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; }
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)) }); }
private void PullOnPath(List <Point> path, List <AgentCommand> commandList, int agentIndex, int boxIndex) { for (int i = 0; i < path.Count - 2; i++) { Point currentBoxPos = path[i]; Point nextBoxPos = path[i + 1]; Point agentPos = path[i + 1]; Point nextAgentPos = path[i + 2]; Direction agentDir = PointsToDirection(agentPos, nextAgentPos); Direction boxDir = PointsToDirection(nextBoxPos, currentBoxPos); commandList.Add(AgentCommand.CreatePull(agentDir, boxDir)); MoveAgent(nextAgentPos, agentIndex); MoveBox(nextBoxPos, boxIndex); } }