コード例 #1
0
 public MapAgent(Map map, ISearchForActions <string, MoveToAction> search,
                 ICollection <string> goals,
                 IEnvironmentViewNotifier notifier)
     : this(map, search, goals)
 {
     this.notifier = notifier;
 }
コード例 #2
0
 public SimpleMapAgent(Map map, IEnvironmentViewNotifier notifier,
                       ISearchForActions <string, MoveToAction> search,
                       string[] goals)
     : this(map, search, goals)
 {
     this.notifier = notifier;
 }
コード例 #3
0
 public MapAgent(Map map, ISearchForActions <string, MoveToAction> search,
                 ICollection <string> goals)
 {
     this.map     = map;
     this._search = search;
     this.goals.AddAll(goals);
 }
コード例 #4
0
 public SimpleMapAgent(Map map, IEnvironmentViewNotifier notifier,
                       ISearchForActions <string, MoveToAction> search)
 {
     this.map      = map;
     this.notifier = notifier;
     this._search  = search;
 }
コード例 #5
0
 /**
  * Constructor.
  * @param map Information about the environment
  * @param search Search strategy to be used
  * @param goals List of locations to be visited
  * @param notifier Gets informed about decisions of the agent
  * @param hFnFactory Factory, mapping goals to heuristic functions. When using
  *                   informed search, the agent must be able to estimate remaining costs for
  *                   the goals he has selected.
  */
 public MapAgent(Map map,
                 ISearchForActions <string, MoveToAction> search, ICollection <string> goals,
                 IEnvironmentViewNotifier notifier,
                 Function <string, IToDoubleFunction <Node <string, MoveToAction> > > hFnFactory)
     : this(map, search, goals, notifier)
 {
     this.hFnFactory = hFnFactory;
 }
コード例 #6
0
 public SimpleMapAgent(Map map, ISearchForActions <string, MoveToAction> search, string[] goals)
     : base(goals.Length)
 {
     this.map     = map;
     this._search = search;
     this.goals   = new string[goals.Length];
     System.Array.Copy(goals, 0, this.goals, 0, goals.Length);
 }
コード例 #7
0
        public void setUp()
        {
            envChanges = TextFactory.CreateStringBuilder();

            BidirectionalSearch <string, MoveToAction> bidirectionalSearch = new BidirectionalSearch <string, MoveToAction>();

            search = new BreadthFirstSearch <string, MoveToAction>(bidirectionalSearch);
        }
コード例 #8
0
 public SimpleMapAgent(Map map, IEnvironmentViewNotifier notifier,
                       ISearchForActions <string, MoveToAction> search,
                       int maxGoalsToFormulate)
     : base(maxGoalsToFormulate)
 {
     this.map      = map;
     this.notifier = notifier;
     this._search  = search;
 }
コード例 #9
0
ファイル: SearchAgent.cs プロジェクト: tvn-cosine/aima.net
        public SearchAgent(IProblem <S, A> p, ISearchForActions <S, A> search)
        {
            ICollection <A> actions = search.findActions(p);

            actionList = CollectionFactory.CreateQueue <A>();
            if (null != actions)
            {
                actionList.AddAll(actions);
            }

            //   actionIterator = actionList.iterator();
            searchMetrics = search.getMetrics();
        }
コード例 #10
0
ファイル: LabyrinthScene.cs プロジェクト: zhenia01/PacMan
        public LabyrinthScene(ISearchProblem <S, A> problem, ISearchForActions <S, A> search, IMetrics metrics)
        {
            Utils.GameUtils.OgmoProject.LoadLevelFromFile("level.oel", this);

            var skovoroda = new Skovoroda(40 * 17, 40 * 14);
            var world     = new World(40, 40);

            Add(skovoroda);
            Add(world);

            var actions = search.FindActions(problem);

            var actionsTask = Task.Run(async() =>
            {
                foreach (A a in actions)
                {
                    var action = a as MoveAction;
                    world.X   += action.Action switch
                    {
                        MoveActionEnum.Up => 0,
                        MoveActionEnum.Down => 0,
                        MoveActionEnum.Left => - 40,
                        MoveActionEnum.Right => 40,
                        _ => 0
                    };

                    world.Y += action.Action switch
                    {
                        MoveActionEnum.Up => - 40,
                        MoveActionEnum.Down => 40,
                        MoveActionEnum.Left => 0,
                        MoveActionEnum.Right => 0,
                        _ => 0
                    };

                    await Task.Delay(20);
                }
            });

            actionsTask.ContinueWith(t => Game.SwitchScene(new MetricsScene(actions.Count(), metrics)));
        }
コード例 #11
0
 public MapAgent(Map map, ISearchForActions <string, MoveToAction> search, string goal)
 {
     this.map     = map;
     this._search = search;
     goals.Add(goal);
 }
コード例 #12
0
ファイル: SearchFactory.cs プロジェクト: bclgenki/tvn-cosine
        /**
         * Creates a search instance.
         *
         * @param strategy
         *            search strategy. See static constants.
         * @param qSearchImpl
         *            queue search implementation: e.g. {@link #TREE_SEARCH}, {@link #GRAPH_SEARCH}
         *
         */
        public ISearchForActions <S, A> createSearch <S, A>(int strategy, int qSearchImpl, IToDoubleFunction <Node <S, A> > h)
        {
            QueueSearch <S, A>       qs     = null;
            ISearchForActions <S, A> result = null;

            switch (qSearchImpl)
            {
            case TREE_SEARCH:
                qs = new TreeSearch <S, A>();
                break;

            case GRAPH_SEARCH:
                qs = new GraphSearch <S, A>();
                break;

            case GRAPH_SEARCH_RED_FRONTIER:
                qs = new GraphSearchReducedFrontier <S, A>();
                break;

            case GRAPH_SEARCH_BFS:
                qs = new GraphSearchBFS <S, A>();
                break;

            case BIDIRECTIONAL_SEARCH:
                qs = new BidirectionalSearch <S, A>();
                break;
            }
            switch (strategy)
            {
            case DF_SEARCH:
                result = new DepthFirstSearch <S, A>(qs);
                break;

            case BF_SEARCH:
                result = new BreadthFirstSearch <S, A>(qs);
                break;

            case ID_SEARCH:
                result = new IterativeDeepeningSearch <S, A>();
                break;

            case UC_SEARCH:
                result = new UniformCostSearch <S, A>(qs);
                break;

            case GBF_SEARCH:
                result = new GreedyBestFirstSearch <S, A>(qs, h);
                break;

            case ASTAR_SEARCH:
                result = new AStarSearch <S, A>(qs, h);
                break;

            case RBF_SEARCH:
                result = new RecursiveBestFirstSearch <S, A>(new AStarSearch <S, A> .EvalFunction(h));
                break;

            case RBF_AL_SEARCH:
                result = new RecursiveBestFirstSearch <S, A>(new AStarSearch <S, A> .EvalFunction(h), true);
                break;

            case HILL_SEARCH:
                result = new HillClimbingSearch <S, A>(h);
                break;
            }
            return(result);
        }