public override Action Clone()
        {
            var clone = new PullAction(Agent, AgentDirection, BoxDirection);

            clone.AgentNextPosition = AgentNextPosition;
            clone.BoxNextPosition   = BoxNextPosition;
            clone.BoxPrevPosition   = BoxPrevPosition;
            return(clone);
        }
コード例 #2
0
        /// <summary>
        /// Creates dictionary, where key is the agent and value is every viable move (excluding collisions which are checked later)
        /// </summary>
        public static List <List <Action> > GenerateAllPossibleActions(List <Agent> agents)
        {
            var allPossibleActions = new List <List <Action> >();

            foreach (var agent in agents)
            {
                var agentPossibleActions = new List <Action>();

                // TODO: Uncomment when working on multi agent solution
                // agentPossibleActions.Add(new NoOpAction(agent));

                foreach (var agentDirection in AllDirections)
                {
                    agentPossibleActions.Add(new MoveAction(agent, agentDirection));

                    foreach (var boxDirection in AllDirections)
                    {
                        var pushAction = new PushAction(agent, agentDirection, boxDirection);
                        if (pushAction.AreDirectionsValid())
                        {
                            agentPossibleActions.Add(pushAction);
                        }

                        var pullAction = new PullAction(agent, agentDirection, boxDirection);
                        if (pullAction.AreDirectionsValid())
                        {
                            agentPossibleActions.Add(pullAction);
                        }
                    }
                }

                allPossibleActions.Add(agentPossibleActions);
            }

            return(CartesianProduct <Action>(allPossibleActions));
        }