public WaitingForPlayerMoveState(IPhutballBoard phutballBoard, MovesHistory movesHistory, IPlayersState playersState) { _phutballBoard = phutballBoard; _movesHistory = movesHistory; _playersState = playersState; _performMoves = new PerformMoves(phutballBoard, playersState); }
public int MakeMove(Move m) { MovesHistory.Add(new Tuple <Move, int, Point>(m, Turn.GetPlyCounter(), Turn.GetPreviouslyMovedPiece())); if (m.FromPiece == Const.FLAGSHIP) //Flagship has been moved --> Update flagship position { FlagshipPosition = m.To; } else if (m.ToPiece == Const.FLAGSHIP) //Flagship has been captured --> Set flagship as out of the board { FlagshipPosition = new Point(-1, -1); } //Make move Board.Grid[m.To.X, m.To.Y] = Board.Grid[m.From.X, m.From.Y]; Board.Grid[m.From.X, m.From.Y] = 0; Turn.PlayerMoved(m); CleanLegalMoves(); if (Terminal()) { Winner = Utils.Utils.PieceToColor(MovesHistory.Last().Item1.FromPiece) == Color.Gold ? Color.Gold : Color.Silver; GameStatus = Const.GAME_OVER; } return(0); }
public BestMoveApplier(IMoveFinders moveFinders, MovesHistory movesHistory, IFieldsGraph fieldsGraph, IPerformMoves performMoves, IEventPublisher eventPublisher) { _moveFinders = moveFinders; _eventPublisher = eventPublisher; _performMoves = performMoves; _movesHistory = movesHistory; _fieldsGraph = fieldsGraph; }
public PlayerSelectedFieldStateMove( IPhutballBoard phutballBoard, IPlayersState playersState, Field selectedField, MovesHistory movesHistory) { _phutballBoard = phutballBoard; _movesHistory = movesHistory; _playersState = playersState; _performMoves = new PerformMoves(phutballBoard, _playersState); _selectedField = selectedField; }
public void SimulateMove(Move m) { MovesHistory.Add(new Tuple <Move, int, Point>(m, Turn.GetPlyCounter(), Turn.GetPreviouslyMovedPiece())); Board.Grid[m.To.X, m.To.Y] = Board.Grid[m.From.X, m.From.Y]; Board.Grid[m.From.X, m.From.Y] = 0; Turn.PlayerMoved(m); if (m.FromPiece == Const.FLAGSHIP) //Flagship has been moved --> Update flagship position { FlagshipPosition = m.To; } else if (m.ToPiece == Const.FLAGSHIP) //Flagship has been captured --> Set flagship as out of the board { FlagshipPosition = new Point(-1, -1); } CleanLegalMoves(); }
public void Play(TimeSpan maxTime) { while (true) { if (!GameState.GetAvailableMoves(true).Any()) { break; } var move = WhiteAgent.GetMove(maxTime); GameState.MakeMove(move); MovesHistory.Add(move); if (!GameState.GetAvailableMoves(false).Any()) { break; } move = BlackAgent.GetMove(maxTime); GameState.MakeMove(move); MovesHistory.Add(move); } WhiteAgent.Finalize(); BlackAgent.Finalize(); }
public void UndoMove(Move m) { Board.Grid[m.From.X, m.From.Y] = m.FromPiece; Board.Grid[m.To.X, m.To.Y] = m.ToPiece; Turn.PlayerUnMoved(MovesHistory.Last()); MovesHistory.RemoveAt(MovesHistory.Count - 1); //Turn.SetPreviousPieceMoved(MovesHistory.Last().Item3); if (m.FromPiece == Const.FLAGSHIP) { FlagshipPosition = m.From; } else if (m.ToPiece == Const.FLAGSHIP) { FlagshipPosition = m.To; } CleanLegalMoves(); }
public MovesHistoryPresenter(MovesHistory movesHistory, IEventPublisher eventPublisher) { _movesHistory = movesHistory; _eventPublisher = eventPublisher; _eventPublisher.Subscribe <MovesHistoryChanged>(OnMovesHistoryChanged); }
public GameUI() { game = new Game(); GameHistory = new MovesHistory(); }