Exemplo n.º 1
0
 public IPuzzleMove selectMove(IPuzzleState gameState)
 {
     if (rnd.NextDouble() < inertiaProbability)
     {
         List <IPuzzleMove> moves = gameState.GetMoves();
         SokobanGameState   state = (SokobanGameState)gameState;
         foreach (IPuzzleMove m in moves)
         {
             SokobanPushMove push = (SokobanPushMove)m;
             if (push.MoveList.Count() == 0)
             {
                 return(m);
             }
         }
     }
     return(gameState.GetRandomMove());
 }
Exemplo n.º 2
0
        public static GoalMacro GenerateGoalMacro(Position playerPosition, Position goal, Position entrance, List <Position> boxesInGoal, SokobanGameState state)
        {
            SokobanGameState clone = (SokobanGameState)state.Clone();

            clone.ClearBoardForGoalMacro(boxesInGoal, goal, entrance);

            if (clone.Board[playerPosition.X, playerPosition.Y] == SokobanGameState.EMPTY || clone.Board[playerPosition.X, playerPosition.Y] == SokobanGameState.GOAL)
            {
                clone.SetPlayerPosition(playerPosition);
                AbstractSokobanState clearState = new AbstractSokobanState(clone.ToString(), clone.RewardType, false, false, false, false, clone.SimulationStrategy, null);
                SokobanPushMove      pushMove   = SolveMacro(clearState);
                if (pushMove != null)
                {
                    return(new GoalMacro(playerPosition, pushMove));
                }
            }
            return(null);
        }