Some newer thoughts.
This time it's not just about altitudes(= flipper angles) but about ways we can collide the flipper with the ball.
1)
If necessary, advance so far that it takes no more than 10 frames for the ball to be in reach of a flipper.
Now, determine all possibilities for a first collision:
- Dumb brute force: For that flipper, try all of the 10 inputs (mentioned in a previous post) after
delaying for 0 to 3 frames and try appending "let go" and "hold" frames.
- Maybe better way: Narrow down on the inputs we want to test based on the ball's trajectory relative to the flipper.
For each result, try an additional "let go" or "hold" frame to determine
if there is a collision on the next frame, too. (2 consecutive collisions)
- If the ball is above the flipper, try an additional "hold" frame.
- If the ball is below the flipper, try an additional "let go" frame.
2)
For any scenario fetched in 1), if the ball is going to be in reach of the other flipper in the next 10 or so frames,
then adjust the other flipper's altitude (try all 10 inputs - or as many as we can fit in before the ball collides).
For each resulting scenario, check identifying information from a text file and if it already exists, discard it.
If it doesn't exist yet, save the new scenario:
- Save state
- Save identifying information in the text file (framecount, ball's position and speed, flipper altitudes)
3)
Delete savestate used in 1).
4)
For all new scenarios saved in 2), repeat with 1)
When the ball first reaches the left flipper at the very start of the game, I found 16 possible first collisions via trial-and-error.
Some of them have the possibility of another collision on the next frame, yielding more scenarios.
For half of those scenarios where the ball isn't going to be in reach of the right flipper, repeat with 1) directly.
For half of those scenarios where the ball is going to be in reach of the right flipper, adjust beforehand the other flipper's altitude to any of the 10 possible altitudes and save each resulting scenario, then repeat with 1).
----------
Edit:
The above procedure, as far as I can tell, is accurate but takes quite some time.
Maybe it is possible to reduce computation time by simply hex-editing the flipper altitude right before collision based on the last time that flipper collided and the altitude it had at that time.
For example:
- Flipper A hits the ball at frame 1000. It was a let go frame and its altitude was 0x200002.
- Flipper B bounces the ball back so it is in reach of flipper A again at frame 1003.
- Find all possible altitudes that can be reached in 2 frames from 0x200002 and then add a "Let go" or a "Hold" frame
for the frame the collision happens.
I'm not sure if this is error prone but certainly worth considering.
----------
Edit:
It might also be an idea to determine all run-throughs of a room using hex-editing
without calculating if it is possible.
And then verify all those run-throughs afterwards until we find one that is legitimate.