I’m trying to design a game with time travel.
In the following picture, there is a character traveling toward the right in a straight line (like a billiard ball).
If the character encounters another character, he will always turn right (as a rule).
There is also a time portal at the bottom, that will teleport you to the exit portal, 2 steps back in the past.
In this scenario, there are 2 possible trajectories for the character:
- He just goes straight as passes between the two portals. No problem.
- At the start of the simulation, another character appears in the exit portal: it’s you from the future! Both goes straight one step, meeting in the middle. Then, as per the rule on collisions, both turn right. The initial character enters the portal at step 2, thus closing the loop. The second character continues toward the left.
My question is: how to find automatically those 2 solutions?
The first is simple, I just calculate each step using the previous one together with the movement rules.
The second solution implies some knot tying, so it’s not simple.
There are many other ways to lay down the portals, leading to different number of solutions.
Any idea about an algorithm class that might help?
My initial idea was to represent the discrete positions in spacetime as a graph, and calculate the trajectories in the graph, but not sure.