Esempio n. 1
0
  /**
   * Returns an exact copy of the game. This may be used for forward searches such as minimax. The
   * copying is relatively efficient.
   *
   * @return the game
   */
  public Game copy() {
    Game copy = new Game();

    copy.seed = seed;
    copy.rnd = new Random(seed);
    copy.laberintoActua = laberintoActua;
    copy.pills = (BitSet) pills.clone();
    copy.powerPills = (BitSet) powerPills.clone();
    copy.indiceDeLaberinto = indiceDeLaberinto;
    copy.cuentaElLvl = cuentaElLvl;
    copy.tiempoLvlActual = tiempoLvlActual;
    copy.tiempoTotal = tiempoTotal;
    copy.score = score;
    copy.fastamasComerMultiplicador = fastamasComerMultiplicador;
    copy.juegoTerminado = juegoTerminado;
    copy.timeOfLastGlobalReversal = timeOfLastGlobalReversal;
    copy.pacmanFueComido = pacmanFueComido;
    copy.pastillaFueComida = pastillaFueComida;
    copy.pildoraPoderFueComida = pildoraPoderFueComida;
    copy.pacman = pacman.copy();

    copy.fantasmaComido = new EnumMap<GHOST, Boolean>(GHOST.class);
    copy.fantasmas = new EnumMap<GHOST, Ghost>(GHOST.class);

    for (GHOST ghostType : GHOST.values()) {
      copy.fantasmas.put(ghostType, fantasmas.get(ghostType).copy());
      copy.fantasmaComido.put(ghostType, fantasmaComido.get(ghostType));
    }

    return copy;
  }