pinobatch / libbet

Libbet and the Magic Floor - a puzzle game for Game Boy
zlib License
35 stars 1 forks source link

Make the end of the demo route shorter #3

Closed pinobatch closed 6 years ago

pinobatch commented 6 years ago

The demo implemented in #2 can get boring near the end. Make it shorter.

The demo uses this map:

4 3001
3 2213
2 0103
1 3221
  abcd

The route consists of 5 segments:

1. Touch all shade 2 cells while explaining roll and hop
2. Touch all shade 2 cells again while explaining controls
3. Demonstrate leaving tracks, c1 to a3
4. Demonstrate dead ends, ending at c1
5. Demonstrate leaving more tracks and exit, ending at c4

Segment 4, a demonstration of 2 routes to the d4 dead end starts in a3 and ends in c1, gives 6 tracks, and is already as short as can be:

a4+ b4+ d4+ (c1) a1+ a2+ c2 c4+ d4

So we need an efficient segment from c1 to a3 and segment 5 from c1 to c4 that leave 12 more tracks, for a total of 18. They need a roughly equal move count.

For the moment, let's start with existing segment 3, which gives 8 tracks. One move (a1a2) overlaps segment 4, giving a total of 13 tracks.

b1 a1+ a2+ b2+ b3+ d3+ d2 c2+ c3+ a3+

Then the task becomes optimizing segment 5 for a short 5 tracks. Because of the dead end warp, there's a bias toward down tracks. Apart from c3b3, the six other remaining tracks are down: a4a2, a3a1, b4b2, b2b1, c4c3, c3c1. Anything that starts at c1, gets five of these, and ends at c4 in under the present 24 steps is an optimization.

a1 a2 c2 c4 c3+ c1+
b1 b3 a3 a4 a2+ c2 b2+ b1+
b3 a3 a4 c4

This is 18 steps and achieves 90%, skipping a4a2 and a3a1. Cutting more might require TAS-scale exhaustive search for better segments 3 and 5. optimize_demo_seg_5