public void DoMove(IPuzzleMove move) { stateChanged = false; SamegameGameMove sgmove = move as SamegameGameMove; //int value = board[sgmove.X][sgmove.Y]; //HashSet<Position> visited = new HashSet<Position>(); //List<Position> toRemove = new List<Position>(); //CheckAdjacentBlocks(sgmove.X, sgmove.Y, value, ref visited, ref toRemove); //remove adjacent blocks if (sgmove.Blocks.Count > 0) { board[sgmove.X][sgmove.Y] = 1000; score += (int)Math.Pow((sgmove.Blocks.Count() - 2), 2); stateChanged = true; } foreach (Position position in sgmove.Blocks) { board[position.X][position.Y] = 1000; } for (int i = 0; i < board.Count; i++) { board[i].RemoveAll(v => v == 1000); } board.RemoveAll(column => column.Count == 0); //remove empty columns }
public IPuzzleMove selectMove(IPuzzleState gameState) { List <IPuzzleMove> moves = gameState.GetMoves(); if (rnd.NextDouble() <= 0.00007) //epsilon greedy { return(moves[rnd.Next(moves.Count)]); } moves.RemoveAll(item => gameState.GetBoard(SamegameGameMove.GetX(item), SamegameGameMove.GetY(item)) == selectedColor); if (moves.Count == 0) { moves = gameState.GetMoves(); } IPuzzleMove selectedMove = moves[rnd.Next(moves.Count)]; return(selectedMove); }