static Board Simulate(Action move) { var board = CurrentBoard.Copy(); var playerId = 0; // Start Simulating var unit = board.Units[playerId, move.Index]; // MOVE&BUILD : if (move.Type == "MOVE&BUILD") { // MOVE int oldHeight = board.Cases[unit.X, unit.Y].Height; unit.X = unit.X + Board.Offsets[move.Dir1, 0]; unit.Y = unit.Y + Board.Offsets[move.Dir1, 1]; // Scores data move.HeightDifference = board.Cases[unit.X, unit.Y].Height - oldHeight; move.PointScored = board.Cases[unit.X, unit.Y].Height == 3; // BUILD var buildX = unit.X + Board.Offsets[move.Dir2, 0]; var buildY = unit.Y + Board.Offsets[move.Dir2, 1]; //TODO : check if occupied by a potential ennemy position board.Cases[buildX, buildY].Height++; } else if (move.Type == "PUSH&BUILD") { // PUSH var newX = unit.X + Board.Offsets[move.Dir1, 0]; var newY = unit.Y + Board.Offsets[move.Dir1, 1]; int oldEnnemyHeight = board.Cases[newX, newY].Height; for (int u = 0; u < Board.UnitsPerPlayer; ++u) { Unit ennemyUnit = board.Units[1 - playerId, u]; if (ennemyUnit.X == newX && ennemyUnit.Y == newY) { ennemyUnit.X = ennemyUnit.X + Board.Offsets[move.Dir2, 0]; ennemyUnit.Y = ennemyUnit.Y + Board.Offsets[move.Dir2, 1]; move.EnnemyPushedHeightDifference = board.Cases[ennemyUnit.X, ennemyUnit.Y].Height - oldEnnemyHeight; break; } } // BUILD board.Cases[newX, newY].Height++; } return(board); }