Exemple #1
0
        private void CreateAllPossibleMoves()
        {
            if (allPossible != null)
            {
                return;
            }
            var all = new List <AgentCommand>();

            Direction[] directions = new Direction[4] {
                Direction.N, Direction.E, Direction.S, Direction.W
            };
            foreach (Direction d in directions)
            {
                all.Add(AgentCommand.CreateMove(d));
                foreach (Direction d2 in directions)
                {
                    if (d == d2)
                    {
                        all.Add(AgentCommand.CreatePush(d, d2));
                    }
                    else if (d2.Opposite() == d)
                    {
                        all.Add(AgentCommand.CreatePull(d, d2));
                    }
                    else
                    {
                        all.Add(AgentCommand.CreatePull(d, d2));
                        all.Add(AgentCommand.CreatePush(d, d2));
                    }
                }
            }
            allPossible = all;
        }
Exemple #2
0
 internal static List <AgentCommand> RightHandBoxSwimming(Direction d)
 {
     return(new List <AgentCommand>()
     {
         AgentCommand.CreateMove(Opposite(d)),
         AgentCommand.CreatePull(d, Clockwise(d)),
         AgentCommand.CreatePush(Clockwise(d), Opposite(d)),
         AgentCommand.CreatePull(CounterClockwise(d), d),
         AgentCommand.CreatePush(d, Clockwise(d))
     });
 }
Exemple #3
0
        private void PushOnPath(List <Point> path, Point agentPos, List <AgentCommand> commandList, int agentIndex, int boxIndex)
        {
            for (int i = 0; i < path.Count - 1; i++)
            {
                Point currentBoxPos = path[i];
                Point nextBoxPos    = path[i + 1];

                Direction agentDir = PointsToDirection(agentPos, currentBoxPos);
                Direction boxDir   = PointsToDirection(currentBoxPos, nextBoxPos);

                commandList.Add(AgentCommand.CreatePush(agentDir, boxDir));
                agentPos = currentBoxPos;

                MoveBox(nextBoxPos, boxIndex);
                MoveAgent(currentBoxPos, agentIndex);
            }
        }