public JokerPoint betterPlanMove(JokerGame game) { if (orderMap == null) { initOrderMap(game.getHeight()); } int n = game.getHeight(); JokerMove prevMove; if ((prevMove = game.getLastMove()) != null) { int row = prevMove.getLocation().x; int col = prevMove.getLocation().y; updateOrderMap(row, col, n); } char[,] tmpBoard = game.getBoardCopy(); int best = int.MinValue; List <JokerPoint> bestMoves = new List <JokerPoint>(); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (tmpBoard[i, j] != '*') { continue; } tmpBoard[i, j] = color; int heuristic = AiUtil.getLiberties(getColor(), tmpBoard); heuristic -= (AiUtil.getLiberties(getOpponentColor(), tmpBoard) * 2); heuristic += orderMap[i, j]; if (heuristic > best) { best = heuristic; bestMoves.Clear(); bestMoves.Add(new JokerPoint(i, j)); } else if (heuristic == best) { bestMoves.Add(new JokerPoint(i, j)); } tmpBoard[i, j] = '*'; } } JokerPoint bestMove = bestMoves[Randomizer.Next(bestMoves.Count)]; updateOrderMap(bestMove.x, bestMove.y, n); return(bestMove); }
public override void planMove(JokerGame game) { char[,] board = game.getBoard(); List <JokerPoint> list = new List <JokerPoint>(); for (int i = 0; i < game.getHeight(); i++) { for (int j = 0; j < game.getWidth(); j++) { if (board[i, j] == '*') { list.Add(new JokerPoint(i, j)); } } } JokerPoint randomMove = list[rand.Next(list.Count)]; while (!list.isEmpty()) { if (makeMove(game, randomMove)) { return; } } }
public override void planMove(JokerGame game) { if (influence == null) { initInfluenceMap(game.getHeight()); } boardCopy = game.getBoardCopy(); this._maxDepth = game.getWidth() + 1; alphabeta(this._maxDepth, -INF, INF, getColor()); makeMove(game, bestMove); }
public JokerPoint betterPlanMove(JokerGame game, int maxDepth) { // Takes 95% CPU if (influence == null) { initInfluenceMap(game.getHeight()); } boardCopy = game.getBoardCopy(); this._maxDepth = maxDepth; alphabeta(this._maxDepth, -INF, INF, getColor()); return(bestMove); }