public static int CreateMovementOption(IChessPiece Piece, List <MovementOptions> AllLegalMovesForThisPiece, int direction, int walkingLength, bool enemyAhead, int FuturePositionX, int FuturePositionY) { MovementOptions MoveChoice = Piece.AllMoveOptionsForThisPiece[direction]; MoveChoice.MyPiece = Piece; if (enemyAhead) { MoveChoice.CheckForEnemyResult = 1; walkingLength = 100; } if (Piece.teamDirection == -1) { Piece.AllMoveOptionsForThisPiece[direction].MyTeam = "White"; } else { Piece.AllMoveOptionsForThisPiece[direction].MyTeam = "Black"; } Piece.AllMoveOptionsForThisPiece[direction].PositionX = FuturePositionX; Piece.AllMoveOptionsForThisPiece[direction].PositionY = FuturePositionY; AllLegalMovesForThisPiece.Add(Piece.AllMoveOptionsForThisPiece[direction]); Piece.AllMoveOptionsForThisPiece[direction] = MoveChoice; return(walkingLength); }
//This Method adds a new log entry internal static void AddMoveToLog(MovementOptions move) { //_The New Log__My Team (White or Black)_The Full Name ____________________Old PositionX___________________Old PositionY_____________________NewX_____________________NewY string log = move.MyTeam + " " + move.MyPiece.FullName + " moved from " + move.MyPiece.PositionX + "," + move.MyPiece.PositionY + " to " + move.PositionX + "," + move.PositionY; //Save the newest Log newestLog = log; //Add the new log to the complete list CompleteMoveLog.Add(log); }
//This Method decides if we log an Move or an Strike internal static void LogDecidedMove(MovementOptions move) { if (move.CheckForEnemyResult == 1) { Logger.AddPieceStrikeToLog(move); } else { Logger.AddMoveToLog(move); } }
//Checks where the enemy piece can go. private MovementOptions AddEnemyPieceToMovementOption(MovementOptions movementOption, List <IChessPiece> EnemyPieces) { foreach (var piece in EnemyPieces) { if ((movementOption.PositionX == piece.PositionX) && (movementOption.PositionY == piece.PositionY)) { movementOption.EnemyPiece = piece; return(movementOption); } } return(movementOption); }
//This method adds a log which explains which piece defeated which piece and where. internal static void AddPieceStrikeToLog(MovementOptions move) { string log = move.MyTeam + " " + move.MyPiece.FullName + " moved from " + move.MyPiece.PositionX + "," + move.MyPiece.PositionY + " and removed an enemy " + move.EnemyPiece.FullName + " at position " + move.PositionX + "," + move.PositionY; //Save the newest Log newestLog = log; //Add the new log to the complete list CompleteMoveLog.Add(log); }
//The enemy piece with the highest value can be killed by my piece, which has a lower value than the enemy piece. private MovementOptions FindHighestPieceValue(List <MovementOptions> PiecesICanKill) { var highestValueFound = 0; MovementOptions optimalMovementOption = null; foreach (var movementOption in PiecesICanKill) { if ((highestValueFound < movementOption.EnemyPiece.Value) || ((highestValueFound == movementOption.EnemyPiece.Value) && (optimalMovementOption.MyPiece.Value > movementOption.MyPiece.Value))) { highestValueFound = movementOption.EnemyPiece.Value; optimalMovementOption = movementOption; } } return(optimalMovementOption); }
private void MovePiece(MovementOptions pieceToMove, List <IChessPiece> list, List <IChessPiece> EnemyPiecePositions) { pieceToMove.MyPiece.PositionX = pieceToMove.PositionX; pieceToMove.MyPiece.PositionY = pieceToMove.PositionY; if (pieceToMove.CheckForEnemyResult == 1) { if (pieceToMove.MyTeam == "White") { Logger.WhitePoints += pieceToMove.EnemyPiece.Value; } else { Logger.BlackPoints += pieceToMove.EnemyPiece.Value; } RemoveEnemyPiece(pieceToMove.EnemyPiece); } }
private static void SaveOldPosition(MovementOptions move) { move.OldPositionX = move.MyPiece.PositionX; move.OldPositionY = move.MyPiece.PositionY; }
private static void MakeHypotheticalMove(MovementOptions move) { move.MyPiece.PositionX = move.PositionX; move.MyPiece.PositionY = move.PositionY; }