예제 #1
0
    public void Start()
    {
        // Set up the world with the initial state
        currentWorld = new World();

        // Create QLearner object
        qLearner = new QLearner(alpha: 0.3f, epsilon: 0.15f, discount: 0.66f);
        qLearner.OpenSavedData();

        // Create 2 ai agents
        agentList = new List <IAgent>();
        AIAgent ai1 = new AIAgent(1);

        ai1.IsLearning = true;
        ai1.QLearner   = qLearner;
        AIAgent ai2 = new AIAgent(2);

        ai2.IsLearning = true;
        ai2.QLearner   = qLearner;
        agentList.Add(ai1);
        agentList.Add(ai2);

        // Specify number of games
        numberOfGames = 10;

        // Specify which iteration of games we are on
        gameIteration = 1;
        gameFrames    = 0;

        Debug.Log("Beginning learning.  Simulating " + numberOfGames.ToString() + " games before writing.");
    }
예제 #2
0
    // First-time setup
    void Start()
    {
        // Set up the world with the initial state
        currentWorld = new RenderedWorld(this);
        currentWorld.Display();
        Gui.SetMode(0);

        restartTimer = -1;
        winner       = 0;
        agentList    = new List <IAgent>();

#if AIEnabled
        // Create q-learning object for the AI, and pick up learning where we left off
        qLearner = new QLearner(alpha: 0.3f, epsilon: 0.15f, discount: 0.66f);
        qLearner.OpenSavedData();
#endif

#if AIP1
        // Create AI for player 1
        AIAgent player1Ai = new AIAgent(1);
        player1Ai.ResourceScript = this;         // For debug rendering
        player1Ai.QLearner       = qLearner;
        player1Ai.IsLearning     = true;
        agentList.Add(player1Ai);
#else
        // Create the human agent
        agentList.Add(new WASDFAgent(1));
#endif

#if AIP2
        // Create AI for player 1
        AIAgent player2Ai = new AIAgent(2);
        player2Ai.ResourceScript = this;         // For debug rendering
        player2Ai.QLearner       = qLearner;
        player2Ai.IsLearning     = true;
        agentList.Add(player2Ai);
#else
        // Create the human agent
        agentList.Add(new ArrowsAgent(2));
#endif
    }