Overall Editorial by arr28

First 4-hour AHC

This was my first 4-hour heuristic competition and coding time was considerably the limiting factor. After 4 hours I was in 448th on the leaderboard. Continuing after the competition ended, I improved that to 247th on the extended leaderboard.

Summary Score
Just “Move” 167612
Optimal Slide & Move 204033
Put a single block at (1,9) or (1,10), if not a target, when directly above 205101
Try all possible (non-target) locations for a single block, use A* for moves 208063
Try all possible (non-target) locations for a single block when first adjacent 208358
Put a block after move X, in all possible directions, with increasing X 208443
Try up to 4 blocks, placed after moves W, X, Y & Z - repeat until out of time 211101
Up to 6 blocks 211638
Up to 10 blocks 212124
Low-level performance optimizations (same basic algorithm) 213031
Run with Cython 213064
Place 7-14 blocks (and fix a bug which incorrectly bunched the blocks) 214119

The final solution first calculated a fallback solution, which was the optimal possible solution using only “Move” and “Slide” actions.

The bulk of the 2s time limit was spent trying with blocks in a variety of locations. Each trial started by pre-selecting a random set of 7-14 move indexes & directions. The move indexes were limited to the first quarter of the length of the current best solution.

Then it set about moving from target to target, using A* to find the fastest route between the two. After making the relevant number of moves, it would place a block in the specified direction, provided that the block wasn’t out of bounds. (Each time a block was placed, pre-calculation of data for the A* heuristic and “Slide” distances were calculated to increase simulation speed.)

The best solution was submitted when the 2s time limit was near. Running with Cython allowed approximately 230 trials in the time limit. CPython only managed ~180 trials. However, the difference in overall score from switching to Cython was negligible.

posted:
last update: