void AI_Completed(IMove move) { _aiRunning = false; if (_historyForm != null) { _historyForm.Enabled = true; } btnCancel.Visible = false; btnNew.Enabled = true; listAiLevel.Enabled = true; if (_ai.Canceled) { _aiLevelUpdating = true; _aiLevels[_game.Ply & 1] = null; listAiLevel.SelectedIndex = 0; _aiLevelUpdating = false; } else { move.MakeMove(_game); AddMoveToGameRecord(move); _boardView.InvalidateRender(); _game.Ply++; } PrepareTurn(); }
public bool Move(IMove move, bool sw = true) { move.MakeMove(); History.Add(move); CalculatePieceMoves(); this.NextMovePlayer = GetNextPlayer(NextMovePlayer); if (sw) { if (Board.IsStalemate(this.NextMovePlayer)) { // TODO: FIGURE OUT WHY STALEMATE. I THINK IT IS CHECKING WRONG PLAYER var sm = Board.IsStalemate(this.NextMovePlayer); if (sm) { Console.WriteLine("stalemate"); Console.ReadLine(); } } var cm = Board.IsCheckMate(NextMovePlayer); if (cm) { Console.WriteLine("stalemate"); Console.ReadLine(); } } return(true); }
public bool TryPreviewAt(BoardStackPosition mouseOver) { if (!_game[mouseOver.Position].HasValue) { _boardView.CarryVisible = false; _move = new PlacePieceMove(_pieceID, mouseOver.Position); _move.MakeMove(_game); _boardView.InvalidateRender(); _boardView.SetHighlight(mouseOver.Position, 0); return(true); } return(false); }
void ProcessMove(IMove move = null, TakEngine.Notation.MoveNotation notation = null, bool alreadyExecuted = false) { if (move == null && notation == null) { throw new ArgumentException("move and notation cannot both be null"); } if (notation == null) { if (!TakEngine.Notation.MoveNotation.TryParse(move.Notate(), out notation)) { throw new ApplicationException("Critical move error"); } } else if (move == null) { _tempMoveList.Clear(); Helper.EnumerateMoves(_tempMoveList, _game, _ai.NormalPositions); move = notation.MatchLegalMove(_tempMoveList); if (move == null) { throw new ApplicationException("Illegal move: " + notation.Text); } } if (!alreadyExecuted) { move.MakeMove(_game); } if (!_gameRecord.MoveNotations.Contains(notation)) // if opening an existing game file then we may have already loaded the notation { _gameRecord.MoveNotations.Add(notation); } _navigating = true; if (_historyForm != null) { _historyForm.AddPly(notation.Text); } _navigating = false; _movesOfNotation[notation] = move; _game.Ply++; _boardView.InvalidateRender(); }