コード例 #1
0
  /**
   * The main method. Several options are listed - simply remove comments to use the option you
   * want.
   *
   * @param args the command line arguments
   */
  public static void main(String[] args) {
    Executor exec = new Executor();

    // run multiple games in batch mode - good for testing.
    int numTrials = 10;
    // exec.runExperiment(new RandomPacMan(),new RandomGhosts(),numTrials);

    /*
    //run a game in synchronous mode: game waits until controllers respond.
    int delay=5;
    boolean visual=true;
    exec.runGame(new RandomPacMan(),new RandomGhosts(),visual,delay);
    		 */

    /// *
    // run the game in asynchronous mode.
    boolean visual = true;
    //		exec.runGameTimed(new NearestPillPacMan(),new AggressiveGhosts(),visual);
    //		exec.runGameTimed(new StarterPacMan(),new StarterGhosts(),visual);
    //		exec.runGameTimed(new HumanController(new KeyBoardInput()),new StarterGhosts(),visual);
    // */

    /*
    //run the game in asynchronous mode but advance as soon as both controllers are ready  - this is the mode of the competition.
    //time limit of DELAY ms still applies.
    boolean visual=true;
    boolean fixedTime=false;
    exec.runGameTimedSpeedOptimised(new RandomPacMan(),new RandomGhosts(),fixedTime,visual);
    */

    /*
    //run game in asynchronous mode and record it to file for replay at a later stage.
    boolean visual=true;
    String fileName="replay.txt";
    exec.runGameTimedRecorded(new HumanController(new KeyBoardInput()),new RandomGhosts(),visual,fileName);
    //exec.replayGame(fileName,visual);
     */

    // run game for data collection
    // exec.runGameTimed(new DataCollectorController(new KeyBoardInput()), new AggressiveGhosts(),
    // visual);

    // Ejecutamos el juego con el controlador de QLearning y con las repeticiones que configuramos
    // A modo orientativo 2000 repeticiones tarda unos 40 segundos en ser ejecutadas
    int repeticiones = 2000;
    exec.runQLearner(new StarterPacMan(), new QController(), repeticiones);
  }