hp
toc

Complete Contact Configurations

2020-02-22, post № 225

C, games, programming, #board game, #Contact, #stochastic analysis

Contact is a board game designed by Ken Garland in which players draw square tiles containing colored connections from a pile, attempting to form matches. Whilst the game is enjoyable to play — allowing the odd trading of cards in unfortunate circumstances — it seldom leads to a complete configuration, meaning a valid contacting arrangement using all available cards.

With the power of stochastically driven brute-force, however, finding such complete configurations turns out to be feasible — at least when playing with the 𝟣𝟦𝟢 cards my Contact version contains. Not surprisingly, many solutions are of rather linear nature since the game only contains two branching cards, i. e. cards where three sides boast connections.
Thus, the search is further narrowed in by demanding a maximum dimension, that is the final configuration has to lie in a card rectangle of a given area. From my testing, a maximum dimension of 𝟧𝟢𝟢 is moderately quickly computed (~ 𝟥𝟢 sec @ 4.00 GHz), whilst lower maximum dimensions appear to be less likely.

complete-contact-configurations-00_tdg-500.png
0complete-contact-configurations-00_tdg-500.pngcomplete-contact-configurations-00_tdg-500.pngcomplete-contact-configurations-01_tdg-500.pngcomplete-contact-configurations-01_tdg-500.pngcomplete-contact-configurations-02_tdg-500.pngcomplete-contact-configurations-02_tdg-500.pngcomplete-contact-configurations-03_tdg-500.pngcomplete-contact-configurations-03_tdg-500.pngcomplete-contact-configurations-04_tdg-500.pngcomplete-contact-configurations-04_tdg-500.pngcomplete-contact-configurations-05_tdg-500.pngcomplete-contact-configurations-05_tdg-500.pngcomplete-contact-configurations-06_tdg-500.pngcomplete-contact-configurations-06_tdg-500.pngcomplete-contact-configurations-07_tdg-500.pngcomplete-contact-configurations-07_tdg-500.pngcomplete-contact-configurations-08_tdg-500.pngcomplete-contact-configurations-08_tdg-500.pngcomplete-contact-configurations-09_tdg-500.pngcomplete-contact-configurations-09_tdg-500.pngcomplete-contact-configurations-10_tdg-500.pngcomplete-contact-configurations-10_tdg-500.pngcomplete-contact-configurations-11_tdg-500.pngcomplete-contact-configurations-11_tdg-500.pngcomplete-contact-configurations-12_tdg-500.pngcomplete-contact-configurations-12_tdg-500.pngcomplete-contact-configurations-13_tdg-500.pngcomplete-contact-configurations-13_tdg-500.pngcomplete-contact-configurations-14_tdg-500.pngcomplete-contact-configurations-14_tdg-500.pngcomplete-contact-configurations-15_tdg-500.pngcomplete-contact-configurations-15_tdg-500.pngcomplete-contact-configurations-00_tdg-500.png

From an implementation point of view, a generalized Contact card (defined as four sides, each with three nodes being blank or colored one of three colors) snuggly fits into 𝟤𝟦 bits, allowing for card rotation, reflection and match determination being implemented through integer bit fiddling.
The stochastic process is driven by an (ideally assumed) uniformly distributed random number generator, being recursively applied until all cards are consumed. Finally, an image is created as a portable pixmap .ppm and resized to a .png using ImageMagick.

Source code: complete-contact-configurations.c

Jonathan Frech's blog; built 2024/04/13 20:55:09 CEST