private void performMove(Move move, bool newMovePath = true, bool refreshDesk = true, bool autorunAI = true) { if (newMovePath) { // in case some undo moves were made, clear this history int movesUndoneCnt = movesUndone.Count; while (movesUndoneCnt > 0) { gameMovesHistory.Items.RemoveAt(0); movesUndoneCnt--; } movesUndone.Clear(); } movesDone.Add(move); boardMakeMove(move); desk.makeMove(move); if (refreshDesk) { tableDesk.Refresh(); } incrementGameSteps(); updatePlayerPiecesCnt(rules.getOppositePlayer(desk.getCurrentPlayer())); if (newMovePath) { addGameHistoryMove(move); } if (rules.isGameEnd(desk)) { gameFinished(); return; } desk.setCurrentPlayer(rules.getNextPlayer(desk)); setActivePlayer(desk.getCurrentPlayer(), autorunAI, refreshDesk); }
private void startAIComputing(object sender, DoWorkEventArgs e) { // run ai with its own desk, while computing the desk is modified Desk aiDesk = new Desk(rules.getDeskSize(), rules.getPiecesPerPlayer()); aiDesk.setPlayerPieces(desk.getPlayerFields(GameVar.PLAYER_WHITE), GameVar.PLAYER_WHITE); aiDesk.setPlayerPieces(desk.getPlayerFields(GameVar.PLAYER_BLACK), GameVar.PLAYER_BLACK); aiDesk.setCurrentPlayer(desk.getCurrentPlayer()); aiMove = engine.getBestMove(aiDesk, rules); }