diff --git a/Checkers/Assets/Scenes/Main.unity b/Checkers/Assets/Scenes/Main.unity index 1476140..c928c87 100644 --- a/Checkers/Assets/Scenes/Main.unity +++ b/Checkers/Assets/Scenes/Main.unity @@ -178,187 +178,6 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 6 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!43 &164254807 -Mesh: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_Name: - serializedVersion: 9 - m_SubMeshes: - - serializedVersion: 2 - firstByte: 0 - indexCount: 12 - topology: 0 - baseVertex: 0 - firstVertex: 0 - vertexCount: 4 - localAABB: - m_Center: {x: 0, y: 0, z: 0} - m_Extent: {x: 0.5, y: 0.5, z: 0} - m_Shapes: - vertices: [] - shapes: [] - channels: [] - fullWeights: [] - m_BindPose: [] - m_BoneNameHashes: - m_RootBoneNameHash: 0 - m_MeshCompression: 0 - m_IsReadable: 1 - m_KeepVertices: 1 - m_KeepIndices: 1 - m_IndexFormat: 0 - m_IndexBuffer: 000002000100020003000100000000000000000000000000 - m_VertexData: - serializedVersion: 2 - m_VertexCount: 4 - m_Channels: - - stream: 0 - offset: 0 - format: 0 - dimension: 3 - - stream: 0 - offset: 12 - format: 0 - dimension: 3 - - stream: 0 - offset: 0 - format: 0 - dimension: 0 - - stream: 0 - offset: 24 - format: 0 - dimension: 4 - - stream: 0 - offset: 40 - format: 0 - dimension: 2 - - stream: 0 - offset: 0 - format: 0 - dimension: 0 - - stream: 0 - offset: 0 - format: 0 - dimension: 0 - - stream: 0 - offset: 0 - format: 0 - dimension: 0 - - stream: 0 - offset: 0 - format: 0 - dimension: 0 - - stream: 0 - offset: 0 - format: 0 - dimension: 0 - - stream: 0 - offset: 0 - format: 0 - dimension: 0 - - stream: 0 - offset: 0 - format: 0 - dimension: 0 - - stream: 0 - offset: 0 - format: 0 - dimension: 0 - - stream: 0 - offset: 0 - format: 0 - dimension: 0 - m_DataSize: 192 - _typelessdata: 000000bf000000bf000000000000008000000080000080bf2a39e33dc65cb63d4c305e3e0000803f00000000000000000000003f000000bf000000000000008000000080000080bf2a39e33dc65cb63d4c305e3e0000803f0000803f00000000000000bf0000003f000000000000008000000080000080bf6caa423e4c5c573e5cd9e73e0000803f000000000000803f0000003f0000003f000000000000008000000080000080bf6caa423e4c5c573e5cd9e73e0000803f0000803f0000803f - m_CompressedMesh: - m_Vertices: - m_NumItems: 0 - m_Range: 0 - m_Start: 0 - m_Data: - m_BitSize: 0 - m_UV: - m_NumItems: 0 - m_Range: 0 - m_Start: 0 - m_Data: - m_BitSize: 0 - m_Normals: - m_NumItems: 0 - m_Range: 0 - m_Start: 0 - m_Data: - m_BitSize: 0 - m_Tangents: - m_NumItems: 0 - m_Range: 0 - m_Start: 0 - m_Data: - m_BitSize: 0 - m_Weights: - m_NumItems: 0 - m_Data: - m_BitSize: 0 - m_NormalSigns: - m_NumItems: 0 - m_Data: - m_BitSize: 0 - m_TangentSigns: - m_NumItems: 0 - m_Data: - m_BitSize: 0 - m_FloatColors: - m_NumItems: 0 - m_Range: 0 - m_Start: 0 - m_Data: - m_BitSize: 0 - m_BoneIndices: - m_NumItems: 0 - m_Data: - m_BitSize: 0 - m_Triangles: - m_NumItems: 0 - m_Data: - m_BitSize: 0 - m_UVInfo: 0 - m_LocalAABB: - m_Center: {x: 0, y: 0, z: 0} - m_Extent: {x: 0.5, y: 0.5, z: 0} - m_MeshUsageFlags: 0 - m_BakedConvexCollisionMesh: - m_BakedTriangleCollisionMesh: - m_MeshMetrics[0]: 1 - m_MeshMetrics[1]: 1 - m_MeshOptimized: 0 - m_StreamData: - offset: 0 - size: 0 - path: ---- !u!21 &176366238 -Material: - serializedVersion: 6 - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_Name: Custom/VertexColorCamera - m_Shader: {fileID: 4800000, guid: 04ede0abc1e28a148a7a91cc95adf385, type: 3} - m_ShaderKeywords: - m_LightmapFlags: 4 - m_EnableInstancingVariants: 0 - m_DoubleSidedGI: 0 - m_CustomRenderQueue: -1 - stringTagMap: {} - disabledShaderPasses: [] - m_SavedProperties: - serializedVersion: 3 - m_TexEnvs: [] - m_Floats: [] - m_Colors: [] --- !u!1 &181847786 GameObject: m_ObjectHideFlags: 0 @@ -1043,7 +862,7 @@ Transform: m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - - {fileID: 1032017646} + - {fileID: 1356140377} m_Father: {fileID: 1510433598} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -1138,7 +957,7 @@ MonoBehaviour: m_NumColorKeys: 2 m_NumAlphaKeys: 2 placeAtClippingPlane: 0 - childObject: {fileID: 1032017645} + childObject: {fileID: 1356140376} --- !u!1 &654029429 GameObject: m_ObjectHideFlags: 0 @@ -1252,83 +1071,27 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 654029429} m_CullTransparentMesh: 0 ---- !u!1 &1032017645 -GameObject: - m_ObjectHideFlags: 1 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} +--- !u!21 &837826814 +Material: serializedVersion: 6 - m_Component: - - component: {fileID: 1032017646} - - component: {fileID: 1032017648} - - component: {fileID: 1032017647} - m_Layer: 0 - m_Name: CameraFixedGradientSky - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &1032017646 -Transform: - m_ObjectHideFlags: 1 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1032017645} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0.31} - m_LocalScale: {x: 0.6363683, y: 0.35795715, z: 0} - m_Children: [] - m_Father: {fileID: 534669905} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!23 &1032017647 -MeshRenderer: - m_ObjectHideFlags: 1 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1032017645} - m_Enabled: 1 - m_CastShadows: 0 - m_ReceiveShadows: 0 - m_DynamicOccludee: 0 - m_MotionVectors: 1 - m_LightProbeUsage: 0 - m_ReflectionProbeUsage: 0 - m_RenderingLayerMask: 1 - m_RendererPriority: 0 - m_Materials: - - {fileID: 176366238} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!33 &1032017648 -MeshFilter: - m_ObjectHideFlags: 1 + m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1032017645} - m_Mesh: {fileID: 164254807} + m_Name: Custom/VertexColorCamera + m_Shader: {fileID: 4800000, guid: 04ede0abc1e28a148a7a91cc95adf385, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: [] + m_Floats: [] + m_Colors: [] --- !u!1 &1071588205 GameObject: m_ObjectHideFlags: 0 @@ -1714,6 +1477,83 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 52.5, y: 30, z: 0} +--- !u!1 &1356140376 +GameObject: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1356140377} + - component: {fileID: 1356140379} + - component: {fileID: 1356140378} + m_Layer: 0 + m_Name: CameraFixedGradientSky + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1356140377 +Transform: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1356140376} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0.31} + m_LocalScale: {x: 0.6363683, y: 0.35795715, z: 0} + m_Children: [] + m_Father: {fileID: 534669905} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &1356140378 +MeshRenderer: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1356140376} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 0 + m_ReflectionProbeUsage: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 837826814} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!33 &1356140379 +MeshFilter: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1356140376} + m_Mesh: {fileID: 2093128527} --- !u!1 &1448798574 GameObject: m_ObjectHideFlags: 0 @@ -3212,6 +3052,166 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: MoveTreeBuilder: {fileID: 1531258111} +--- !u!43 &2093128527 +Mesh: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + serializedVersion: 9 + m_SubMeshes: + - serializedVersion: 2 + firstByte: 0 + indexCount: 12 + topology: 0 + baseVertex: 0 + firstVertex: 0 + vertexCount: 4 + localAABB: + m_Center: {x: 0, y: 0, z: 0} + m_Extent: {x: 0.5, y: 0.5, z: 0} + m_Shapes: + vertices: [] + shapes: [] + channels: [] + fullWeights: [] + m_BindPose: [] + m_BoneNameHashes: + m_RootBoneNameHash: 0 + m_MeshCompression: 0 + m_IsReadable: 1 + m_KeepVertices: 1 + m_KeepIndices: 1 + m_IndexFormat: 0 + m_IndexBuffer: 000002000100020003000100000000000000000000000000 + m_VertexData: + serializedVersion: 2 + m_VertexCount: 4 + m_Channels: + - stream: 0 + offset: 0 + format: 0 + dimension: 3 + - stream: 0 + offset: 12 + format: 0 + dimension: 3 + - stream: 0 + offset: 0 + format: 0 + dimension: 0 + - stream: 0 + offset: 24 + format: 0 + dimension: 4 + - stream: 0 + offset: 40 + format: 0 + dimension: 2 + - stream: 0 + offset: 0 + format: 0 + dimension: 0 + - stream: 0 + offset: 0 + format: 0 + dimension: 0 + - stream: 0 + offset: 0 + format: 0 + dimension: 0 + - stream: 0 + offset: 0 + format: 0 + dimension: 0 + - stream: 0 + offset: 0 + format: 0 + dimension: 0 + - stream: 0 + offset: 0 + format: 0 + dimension: 0 + - stream: 0 + offset: 0 + format: 0 + dimension: 0 + - stream: 0 + offset: 0 + format: 0 + dimension: 0 + - stream: 0 + offset: 0 + format: 0 + dimension: 0 + m_DataSize: 192 + _typelessdata: 000000bf000000bf000000000000008000000080000080bf2a39e33dc65cb63d4c305e3e0000803f00000000000000000000003f000000bf000000000000008000000080000080bf2a39e33dc65cb63d4c305e3e0000803f0000803f00000000000000bf0000003f000000000000008000000080000080bf6caa423e4c5c573e5cd9e73e0000803f000000000000803f0000003f0000003f000000000000008000000080000080bf6caa423e4c5c573e5cd9e73e0000803f0000803f0000803f + m_CompressedMesh: + m_Vertices: + m_NumItems: 0 + m_Range: 0 + m_Start: 0 + m_Data: + m_BitSize: 0 + m_UV: + m_NumItems: 0 + m_Range: 0 + m_Start: 0 + m_Data: + m_BitSize: 0 + m_Normals: + m_NumItems: 0 + m_Range: 0 + m_Start: 0 + m_Data: + m_BitSize: 0 + m_Tangents: + m_NumItems: 0 + m_Range: 0 + m_Start: 0 + m_Data: + m_BitSize: 0 + m_Weights: + m_NumItems: 0 + m_Data: + m_BitSize: 0 + m_NormalSigns: + m_NumItems: 0 + m_Data: + m_BitSize: 0 + m_TangentSigns: + m_NumItems: 0 + m_Data: + m_BitSize: 0 + m_FloatColors: + m_NumItems: 0 + m_Range: 0 + m_Start: 0 + m_Data: + m_BitSize: 0 + m_BoneIndices: + m_NumItems: 0 + m_Data: + m_BitSize: 0 + m_Triangles: + m_NumItems: 0 + m_Data: + m_BitSize: 0 + m_UVInfo: 0 + m_LocalAABB: + m_Center: {x: 0, y: 0, z: 0} + m_Extent: {x: 0.5, y: 0.5, z: 0} + m_MeshUsageFlags: 0 + m_BakedConvexCollisionMesh: + m_BakedTriangleCollisionMesh: + m_MeshMetrics[0]: 1 + m_MeshMetrics[1]: 1 + m_MeshOptimized: 0 + m_StreamData: + offset: 0 + size: 0 + path: --- !u!1001 &5814978486000392399 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Checkers/Assets/Scripts/AI/MoveTreeBuilder.cs b/Checkers/Assets/Scripts/AI/MoveTreeBuilder.cs index fb8e95a..9a1f993 100644 --- a/Checkers/Assets/Scripts/AI/MoveTreeBuilder.cs +++ b/Checkers/Assets/Scripts/AI/MoveTreeBuilder.cs @@ -55,14 +55,14 @@ public void DoPlayerMove(Move playerMove) private void CreateMoveTree(Move initialMove) { moveTree = new TreeNode(initialMove); - AddMovesToTreeNode(moveTree, MoveTreeDepth, int.MinValue, int.MaxValue); + AddMovesToTreeNode(moveTree, MoveTreeDepth); } - private void AddMovesToTreeNode(TreeNode treeNode, int depth, int alpha, int beta) + private void AddMovesToTreeNode(TreeNode treeNode, int depth) { DoMove(treeNode.Value); if (depth != 0) - AddPossibleMoves(treeNode, depth, alpha, beta); + AddPossibleMoves(treeNode, depth); AssignMoveScore(treeNode); UndoMove(treeNode.Value); } @@ -70,8 +70,6 @@ private void AddMovesToTreeNode(TreeNode treeNode, int depth, int alpha, i private void DoMove(Move move) { aiPawnMover.DoMove(move); -// Debug.Log("Move from " + move.From.Column + ", " + move.From.Row + " to " + move.To.Column + ", " + -// move.To.Row); DecrementPawnsCountIfCapturing(move); } @@ -89,15 +87,15 @@ private PawnColor GetPawnColor(GameObject pawn) return pawn.GetComponent().PawnColor; } - private void AddPossibleMoves(TreeNode treeNode, int depth, int alpha, int beta) + private void AddPossibleMoves(TreeNode treeNode, int depth) { if (treeNode.Value.IsMulticapturing) - ContinueMulticapturingMove(treeNode, depth, alpha, beta); + ContinueMulticapturingMove(treeNode, depth); else - AddNewMove(treeNode, depth, alpha, beta); + AddNewMove(treeNode, depth); } - private void ContinueMulticapturingMove(TreeNode treeNode, int depth, int alpha, int beta) + private void ContinueMulticapturingMove(TreeNode treeNode, int depth) { GameObject pawn = GetPawnFromTreeNode(treeNode); var capturingMoves = moveChecker.GetPawnCapturingMoves(pawn); @@ -106,10 +104,7 @@ private void ContinueMulticapturingMove(TreeNode treeNode, int depth, int { var move = new Move(pawnTileIndex, moveIndex); var moveTreeNode = treeNode.AddChild(move); - AddMovesToTreeNode(moveTreeNode, depth - 1, alpha, beta); - SetAlphaAndBeta(IsMoveByMaximizingPlayer(treeNode), moveTreeNode.Value.Score, ref alpha, ref beta); - if (beta <= alpha) - return; + AddMovesToTreeNode(moveTreeNode, depth - 1); } } @@ -118,15 +113,7 @@ private GameObject GetPawnFromTreeNode(TreeNode treeNode) return tileGetter.GetTile(treeNode.Value.To).GetComponent().GetPawn(); } - private void SetAlphaAndBeta(bool isMoveByMaximizingPlayer, int score, ref int alpha, ref int beta) - { - if (isMoveByMaximizingPlayer) - alpha = Mathf.Max(alpha, score); - else - beta = Mathf.Min(beta, score); - } - - private void AddNewMove(TreeNode treeNode, int depth, int alpha, int beta) + private void AddNewMove(TreeNode treeNode, int depth) { foreach (var pawn in GetPawnsToCheck(treeNode)) { @@ -137,10 +124,7 @@ private void AddNewMove(TreeNode treeNode, int depth, int alpha, int beta) { var move = new Move(pawnTileIndex, moveIndex); var moveTreeNode = treeNode.AddChild(move); - AddMovesToTreeNode(moveTreeNode, depth - 1, alpha, beta); - SetAlphaAndBeta(IsMoveByMaximizingPlayer(treeNode), moveTreeNode.Value.Score, ref alpha, ref beta); - if (beta <= alpha) - return; + AddMovesToTreeNode(moveTreeNode, depth - 1); } } } @@ -167,8 +151,6 @@ private void AssignMoveScore(TreeNode treeNode) treeNode.Value.Score = whitePawnsCount - blackPawnsCount; else AssignMoveScoreByPawnColor(treeNode); -// Debug.Log("Assigned score for move from " + treeNode.Value.From.Column + ", " + treeNode.Value.From.Row + -// " to " + treeNode.Value.To.Column + ", " + treeNode.Value.To.Row + ": " + treeNode.Value.Score); } private void AssignMoveScoreByPawnColor(TreeNode treeNode) @@ -193,8 +175,6 @@ private bool IsMoveByMaximizingPlayer(TreeNode treeNode) private void UndoMove(Move move) { aiPawnMover.UndoMove(move); -// Debug.Log("Undo move from " + move.From.Column + ", " + move.From.Row + " to " + move.To.Column + ", " + -// move.To.Row); IncrementPawnsCountIfCapturing(move); }