Mora Jai Solver

Made with: Unity, C# for PC

Solo project

For fun

August 2025

Functionality

To explain how this program works, I first need to explain how a Mora Jai puzzle box from the game Blue Prince works. A box has a 3x3 grid of colored tiles (buttons), and another 4 buttons, one in each of the corners. The corner tiles needs to match the color of the buttons in their corresponding color (it’s actually a symbol, but each symbol has a corresponding color). Each tile color does something else when pressed:

  • Grey: Does nothing

  • Black: Each tile in the row moves one to the right (right-most tile goes back to the left)

  • Green: Swaps with the tile on the opposite side of the box

  • Pink: Rotates all horizontally and diagonally adjacent tiles clockwise

  • Yellow: Swaps place with the tile above, does nothing on top row

  • Violet: Swaps place with the tile below, does nothing on bottom row

  • White: Itself and all horizontally adjecent white tiles become grey, and all horizontally adjecent grey tiles become white

  • Red: Each white tile becomes black and each black tile becomes red

  • Orange: If the majority of horizontally adjecent tiles share a color, become that color

  • Blue: Has the same effect as the center tile (but use it’s own position), has no effect if center tile is blue

Taking this into account, my program will solve the puzzle in the least amount of possible moves every single time.

To setup, you can click on any tile to set it’s color, and then hit either Solve if you want to program to solve it, or Play if you want to play it yourself. Reset sets the board back to your last used board.

In the settings menu, you can:

  • Change how many states the program will handle per frame (higher number is faster, but will make it so it hangs on frames more, which causes less UI updates and forces reset to wait until the frame is finished;

  • Toggle if you want to solve the puzzle yourself with the solution you got from hitting solve immediately after it’s done solving.

Technical Overview

After hitting solve, the program will try and solve the puzzle. It does this by simulating clicking the first tile, then if that creates a new board that hasnt been created before, it puts that board state into a queue. It then simulates the second tile, etc. After all 9 tiles have been clicked, it does the same thing for all new states in the queue, until it finds the correct solution (meaning all 4 corner tiles are their desired color). This will find the solution in the least amount of clicks possible, because it will never try an option that costs say 4 clicks, before it has tried every possible option that costs 3 clicks.

After handling each click, it saves that state key, the input that it took to get there and the key of the previous state as a struct to a dictionary. When it finds the solution, it uses that key to find the previous entry, then uses that key, until its back to the beginning board state and has retrieved all the inputs needed.

Previous
Previous

ReLion Us!