コード例 #1
0
  public void runGame() {
    SwingUtilities.invokeLater(a);
    try {
      sleep(delay);
    } catch (InterruptedException e) {
      System.out.println("interrupted.");
    }
    while (!world.endGame()) {
      // System.out.println("Game playing. Making move.");
      int action1 = -1;
      int action2 = -1;
      action1 = policy1.getBestAction(world.getState1());
      action2 = policy2.getBestAction(world.getState2());
      System.out.println("action2 " + action2);
      SwingUtilities.invokeLater(a);

      try {
        sleep(delay);
      } catch (InterruptedException e) {
        System.out.println("interrupted.");
      }
    }
    a.agentsScore += world.agent1Score;
    a.catScore += world.fail;

    // turn off gameOn flag if only single game
    if (single) gameOn = false;
  }
コード例 #2
0
 public void resetGame() {
   world.resetState();
 }