Example #1
0
 public void reset(final MarioAIOptions args) {
   deadEndsCount = 0;
   cannonsCount = 0;
   hillStraightCount = 0;
   tubesCount = 0;
   blocksCount = 0;
   coinsCount = 0;
   gapsCount = 0;
   hiddenBlocksCount = 0;
   mushrooms = 0;
   flowers = 0;
   creatures = 0;
   greenMushrooms = 0;
   totalHillStraight = args.getHillStraightCount() ? Integer.MAX_VALUE : 0;
   totalCannons = args.getCannonsCount() ? Integer.MAX_VALUE : 0;
   totalGaps = args.getGapsCount() ? Integer.MAX_VALUE : 0;
   totalDeadEnds = args.getDeadEndsCount() ? Integer.MAX_VALUE : 0;
   totalBlocks = args.getBlocksCount() ? Integer.MAX_VALUE : 0;
   totalHiddenBlocks = args.getHiddenBlocksCount() ? Integer.MAX_VALUE : 0;
   totalCoins = args.getCoinsCount() ? Integer.MAX_VALUE : 0;
   totalTubes = args.getTubesCount() ? Integer.MAX_VALUE : 0;
   resetUncountableCounters();
 }
  public void reset(MarioAIOptions marioAIOptions) {
    //        System.out.println("\nLevelScene RESET!");
    //        this.gameViewer = setUpOptions[0] == 1;
    //        System.out.println("this.mario.isMarioInvulnerable = " +
    // this.mario.isMarioInvulnerable);
    //    this.levelDifficulty = marioAIOptions.getLevelDifficulty();
    //        System.out.println("this.levelDifficulty = " + this.levelDifficulty);
    //    this.levelLength = marioAIOptions.getLevelLength();
    //        System.out.println("this.levelLength = " + this.levelLength);
    //    this.levelSeed = marioAIOptions.getLevelRandSeed();
    //        System.out.println("levelSeed = " + levelSeed);
    //    this.levelType = marioAIOptions.getLevelType();
    //        System.out.println("levelType = " + levelType);

    GlobalOptions.FPS = marioAIOptions.getFPS();
    //        System.out.println("GlobalOptions.FPS = " + GlobalOptions.FPS);
    GlobalOptions.isPowerRestoration = marioAIOptions.isPowerRestoration();
    //        System.out.println("GlobalOptions.isPowerRestoration = " +
    // GlobalOptions.isPowerRestoration);
    //    GlobalOptions.isPauseWorld = marioAIOptions.isPauseWorld();
    GlobalOptions.areFrozenCreatures = marioAIOptions.isFrozenCreatures();
    //        System.out.println("GlobalOptions = " + GlobalOptions.isPauseWorld);
    //        GlobalOptions.isTimer = marioAIOptions.isTimer();
    //        System.out.println("GlobalOptions.isTimer = " + GlobalOptions.isTimer);
    //        isToolsConfigurator = setUpOptions[11] == 1;
    this.setTimeLimit(marioAIOptions.getTimeLimit());
    //        System.out.println("this.getTimeLimit() = " + this.getTimeLimit());
    //        this.isViewAlwaysOnTop() ? 1 : 0, setUpOptions[13]
    GlobalOptions.isVisualization = marioAIOptions.isVisualization();
    //        System.out.println("visualization = " + visualization);

    killedCreaturesTotal = 0;
    killedCreaturesByFireBall = 0;
    killedCreaturesByStomp = 0;
    killedCreaturesByShell = 0;
    bricksBumped = 0;

    marioInitialPos = marioAIOptions.getMarioInitialPos();
    greenMushroomMode = marioAIOptions.getGreenMushroomMode();

    if (replayer != null) {
      try {
        //            replayer.openNextReplayFile();
        replayer.openFile("level.lvl");
        level = (Level) replayer.readObject();
        level.counters.resetUncountableCounters();
        //            replayer.closeFile();
        //            replayer.closeRecorder();
      } catch (IOException e) {
        System.err.println("[Mario AI Exception] : level reading failed");
        e.printStackTrace();
      } catch (Exception e) {
        e.printStackTrace();
      }
    } else level = LevelGenerator.createLevel(marioAIOptions);

    String fileName = marioAIOptions.getLevelFileName();
    if (!fileName.equals("")) {
      try {
        Level.save(level, new ObjectOutputStream(new FileOutputStream(fileName)));
      } catch (IOException e) {
        System.err.println("[Mario AI Exception] : Cannot write to file " + fileName);
        e.printStackTrace();
      }
    }
    this.levelSeed = level.randomSeed;
    this.levelLength = level.length;
    this.levelHeight = level.height;
    this.levelType = level.type;
    this.levelDifficulty = level.difficulty;

    Sprite.spriteContext = this;
    sprites.clear();
    this.width = GlobalOptions.VISUAL_COMPONENT_WIDTH;
    this.height = GlobalOptions.VISUAL_COMPONENT_HEIGHT;

    Sprite.setCreaturesGravity(marioAIOptions.getCreaturesGravity());
    Sprite.setCreaturesWind(marioAIOptions.getWind());
    Sprite.setCreaturesIce(marioAIOptions.getIce());
    Mario.resetStatic(marioAIOptions);

    bonusPoints = -1;

    mario = new Mario(this);
    // System.out.println("mario = " + mario);
    memo = "";

    sprites.add(mario);
    startTime = 1;
    timeLeft = timeLimit * GlobalOptions.mariosecondMultiplier;

    tickCount = 0;
  }
 public void resetDefault() {
   // TODO: set values to defaults
   reset(MarioAIOptions.getDefaultOptions());
 }