public Game CreateNewGame() { var game = new Game(); game.Players = new List<Player> { new Player(GameSide.White), new Player(GameSide.Black, true) }; game.Board = _boardBuilder.CreateNewBoard(); return game; }
public void StartGame() { Game = _gameBuilder.CreateNewGame(); _boardHandler.Draw(Game.Board); while (true) { var move = _moveHandler.GetNextMove(Game); _moveHandler.HandleMove(Game, move); _boardHandler.Draw(Game.Board); } }
public Move SelectBestMove(Game game, List<Move> availableMoves) { var bestValue = -9999; Move bestMove = null; foreach (var move in availableMoves) { var moveScore = _moveEvaluator.EvaluateMove(game, move); if (bestMove == null || (moveScore > bestValue)) { bestMove = move; bestValue = moveScore; } } return bestMove; }
private List<Move> GetAllAvailableMove(Game game, GameSide gameSide) { var availableMoves = new List<Move>(); foreach (var figure in game.Board.Figures.Where(x => x.Side == gameSide)) { var allMovesForFigure = figure.GetFieldsICanMoveTo(); foreach (var locationToMoveTo in allMovesForFigure) { var move = new Move(figure.Location, locationToMoveTo, gameSide); if (_moveValidator.MoveIsValid(move,game.Board)) availableMoves.Add(move); } } return availableMoves; }
public MoveResult HandleMove(Game game, Move move) { var existingFigure = game.Board.GetFigureOnLocation(move.To); if (existingFigure != null) game.Board.CaptureFigure(existingFigure); var figureToMove = game.Board.GetFigureOnLocation(move.From); if (figureToMove.ShouldConvert(move)) { game.Board.ConvertFigure(figureToMove, move); } else { figureToMove.Move(move); } return GetMoveResult(game.Board, move.Side); }
public Move GetNextMove(Game game) { var player = game.GetNextToMove(); Move move; if (player.IsAIPlayer) { move = _moveGenerator.GenerateMove(game, player.GameSide); } else { while (true) { move = _userMoveReader.FetchMove(player.GameSide); if (_moveValidator.MoveIsValid(move, game.Board)) break; } } game.SwitchNextPlayer(); return move; }
public Move GenerateMove(Game game, GameSide gameSide) { var availableMoves = GetAllAvailableMove(game, gameSide); return _moveSelector.SelectBestMove(game, availableMoves); }
public int EvaluateMove(Game game, Move move) { throw new System.NotImplementedException(); }