private static int GoDeeper(Board currentBoard, int srcX, int srcY, int dstX, int dstY, int level, int highestValue) { int[] move = new int[] { srcX, srcY, dstX, dstY }; int[] arr; Board tempBoard = new Board(); tempBoard.Copy(currentBoard); if (tempBoard.UpdateBoard(srcX, srcY, dstX, dstY)) { if (EvaluateBoard(tempBoard) < highestValue) { return(DONE); } else if (EvaluateBoard(tempBoard) < 9000 || EvaluateBoard(tempBoard) > -1000) { arr = MakeTurn(tempBoard, level + 1); tempBoard.UpdateBoard(arr[0], arr[1], arr[2], arr[3]); return(EvaluateBoard(tempBoard)); } else { return(EvaluateBoard(tempBoard)); } } return(DONE); }
private static int EvaluateMove(Board currentBoard, int srcX, int srcY, int dstX, int dstY, int level) { Board tempBoard = new Board(); tempBoard.Copy(currentBoard); if (tempBoard.UpdateBoard(srcX, srcY, dstX, dstY)) { return(EvaluateBoard(tempBoard)); } return(DONE); }
// ClickHandler for piece. private void Piece_Click(object sender, EventArgs e) { int[] arr; PictureBox b = (PictureBox)sender; if ((game.GetAIState() && playerColour == game.GetTurn()) || !game.GetAIState()) { if (!didChoose) { if (game.GetPiece(b.Location.Y / 57, b.Location.X / 57) != null && game.GetPiece(b.Location.Y / 57, b.Location.X / 57).GetColour() == game.GetTurn()) { srcX = b.Location.Y / 57; srcY = b.Location.X / 57; didChoose = true; // Selects the piece. this.piecesImg[srcX, srcY].Image = ImageHandler.PlaceImage(game.GetPiece(srcX, srcY).GetColour(), game.GetPiece(srcX, srcY).IsDux(), true); } } else { if (game.GetPiece(b.Location.Y / 57, b.Location.X / 57) != null && game.GetPiece(b.Location.Y / 57, b.Location.X / 57).GetColour() == game.GetTurn()) { // Reverts the previous selected piece. this.piecesImg[srcX, srcY].Image = ImageHandler.PlaceImage(game.GetPiece(srcX, srcY).GetColour(), game.GetPiece(srcX, srcY).IsDux(), false); srcX = b.Location.Y / 57; srcY = b.Location.X / 57; // Selects the piece. this.piecesImg[srcX, srcY].Image = ImageHandler.PlaceImage(game.GetPiece(srcX, srcY).GetColour(), game.GetPiece(srcX, srcY).IsDux(), true); } else if (game.GetPiece(b.Location.Y / 57, b.Location.X / 57) == null && game.UpdateBoard(srcX, srcY, b.Location.Y / 57, b.Location.X / 57)) { UpdateBoard(srcX, srcY, b.Location.Y / 57, b.Location.X / 57); didChoose = false; } } } if (game.GetTurn() == game.GetPlayerColour() * -1 && (game.GetAIState() && !didChoose)) { Application.DoEvents(); arr = AI.MakeTurn(game, 0); if (game.UpdateBoard(arr[0], arr[1], arr[2], arr[3])) { UpdateBoard(arr[0], arr[1], arr[2], arr[3]); } } }
private static int GoDeeper(Board currentBoard, int srcX, int srcY, int dstX, int dstY, int level, int highestValue) { int[] move = new int[]{srcX, srcY, dstX, dstY}; int[] arr; Board tempBoard = new Board(); tempBoard.Copy(currentBoard); if (tempBoard.UpdateBoard(srcX, srcY, dstX, dstY)) { if (EvaluateBoard(tempBoard) < highestValue) return DONE; else if (EvaluateBoard(tempBoard) < 9000 || EvaluateBoard(tempBoard) > -1000) { arr = MakeTurn(tempBoard, level + 1); tempBoard.UpdateBoard(arr[0], arr[1], arr[2], arr[3]); return EvaluateBoard(tempBoard); } else return EvaluateBoard(tempBoard); } return DONE; }
private static int EvaluateMove(Board currentBoard, int srcX, int srcY, int dstX, int dstY, int level) { Board tempBoard = new Board(); tempBoard.Copy(currentBoard); if (tempBoard.UpdateBoard(srcX, srcY, dstX, dstY)) return EvaluateBoard(tempBoard); return DONE; }