This is the 2nd episode of the game

In this episode, you are allowed to rotate a single tile directly ahead of the active path to maximize your score.
You may want to solve Episode 1 first. (TODO: add link to Episode 1 after release)

  Rules

The game is played on a hexagonal grid with pre-placed tiles and a predefined starting location. Each tile has 12 entrances numbered 0-11, forming 6 distinct path segments — each entrance is used exactly once. A single path segment is represented by two integers: entranceA and entranceB.

Example of a single tile with numbered entrances.

Gameplay:

  • The path starts on the base tile at position [0, 0], at entrance 7.
  • Each turn, the player may rotate the tile directly ahead by 0-5 counter-clockwise steps.
  • After the rotation, the player follows the connected path.
  • The path continues until it reaches a not-visited cell, a board edge, or returns to the base tile.
  • The game ends when the path reaches the edge of the board or returns to the base tile.

Scoring:

Each turn consists of marking the tile as visited and following the resulting path. For every segment traversed during that turn, the player earns incremental points:

  • If the path passes through 1 segment this turn, the score increases by 1
  • If the path passes through 2 segments this turn, the score increases by 3 (1+2)
  • If the path passes through 3 segments this turn, the score increases by 6 (1+2+3)
  • If the path passes through 4 segments this turn, the score increases by 10 (1+2+3+4)
  • If the path passes through 5 segments this turn, the score increases by 15 (1+2+3+4+5)
  • and so on...

Coordinate system:

The board has a fixed size: all cells are located at most 3 units away from the center. You will receive the initial configuration of each tile, including its position ([x, y]). Below is the coordinate system used in this puzzle:

Coordinate system:
y increases towards the south
x increases towards the north-east

Your task:

Before each turn, you can rotate the tile directly ahead of the current path. You will also be given maximum allowed tile rotations for the game. Your objective is to achieve the highest possible score for each given board configuration. Good luck!

  Additional Info

- Click the gear icon in the viewer to access display options.
- This puzzle is inspired by the logic game Entanglement.
- Source code available on GitHub.
- Design available on Figma.

  Game Input / Output

Initial input

Line 1: A single integer required_score - the minimal required score (always the best achievable).

Line 2: A single integer max_rotations - maximum allowed tile rotations per game.

Line 3: A single integer n - the number of tiles (always 36).

Next n lines: 14 space-separated integers: x, y and 6 pairs entranceA, entranceB describing each tile’s configuration.

Example:
-1 -2 0 6 1 9 2 7 3 4 5 10 8 11 defines a tile located at [-1, -2] with the same structure as in the Rules section.

Turn input

Line 1: Two space-separated integers x, y - marking the position of a tile that can be rotated (always the one directly ahead of current path).

Turn output

Single line: A single integer ccw_rotations - the number of counter-clockwise rotations to apply (0-5) to the tile at [x, y].

Note: ccw_rotations = 0 is not counted as a rotation. Other values (1-5) are counted as single rotation. Do not make more than max_rotations rotations!

Constraints
0 ≤ max_rotations ≤ 5
Response time for the first turn: ≤ 10s
Response time for subsequent turns: ≤ 50ms