Beispiel #1
0
        /// <inheritdoc/>
        public override void Initialize()
        {
            m_IsTraining   = Academy.Instance.IsCommunicatorOn;
            m_ValidActions = new List <int>(5);

            m_Directions = new Vector2Int[]
            {
                Vector2Int.zero,
                Vector2Int.up,
                Vector2Int.down,
                Vector2Int.left,
                Vector2Int.right
            };

            int length = m_LookDistance * 2 + 1;

            // The ColorGridBuffer supports PNG compression.
            m_SensorBuffer = new ColorGridBuffer(Maze.NumChannels, length, length);

            var sensorComp = GetComponent <GridSensorComponent>();

            sensorComp.GridBuffer = m_SensorBuffer;
            // Labels for sensor debugging.
            sensorComp.ChannelLabels = new List <ChannelLabel>()
            {
                new ChannelLabel("Wall", new Color32(0, 128, 255, 255)),
                new ChannelLabel("Food", new Color32(64, 255, 64, 255)),
                new ChannelLabel("Visited", new Color32(255, 64, 64, 255)),
            };
        }
Beispiel #2
0
 /// <summary>
 /// Invoked by <see cref="Controller"/> after it randomized the <see cref="Maze"/>.
 /// </summary>
 /// <param name="buffer">The <see cref="Maze"/>'s <see cref="GridBuffer"/></param>
 /// <param name="spawnPos">The agents spawn position on the grid</param>
 public void StartEpisode(GridBuffer buffer, Vector2Int spawnPos)
 {
     m_MazeBuffer ??= buffer;
     m_GridPosition          = spawnPos;
     m_LocalPosNext          = new Vector3(spawnPos.x, 0, spawnPos.y);
     transform.localPosition = m_LocalPosNext;
 }