Example #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.m_vAgents.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
                if (parent.agentTurn != 0)
                {
                    childNode.makespan--; // Cancel the increment in base
                }
            }

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