Exemplo n.º 1
0
        // Done!
        #region .Ctor

        public IDAStar(T start, T goal, AgentCharacter agentCharacter)
        {
            this.start          = new CognitiveState <T>(start, agentCharacter);
            this.goal           = new CognitiveState <T>(goal, agentCharacter);
            this.agentCharacter = agentCharacter;

            // Vamos definir um nivel de corte!
            cutOff = (int)Math.Ceiling(start.GetHeuristic(start, goal));
        }
Exemplo n.º 2
0
Arquivo: MapNode.cs Projeto: r3db/Vlcr
        // Done!
        public float GetCost(MapNode destination, AgentCharacter ac)
        {
            var c = destination.Exits[0].Constraints;

            const float factor = 4.0f;

            var d  = GetCost(destination);
            var m  = (c.Memory.Value * ac.Memory * d / factor);                                                     // Apply Time!
            var t  = (r.NextDouble() * ac.Temperamental * d / factor);                                              // Apply Time!
            var e  = -(Math.Abs(c.Memory.Value) * ac.Explore * d / (2 * (c.Memory.Value > 0 ? 2 : 1.3)));           // Apply Time!
            var g  = (c.Speed.Value * ac.Greedy * d / factor);                                                      // Apply Time!
            var p  = ((1 - c.Transitable.Value) * ac.Bold * d / factor);                                            // Apply Time!
            var nd = d - m - t - e - p - g;

            return((float)nd);
        }
Exemplo n.º 3
0
Arquivo: MapNode.cs Projeto: r3db/Vlcr
        // Done!
        #region ICognitiveLayout<MapNode> Members

        // Done!
        public IList <MapNode> Children(AgentCharacter ac)
        {
            if (this.NodeType == NodeType.Exit)
            {
                return(this.Exits[0].Children());
            }

            IList <MapNode> data = new List <MapNode>();

            for (int i = 0; i < this.Exits.Count; ++i)
            {
                //var x = this.Character.Bold*this.Exits[i].Exits[0].Passable;
                data.Add(this.Exits[i]);
            }
            return(data);
        }
Exemplo n.º 4
0
        // Done!
        public static void FilterAdd <T>(this PriorityQueue <CognitiveState <T> > list, IDictionary <int, CognitiveState <T> > other, CognitiveState <T> node, CognitiveState <T> goal, AgentCharacter agentCharacter) where T : class, ICognitiveLayout <T>
        {
            // Expandir o estado actual!
            IList <T> childreen = node.Children(node, agentCharacter);

            int count = childreen.Count;

            for (int i = 0; i < count; ++i)
            {
                T c = childreen[i];
                // Adicionar à lista somente se não existir na lista de fechados.
                if (other.ContainsKey(c.GetHashCode()))
                {
                    continue;
                }

                CognitiveState <T> s = new CognitiveState <T>(c, node, agentCharacter);
                list.Enqueue(s.Cost + CognitiveState <T> .Estimate(node, c, goal), s);
            }
        }
Exemplo n.º 5
0
        // Done!
        #region .Ctor

        public CognitiveAStar(T start, T goal, AgentCharacter agentCharacter)
        {
            this.start          = new CognitiveState <T>(start, agentCharacter);
            this.goal           = new CognitiveState <T>(goal, agentCharacter);
            this.agentCharacter = agentCharacter;
        }
Exemplo n.º 6
0
 public IList <T> Children(CognitiveState <T> node, AgentCharacter ac)
 {
     return(Layout.Children(ac));
 }
Exemplo n.º 7
0
 // State without a parent
 public CognitiveState(T layout, AgentCharacter agentCharacter)
     : this(layout, null, agentCharacter)
 {
 }
Exemplo n.º 8
0
        }                                                           // Custo Real

        #endregion

        // Done!
        #region .Ctor

        // Normal and most used ctor
        public CognitiveState(T layout, CognitiveState <T> parent, AgentCharacter agentCharacter)
        {
            Parent = parent;
            Layout = layout;
            Cost   = parent == null ? 0 : parent.Cost + parent.Layout.GetCost(layout, agentCharacter);
        }