当前位置: 首页>>代码示例>>C#>>正文


C# Cell.IsRewardCell方法代码示例

本文整理汇总了C#中Cell.IsRewardCell方法的典型用法代码示例。如果您正苦于以下问题:C# Cell.IsRewardCell方法的具体用法?C# Cell.IsRewardCell怎么用?C# Cell.IsRewardCell使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cell的用法示例。


在下文中一共展示了Cell.IsRewardCell方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

        /// <summary>
        /// Runs a tick of the A* search
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void Run(object sender, EventArgs e)
        {
            System.Console.Out.WriteLine("Running A*; Step Count: " + stepCount++);

            while (true)
            {
                if (unvisitedCells.Count == 0)
                {
                    return;
                }

                currentCell = unvisitedCells.Last.Value;
                unvisitedCells.RemoveLast();

                if (currentCell.HasBeenSearched())
                {
                    continue;
                }

                break;
            }

            currentCell.SetHasBeenSearched(true);

            visitedCells.AddLast(currentCell);

            if (currentCell.IsRewardCell())
            {
                System.Console.Out.WriteLine("Found the reward");
                return;
            }

            // Check if cell is a neighbor of the currentCell
            // If so, set the cost and add to unvisitedCells in ProcessNeighbor()

            if (gridWorld.CanMove(Direction.UP, currentCell.GetRowIndex(), currentCell.GetColumnIndex()))
            {
                ProcessNeighbor(gridWorld.GetCells()[currentCell.GetRowIndex() - 1, currentCell.GetColumnIndex()]);
            }

            if (gridWorld.CanMove(Direction.DOWN, currentCell.GetRowIndex(), currentCell.GetColumnIndex()))
            {
                ProcessNeighbor(gridWorld.GetCells()[currentCell.GetRowIndex() + 1, currentCell.GetColumnIndex()]);
            }

            if (gridWorld.CanMove(Direction.LEFT, currentCell.GetRowIndex(), currentCell.GetColumnIndex()))
            {
                ProcessNeighbor(gridWorld.GetCells()[currentCell.GetRowIndex(), currentCell.GetColumnIndex() - 1]);
            }

            if (gridWorld.CanMove(Direction.RIGHT, currentCell.GetRowIndex(), currentCell.GetColumnIndex()))
            {
                ProcessNeighbor(gridWorld.GetCells()[currentCell.GetRowIndex(), currentCell.GetColumnIndex() + 1]);
            }
        }
开发者ID:xiaorong1176,项目名称:agent-path-planning,代码行数:60,代码来源:AStar.cs

示例2: Reward

 /// <summary>
 /// Gets the reward for a cell.
 /// </summary>
 /// <param name="cell">The cell with the reward.</param>
 /// <returns>REWARD or 0</returns>
 public int Reward(Cell cell)
 {
     if (cell.IsRewardCell())
     {
         return REWARD;
     }
     else
     {
         return 0;
     }
 }
开发者ID:xiaorong1176,项目名称:agent-path-planning,代码行数:16,代码来源:QLearning.cs


注:本文中的Cell.IsRewardCell方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。