コード例 #1
0
    public void init() {
      System.out.println("Initializing simulation (null hypothesis).");

      // Create road
      road = new Road(2, 3);

      // Add lights
      road.addLight(0, 29, 15, 15);
      road.addLight(1, 29, 15, 15);
      // road.addLight(2, 29, 15, 15);

      road.addLight(0, 59, 15, 15);
      road.addLight(1, 59, 15, 15);
      // road.addLight(2, 59, 15, 15);

      // Add left turns
      road.addExit(0, 30, 'n');
      road.addExit(0, 60, 'n');

      // Add right turns
      road.addExit(road.getNumLanes() - 1, 30, 's');
      road.addExit(road.getNumLanes() - 1, 60, 's');

      // Add obstacles?
      for (int i = 1; i < 15; i++) {
        int rightLaneNumber = road.getNumLanes() - 1;
        road.addParkedCar(rightLaneNumber, random.nextInt(road.getLane(rightLaneNumber).length()));
      }

      System.out.println("Exits: " + road.getExits().length);
      System.out.println("Inital road...");
      road.print();
    }
コード例 #2
0
    public void init2() {
      System.out.println("Initializing simulation (alternative hypothesis.");

      // Create road
      road = new Road(3, 3);

      // Add lights
      road.addLight(0, 29, 15, 15);
      road.addLight(1, 29, 15, 15);
      road.addLight(2, 29, 15, 15);

      road.addLight(0, 59, 15, 15);
      road.addLight(1, 59, 15, 15);
      road.addLight(2, 59, 15, 15);

      // NO left turns

      // Add right turns
      road.addExit(road.getNumLanes() - 1, 30, 's');
      road.addExit(road.getNumLanes() - 1, 60, 's');

      // NO parked cars

      System.out.println("Exits: " + road.getExits().length);
      System.out.println("Inital road...");
      road.print();
    }