Ejemplo n.º 1
0
        //Copied from another algorithm state
        //We reset some data, so we dont reflect values that aren't true for the new state
        //This constructor is called when a new step is being generated, so we transfer some values appropriately.
        public AlgorithmState(AlgorithmState setFrom)
        {
            cansCollected = setFrom.cansCollected;

            episodeRewards = setFrom.episodeRewards; //Reward data
            totalRewards   = setFrom.totalRewards;

            boardData = new BoardGame(setFrom.boardData); //Copy the board

            //Increase steps in here
            liveQmatrix = new Qmatrix(setFrom.liveQmatrix); //Copy the q matrix

            //The initial location will be the resulting location of the last step
            locationInitial = boardData.GetUnitSquare[UnitType.Bender];

            //Detect if we reached the limit for this episode


            if (liveQmatrix.setNumber == Qmatrix.stepLimit || setFrom.benderAttacked)
            {
                if (liveQmatrix.episodeNumber == Qmatrix.episodeLimit)
                {
                    AlgorithmManager.algorithmEnded = true;
                }
                else
                {
                    StartNewEpisode();
                }
            }
            else
            {
                liveQmatrix.setNumber++;
            }
        }
Ejemplo n.º 2
0
 public Qmatrix(Qmatrix copyFrom)
 {
     //Copy the q-matrix.
     matrixData = new Dictionary <PerceptionState, ValueSet>();
     foreach (var i in copyFrom.matrixData.Keys)
     {   //For each list of strings in copy from.matrix data
         //Get a copy of the dictionary at this list of strings
         //Should be a deep copy
         matrixData.Add(i, new ValueSet(copyFrom.matrixData[i]));
     }
     didWeUpdate   = copyFrom.didWeUpdate;
     setNumber     = copyFrom.setNumber;
     episodeNumber = copyFrom.episodeNumber;
     n             = copyFrom.n;
     y             = copyFrom.y;
     e             = copyFrom.e;
 }
Ejemplo n.º 3
0
 //Called from create empty board (after reset), and the constructor
 //Just a useful container for resetting some values when we want to start over, but making a new state would have us lose bender's position.
 public void InitializeValues()
 {
     boardData.ClearCans(); //Clear the board for our initial launch(this doesn't remove bender, just cans)
     liveQmatrix = new Qmatrix();
 }