Vlad-Shcherbina / icfpc2015-tbd

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Solver architecture (and possibly brainstorming)

Vlad-Shcherbina opened this issue · comments

This is not really a subtask, just a writeup on how I imagine subj.

There are two stages that will be completely independent for convenience.

First is high-level planning of where to lock units. Output of this stage is a sequence of requests
"I want to lock first unit here (and I don't care how it will be achieved)"
"I want to lock second unit there"
...
First stage only tries to maximized move score and does not care about power score.

Second stage is how to satisfy these requests with a sequence of concrete characters that embed lots of phrases of power.
Very naive way to do it is first arbitrarily convert requests into sequence of moves like SE, CCW, W, SW, ... What remains is how to pick individual character for each move. It could be done with dynamic programming pass, using DFA (#2). Ok, actually not really dynamic programming but close enough. Significant improvement: instead of choosing one possible sequence of moves to satisfy a request, consider them all at once (by representing them as a graph, taking cartesian product with DFA, and than using dynamic programming over resulting big transition system).
But seriously, instead of explaining I'll probably just implement it at some point.

First stage (high-level lock planning)

I don't really know how to do it. I looked at qualifier problems (and I recommend all armchair strategists to do the same: production/view_all_qualifier_problems.py). And they seem to fall into distinct classes, so the best I can think of are specialized solvers for some of these classes.

  • problems with just one monocellular unit (where pivot coincides with the cell). I'm pretty sure optimal solution or very good approximation will be easy to find.
  • problems with small tetris-style pieces (where pivots are close to piece centers). I'm thinking of beam search with skyline-based heuristic evaluation function (basically, packing things densely, not leaving holes, avoiding significant height variations).
  • problems where pivots are apart from unit bodies (which makes teleportation possible). No idea how to approach.
  • problems with chtulu-shaped pieces that are hard to pack densely. No idea.
  • problems where initial board placement requires inconventional game plan, where we need to shovel away obstacles in the middle to reach empty space below, or some caverns, or stuff like that. In such games we will probably see some moves that do not happen in tetris, like sticking the piece in a middle of the wall. No idea.

By skyline I mean this

Two random thoughts —

Generally, the longer path for every unit we pick, the better. The longer path is possible to go with upcoming pieces, the better.

These observations tangle with (1).


Someone should go ahead and implement GA. It will most likely suck, but we'll be able to see how well true algorithmical solution stands against it across quali. maps.

Proof of concept: https://github.com/Vlad-Shcherbina/icfpc2015-tbd/blob/master/production/solver.py
It uses two-phase architecture, but implements dumbest possible solvers for both phases.