Exemple #1
0
        /// <summary>
        /// 指定座標にてQ値が最大の方向を返す
        /// </summary>
        /// <returns>Q値が最大の方向</returns>
        public Maze.Direction GetMaxQDirection(Maze.CellLocate locate)
        {
            int state = Env.SerializeState(locate);

            // Q値が最大の行動からランダムに選択する
            var actList = GetMaxQDirectionList(Env.SerializeState(locate));

            return((Maze.Direction)actList[Rand.Next(actList.Count)]);
        }
Exemple #2
0
        // TODO:スタート位置を取得する
        public int GetStartState()
        {
            for (int x = 0; x < EnvMaze.Width; x++)
            {
                for (int y = 0; y < EnvMaze.Height; y++)
                {
                    if (EnvMaze.Cells[x, y].IsStart)
                    {
                        return(SerializeState(new Maze.CellLocate(x, y)));
                    }
                }
            }

            //スタート未設定の場合
            var startCell = new Maze.CellLocate(1, 1);

            EnvMaze.SetStartCell(startCell);

            return(SerializeState(startCell));
        }
Exemple #3
0
 /// <summary>
 /// 行動結果を取得する
 /// </summary>
 /// <param name="currentState">現在の状態</param>
 /// <param name="action">選択した行動</param>
 /// <param name="nextState">行動後の状態</param>
 /// <param name="reword">行動結果の報酬</param>
 public void GetMoveResult(int currentState, int action, out int nextState, out double reword)
 {
     Maze.CellLocate nextLocate = EnvMaze.Move(DeserializeState(currentState), (Maze.Direction)action);
     nextState = SerializeState(nextLocate);
     reword    = EnvMaze.Cells[nextLocate.X, nextLocate.Y].IsGoal ? GoalReword : 0;
 }
Exemple #4
0
 /// <summary>
 /// 状態(座標)をシリアル化する
 /// </summary>
 /// <param name="locate">シリアル化したい座標</param>
 /// <returns>シリアル化後の状態番号</returns>
 public int SerializeState(Maze.CellLocate locate)
 {
     return((locate.Y * EnvMaze.Width) + locate.X);
 }