top | item 39425563

(no title)

macromaniac | 2 years ago

TY. I am a fan of 7x7 with 5 stones, 8x8 I need to revisit (I haven't tried 8x8 with stones, was playing without stones for a while but they add a lot to the game).

Absolutely yes-

Funny story, originally it was generating 10kish tilings for a 6x6 board with 2 stones. but when I moved one of the stones over we would get... 0. WHAT? Apparently there is an entire field about dominoes (of course) and I had stumbled into something called the "Mutilated Chessboard Problem". It's impossible to tile a chessboard that has the top left and bottom right square removed. 62 open squares, doesn't matter, it's untilable. Crazy. Many boards are like this.

There is actually a very neat proof as to why, too. Placing a domino tile removes 1 black and 1 white square. So if you have e.g. 10 black and 12 white squares you're done for, you will always end up with the 0 black squares and 2 white squares remaining. With this intuition I was able to speed up the generator by skipping these types of boards.

As for it's implementation, it is a bit brute force, it recurses over a 64 bit bitboard to find all the possible domino tilings for a particular board, using bitwise operators for moves. I then use the 01 02 domino values and group them by the row/column numbers, so I can eliminate multiple solutions (less fun imo). There are definitely trillions of tilings, so after calculating all of them for a particular board and shuffling them only the first N are stored and then saved to a sqlite database.

discuss

order

No comments yet.