Auto Play: column and bottom-row targeting - #34
Merged
Merged
Conversation
On a portrait phone a full wave has almost no room to march: it bounces, and steps down, about once a second. The autopilot shot whichever column was nearest, which leaves the wave's width untouched until the end, so from level 5 up the wave reached the ship before it could be cleared. Nearly every life lost was a collision with an invader, not a bomb. pickAlienTarget() now chooses the column: - nearest column while the wave is no threat (unchanged behaviour, and the fastest clear on wide screens); - an edge column when the wave would reach the ship before it can be cleared: a narrower wave crosses more screen per step down. The edge column with fewer aliens left goes first, the nearer one on a tie; - the bottom row when it is about to come level with the ship, where it can no longer be shot. This also outranks the saucer. The aim point is now computed on the bottom-most alien of a column, the only one a laser can reach. At level 10 the escort is shot before the mothership: she takes 16 hits, and her escort was marching into the ship in the meantime. Portrait 1080x2400, 500 seeded runs per level, host build of game.cpp: levels cleared 64% -> 98%, full campaigns won 24% -> 96%.
Two sources of dead time found while measuring the targeting change: - The autopilot steered under a power-up the moment it dropped and parked there, not firing, for the two to three seconds of its fall. It now leaves for the pickup only when it is about to land. - It fired only when lined up on its chosen target. It now also fires at any column that is overhead on the way there or during a dodge. Portrait 1080x2400, 500 seeded runs per level: levels 8 and 9 cleared 97% / 84% -> 99% / 93%, full campaigns won 96% -> 99%, and a campaign takes 129 s instead of 143 s. Wide screens clear 8 to 20% faster. README: describe the autopilot's column choice, test count 103 -> 114.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The follow-up left open in #13: which column the autopilot shoots. Measuring first turned up something bigger than expected — on a portrait phone the autopilot lost three campaigns in four, and not to bombs.
What was wrong
A host build of
game.cppplayed 500 seeded runs per level with the autopilot on, and logged the second before every life lost.What changed
Commit 1 — targeting.
pickAlienTarget()chooses the column:The aim point is now computed on the bottom-most alien of a column, the only one a laser can reach.
Commit 2 — dead time. Found in the traces while measuring commit 1, kept separate so it can be dropped:
Results
300 seeded runs per level and 300 campaigns per row. "Clear time" is the sum of the ten per-level mean clear times.
The old portrait clear time is lower only because it counts cleared levels, and the old AI cleared the easy ones.
Things measured and rejected:
Trade-off to know
Commit 2 makes levels end sooner, so fewer saucers cross: the mean campaign score on portrait is 45.0k against 45.6k with commit 1 alone.
Verification
TakesTheNearestColumnWhenTheWaveIsNoThreatpasses on both and guards against over-applying the edge rule.AutoPlay.HoldsThePortraitLineAtLevel6plays eight full portrait waves end to end. The old AI loses three of the eight.AutoPlay.SteersTowardACollectiblePowerUpnow drops its power-up closer to the ship, since a high one is no longer chased at once.assembleDebugandassembleReleasebuild clean. NDK clang-tidy reports nothing ingame.cpp.Not changed