public Tuple <VirtualPiece, Vector2Int> DoEverythingBecauseNothingWorks() { int maxUtils = 1500; VirtualPiece bestMovePiece = null; Vector2Int bestMovePosition = new Vector2Int(0, 0); foreach (VirtualPiece piece in playerPiecesDict[playerTurn]) { List <Vector2Int> possileCells = piece.CheckPathing(); Vector2Int currentPosition = piece.cCurrentPosition; bool isDead = piece.cIsDead; foreach (Vector2Int movement in possileCells) { VirtualBoard newVirtualBoard = CloneVirtualBoard(); VirtualPiece newPiece = newVirtualBoard.FindPiece(piece.cCurrentPosition, piece.cPieceName, isDead, piece.cPlayerInt); newPiece.MovePiece(movement.x, movement.y); newVirtualBoard.player1Utils = newVirtualBoard.EvaluateVirtualBoard(); if (newVirtualBoard.aiPlayerWinning) { maxUtils = newVirtualBoard.player1Utils; bestMovePiece = piece; bestMovePosition = movement; return(new Tuple <VirtualPiece, Vector2Int>(bestMovePiece, bestMovePosition)); } int maxUtils2 = -1500; VirtualPiece bestMovePiece2 = null; Vector2Int bestMovePosition2 = new Vector2Int(0, 0); foreach (VirtualPiece piece2 in newVirtualBoard.playerPiecesDict[newVirtualBoard.playerTurn]) { List <Vector2Int> possileCells2 = piece2.CheckPathing(); Vector2Int currentPosition2 = piece2.cCurrentPosition; bool isDead2 = piece2.cIsDead; foreach (Vector2Int movement2 in possileCells2) { VirtualBoard newVirtualBoard2 = newVirtualBoard.CloneVirtualBoard(); VirtualPiece newPiece2 = newVirtualBoard2.FindPiece(piece2.cCurrentPosition, piece2.cPieceName, isDead2, piece2.cPlayerInt); newPiece2.MovePiece(movement2.x, movement2.y); newVirtualBoard2.player1Utils = newVirtualBoard2.EvaluateVirtualBoard(); if (newVirtualBoard2.player1Utils > maxUtils2) { maxUtils2 = newVirtualBoard2.player1Utils; newVirtualBoard.player1Utils = newVirtualBoard2.player1Utils; bestMovePiece2 = newPiece2; bestMovePosition2 = movement2; } } } if (newVirtualBoard.player1Utils < maxUtils) { maxUtils = newVirtualBoard.player1Utils; bestMovePiece = piece; bestMovePosition = movement; } } } return(new Tuple <VirtualPiece, Vector2Int>(bestMovePiece, bestMovePosition)); }
public void CreateRecursiveBoardDict() { foreach (VirtualPiece piece in playerPiecesDict[playerTurn]) { List <Vector2Int> possileCells = piece.CheckPathing(); Vector2Int currentPosition = piece.cCurrentPosition; bool isDead = piece.cIsDead; foreach (Vector2Int movement in possileCells) { VirtualBoard newVirtualBoard = CloneVirtualBoard(); VirtualPiece newPiece = newVirtualBoard.FindPiece(piece.cCurrentPosition, piece.cPieceName, isDead, piece.cPlayerInt); newPiece.MovePiece(movement.x, movement.y); newVirtualBoard.player1Utils = newVirtualBoard.EvaluateVirtualBoard(); recursiveBoardDict.Add(new Tuple <VirtualPiece, Vector2Int>(piece, movement), newVirtualBoard); } } // foreach (VirtualPiece piece in playerPiecesDict[playerTurn]) //{ // if (piece.cPlayerInt == playerTurn) // { // List<Vector2Int> possileCells = piece.CheckPathing(); // Vector2Int currentPosition = piece.cCurrentPosition; // bool isDead = piece.cIsDead; // foreach (Vector2Int movement in possileCells) // { // VirtualBoard newVirtualBoard = CloneVirtualBoard(); // VirtualPiece newPiece = newVirtualBoard.FindPiece(piece.cCurrentPosition, piece.cPieceName, isDead, piece.cPlayerInt); // newPiece.MovePiece(movement.x, movement.y); // newVirtualBoard.player1Utils = newVirtualBoard.EvaluateVirtualBoard(); // recursiveBoardDict.Add(new Tuple<VirtualPiece, Vector2Int>(piece, movement), newVirtualBoard); // } // } //} }