Beispiel #1
0
        //----------------------------------------------------------------------------------------------------------------------
        void ParseObervations()
        {
            int    numberObservations = worldState.observations.Count;
            string msg = worldState.observations[numberObservations - 1].text;

            observations = JsonConvert.DeserializeObject <JsonObservations>(msg);
        }
        void ObservationsToCommands(JsonObservations observations)
        {
            xPos = observations.XPos;
            zPos = observations.ZPos;
            try
            {
                UpdateTilesInfo(observations);
            }
            catch (IndexOutOfRangeException e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
                return;
            }

            /*
             * System.Diagnostics.Debug.WriteLine("Far ahead: " + neighbourTiles.Level0.farAhead +
             *  ". Ahead: " + neighbourTiles.Level0.ahead +
             *  ". Far left: " + neighbourTiles.Level0.farLeft +
             *  ". Left: " + neighbourTiles.Level0.left +
             *  ". Right: " + neighbourTiles.Level0.right +
             *  ". Far right: " + neighbourTiles.Level0.farRight +
             *  ". Back: " + neighbourTiles.Level0.back +
             *  ". Far back: " + neighbourTiles.Level0.farBack);*/
            if (IsGoalMet())
            {
                return;
            }
            ObservationsToBrainInputs();
            brain.Activate();
            OutputsToCommands();
        }
Beispiel #3
0
 void UpdateTilesInfo(JsonObservations observations)
 {
     try {
         neighbourTiles.SetTileIndicesGivenObs(observations);
     }
     catch (IndexOutOfRangeException e)
     {
         System.Diagnostics.Debug.WriteLine(e.Message);
         throw;
     }
 }
Beispiel #4
0
 bool AnyLavaInNeighbourTiles(JsonObservations observations)
 {
     foreach (string tile in observations.levelSub1)
     {
         if (tile == "lava")
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #5
0
 void ObservationsToBrainInputs(JsonObservations observations)
 {
     if (AnyLavaInNeighbourTiles(observations))
     {
         brain.InputSignalArray[0] = 1;
     }
     else
     {
         brain.InputSignalArray[0] = 0;
     }
 }
Beispiel #6
0
 void ObservationsToCommands(JsonObservations observations)
 {
     try {
         UpdateTilesInfo(observations);
     }
     catch (IndexOutOfRangeException e)
     {
         System.Diagnostics.Debug.WriteLine(e.Message);
         return;
     }
     ObservationsToBrainInputs();
     brain.Activate();
     OutputsToCommands();
 }
Beispiel #7
0
 void ObservationsToCommands(JsonObservations observations)
 {
     ObservationsToBrainInputs(observations);
     brain.Activate();
     OutputsToCommands();
 }