コード例 #1
0
        protected override List <WorldState> ExpandOneAgent(List <WorldState> intermediateNodes, int agentIndex)
        {
            if (this.alreadyExpanded == true) // Necessary because after expansion, the generated nodes have an incremented agentTurn that once again equals agentIndex
                                              // and because it's possible that a node may have valid children that aren't already in the closed list
            {
                return(intermediateNodes);    // Do nothing to this agent
            }
            WorldStateWithOD parent = (WorldStateWithOD)intermediateNodes[0];

            if (agentIndex < parent.agentTurn)
            {
                return(intermediateNodes); // Do nothing to this agent
            }
            var generated = base.ExpandOneAgent(intermediateNodes, agentIndex);

            int childAgentTurn = ((parent.agentTurn + 1) % (this.instance.agents.Length));

            foreach (var node in generated)
            {
                WorldStateWithOD childNode = (WorldStateWithOD)node;

                childNode.agentTurn = childAgentTurn;

                // Makespan increases only if this is the move of the first agent. This makes sure that under a makespan
                // cost function, partial nodes have a correct cost and can even serve as goal nodes.
                if (parent.agentTurn != 0)
                {
                    childNode.makespan--; // Cancel the increment in base
                }
            }

            this.alreadyExpanded = true;
            return(generated);
        }
コード例 #2
0
 public WorldStateWithOD(WorldStateWithOD cpy) : base(cpy)
 {
     this.agentTurn = cpy.agentTurn;
 }