# Core Mechanics of CHetauGet

So, I think this animation shows the core mechanic of the CHetauGet pretty clearly. And also, I’d like to post a more complex level here.

The most challenging part is not implement this mechanic, as you can see, the board, the movements, the vanish logic, the judgement of endgame, and the judgement of stuck are all simple enough. The most challenging is to generate a SOLVABLE game.

Of course I could test every level manually, but I think a game like this should certainly has hundreds of level  to play. Testing every level would cost me a lot of time. So I made a level generator, that is the most challenging part about this mechanic.

Before starting to build the generator, I need a Level Solvability Judger to test if a level is solvable, I call this judger Line Walker. I’m gonna use this level to explain how Line Walker works.

The image above is the example level, the the image below is a abstract of the very same level.

Every pair of star and square can be regarded as a line. The thinner lines could be paired without any preconditions, while the thicker ones can only be paired after their Pre-Node’s pairing. The relation between these lines is like the figure below.

To solve this level, there’re 8 nodes that need to be solved. And the nodes that have to be solved in a certain sequence form a chain ( such as the 1-4-2 chain ) or a tree ( such as the 7,8-6 tree ). The black rhombuses means the current tree is at an end. The main idea of Line Walker is that only when there’s no closed loops in the tree figure the game is solvable.

So, what Line Walker does is to figure out the tree of the game and find closed loops to judge if the game is solvable.

Once I had the Line Walker, I started to build the level generator. Because I need only hundreds of levels, not millions, the efficiency of the generator is not my concern. So here’s my idea: start with an empty board, and choose a grid randomly to place a square, then choose another grid that is either in the same row or the same colume for the star, now I’ve got the first pair, I test the board using Line Walker, if it’s solvable, then go on place another pair and test the board again, and again until more than 80% of the board is filled ( 100% is not easily achieved ). The level is generated.