import java.awt.*;
import java.io.*;
import AgentWorld.*;
import ProductionSystem.*;

// The 'main' class for running the 'Agent World' of CS 540.
//
//   - copyrighted 1997, 1998 by Jude Shavlik
//     (for educational use only)
//

// This is the HW5 (Production Systems) version of RunAgentWorld.

public class RunAgentWorld 
{
  public static void main(String args[])
  { boolean barrenWorld = false; // For debugging purposes, it can be helpful to
                                 // set this true and only have your own player
                                 // out there.

    boolean sparseWorld = true;  // For slower computers, have less objects 
                                 // in the world (the dimensions of the
                                 // world can't be changed).

    try 
    { // Need an AgentWindow instance with which to communicate.
      // This argument indicates whether the game is being displayed.
      // (you might wish to turn this off in the machine learning HW
      // to conserve cpu cycles for training).
      AgentWindow aw = new AgentWindow(true);

      // Show the productin-system (PS) player's sensors.
      // The production rules should be in the file "rules.txt"
      // and this file should be in the same directory as the one
      // from which you call Java.
      aw.addPlayer(new PSPlayer(aw, true, "rules.txt"), "ProdSys Player", Color.blue);

      // Create a malicious player that chases other players and one smart player.
      if (!barrenWorld) aw.addAssassin("The Jackal",     Color.pink);
      if (!barrenWorld) aw.addSmartPlayer("SmartPlayer", Color.green);
 
      // Add some players whose scores aren't reported on the score board.
      if (!barrenWorld) aw.addAnonymousAssassins(1);
      if (!barrenWorld) aw.addAnonymousRandomWalkers(1);
      if (!barrenWorld) aw.addAnonymousSmartPlayers(1);
 
      // For simplicity, don't have any minerals (at least initially) in this HW.
      if (!barrenWorld && !sparseWorld) aw.addMinerals(50);
      if (!barrenWorld) aw.addVegetables(50); // 100 is the maximum allowed.

      aw.setClockPeriod(250);

      // You can request that the 'manager' wait for you to 
      // press GO before each move.
      // In this homework it is probably best to start in single-stepping mode
      // so you can see which rules are chosen.
      aw.setSingleStepMode(true);

      // Comment out the next line if you want to configure the initial world.
      aw.playThisManyGamesEachOfThisManyTimeSteps(100, 1000);
    }
    
    catch(Exception e)
    {
      Utils.println("Exception encountered in main method: " + e);
      Utils.println("The following indicates the location of the problem:");
      e.printStackTrace(System.err);
      Utils.exit(-1);
    }
  }

}
