Beispiel #1
0
        /// <inheritdoc/>
        /// <summary>
        /// Stores valid actions, so that the agent can be penalized for
        /// invalid ones, in case <see cref="m_MaskActions"/> is set to false.
        /// </summary>
        public override void WriteDiscreteActionMask(IDiscreteActionMask actionMask)
        {
            m_ValidActions.Clear();
            m_ValidActions.Add(c_Stay);

            for (int action = 1; action < 5; action++)
            {
                bool isValid = m_MazeBuffer.TryRead(Maze.Wall,
                                                    m_GridPosition + m_Directions[action],
                                                    out float value) && value == 0; // no wall

                if (isValid)
                {
                    m_ValidActions.Add(action);
                }
                else if (m_MaskActions)
                {
                    actionMask.SetActionEnabled(0, action, false);
                }
            }
        }
Beispiel #2
0
 private bool HasWallAt(Vector3Int pos)
 {
     return(Buffer.TryRead(Wall, pos.x, pos.z, out float value) && value == 1);
 }