コード例 #1
0
        public void EnvSet(float ep, string strategy, float NPE)
        {
            epsilon      = ep;
            NOMS_PER_ENV = NPE;

            nomGrid = new NomGrid();
            nomGrid.initGrid(NOMS_PER_ENV);

            agent = new Agent(strategy);
            agent.initPos();
        }
コード例 #2
0
 private void eat(byte state, NomGrid nomGrid)
 {
     if (state >= 162)
     {
         Debug.LogError("Grid cell state error");
     }
     if (state >= 81)
     {
         nomGrid.eatMe(posRow, posCol);
         fitness += 500;
     }
     else
     {
         fitness -= 1;
     }
 }
コード例 #3
0
    public void action(byte state, NomGrid nomGrid, float epsilon)
    {
        //Stochastic process to encourage exploration and test robustness
        //Epsilon starts at 0.01
        Random rnd = new Random();
        float  r   = (float)rnd.NextDouble();

        if (r < epsilon)
        {
            MoveRandom(state);
            return;
        }

        int    i = state;
        string j = strategy;

        switch (Convert.ToByte(strategy[state]) - 48)
        {
        case 1:
            eat(state, nomGrid);
            break;

        case 2:
            MoveUp(state);
            break;

        case 3:
            MoveRight(state);
            break;

        case 4:
            MoveDown(state);
            break;

        case 5:
            MoveLeft(state);
            break;

        case 6:
            //Do nothing
            //Ideally natural selection should eliminate this gene variation
            //fitness--;
            break;
        }
    }
コード例 #4
0
 public void EnvReset()
 {
     nomGrid = null;
     agent   = null;
 }