ciphergoth: (Default)
[personal profile] ciphergoth
I had a lovely Christmas with [livejournal.com profile] spikeylady, [livejournal.com profile] some_fox, [livejournal.com profile] buttonmeup, [livejournal.com profile] yerbury and family.

I got given a "Tantrix" puzzle for Christmas as a stocking present. It contains 10 hexagonal tiles; you have to lay the tiles out to create a loop of one colour such that all the edges match up.

Actually solving the puzzles quickly lost my interest, so instead I wrote a program to solve them. Then I got interested in making a nice display of the results. I've now found all 2706 solutions to the 12 puzzles that form part of the set.



For those interested, the solver is in Python, and uses Cairo for drawing.

Date: 2006-12-28 04:07 pm (UTC)
From: [identity profile] marnanel.livejournal.com
you should send that to [livejournal.com profile] jwz for xscreensaver.

Date: 2006-12-28 04:48 pm (UTC)
From: [identity profile] ciphergoth.livejournal.com
Hmm, not sure

- I don't think he'd want to bring in either Python or Cairo as dependencies
- if it becomes part of a package like xscreensaver the puzzle makers might mind on copyright grounds
- it's not all that animated

but thanks - I'm glad it looks the part :-)

Date: 2006-12-28 04:13 pm (UTC)
From: [identity profile] fuschiafaery.livejournal.com
Sounds like a very techie way of puzzle solving, I think you got a tad further than most of us would have done :-)

Date: 2006-12-28 04:21 pm (UTC)
From: [identity profile] ciphergoth.livejournal.com
I realized in the end that I quickly get bored of trying to solve these things by hand, but I enjoy writing programs to solve things!

Date: 2006-12-28 05:29 pm (UTC)
From: [identity profile] wechsler.livejournal.com
ISTR [livejournal.com profile] darkpoint got bored of Sudoku and also wrote a solver instead.

Date: 2006-12-28 07:48 pm (UTC)
djm4: (Default)
From: [personal profile] djm4
Yes, so did my sister.

Date: 2007-01-02 04:12 pm (UTC)
From: [identity profile] drdoug.livejournal.com
And me!

Date: 2006-12-29 08:24 am (UTC)
From: [identity profile] ciphergoth.livejournal.com
Funnily enough, I got another puzzle for which I started on a Prolog solver having had great success using it to solve a similar puzzle many years ago, but [livejournal.com profile] some_fox solved the puzzle by hand before I was barely started, and it sort of took the wind out of my sails...

Date: 2006-12-28 04:15 pm (UTC)
From: [identity profile] valkyriekaren.livejournal.com
Heh. Must have been the season for it - [livejournal.com profile] d_floorlandmine got a Tantrix too.

Date: 2006-12-28 07:05 pm (UTC)
zz: (Default)
From: [personal profile] zz
i wish i were a creative enough programmer to know how to think about such things in computer-solvable terms. :|

Date: 2006-12-28 07:40 pm (UTC)
From: [identity profile] ciphergoth.livejournal.com
It's not a very creative solver - pick a tile, then pick a tile (and orientation) to go next, check that all the edges match properly and there's no tile already there where you want to place one, carry on until you close the loop or you don't have enough tiles left to get back to the start, then backtrack. The solution space is sufficently small for this to work, though you have to leave it overnight to get all the solutions.

Date: 2006-12-28 07:19 pm (UTC)
From: [identity profile] vulture23.livejournal.com
Of course, my first thought was "Ooh, I'd like to see the code for that..." :)

Date: 2006-12-28 07:49 pm (UTC)

Date: 2006-12-28 11:23 pm (UTC)
henry_the_cow: (Default)
From: [personal profile] henry_the_cow
Is the body of __sub__ supposed to contain + signs? If not, I presume this doesn't affect the result, on the "it seems to work" principle.

We got one of these puzzles last year and I had great fun solving it, by hand. Maybe I should learn Python (not that I have any time to code these days).


Date: 2006-12-29 02:22 am (UTC)
From: [identity profile] ciphergoth.livejournal.com
eek!

It's likely that it hasn't found all the possible solutions then, since that bug will break the distance-based cutoff critereon.

Thanks for spotting it!

Date: 2006-12-29 10:17 pm (UTC)
henry_the_cow: (Default)
From: [personal profile] henry_the_cow
You know, this notion of open-source review just *might* catch on...

Date: 2006-12-30 10:51 am (UTC)
From: [identity profile] ciphergoth.livejournal.com
fixed version (with many other things fixed too - eg transformations make the drawing code much simpler). Let me know if you spot anything else - thanks!

Date: 2006-12-29 11:47 am (UTC)
From: [identity profile] ciphergoth.livejournal.com
It turns out that the distance-based cutoff was completely broken anyway, so all solutions were found. However, fixing it has made the solver faster. I have also replaced functional composition with matrix composition for composing transforms, which is also faster.

Date: 2006-12-28 07:51 pm (UTC)
From: [identity profile] bileandvitriol.livejournal.com
Did you ever do that puzzle that Matt Selby's brother Alex solved?

Date: 2006-12-28 10:02 pm (UTC)
From: [identity profile] ciphergoth.livejournal.com
I only recently found out about that - neat or what?

Date: 2006-12-28 10:09 pm (UTC)
barakta: (Default)
From: [personal profile] barakta
My dad got into Googlewhacking and our response was 'why don't you code up a solver' as he did used to be a programmer. Scarily he seems to enjoy the process of manually solving them, almost iterating the program himself. He's had Tantrixes and other computer solvable games as presents for years and plays with them for weeks noting his results on backs of envelopes before getting bored of them. They do sudoku as well.

Then again this is a man who deliberately signs up (or at least doesn't avoid it) for spam, sets it to come in to an old email address in Outlook Express and then sorts it manually by hand and gets all fascinated by the categories.

Date: 2006-12-29 11:22 am (UTC)
From: [identity profile] purplerabbits.livejournal.com
You know, the moment I saw that puzzle in one of Jess's pictures I *knew* you'd do that!

Tantrix

Date: 2006-12-30 09:30 pm (UTC)
From: [identity profile] thekumquat.livejournal.com
Tchah - they had that in the castle we were in this week and I'd got all of them up to 9, but not the 10 one!

Just a minute - your pic there doesn't have a 4th colour which appears on the last 3 tiles - are you sure you've replicated the puzzle accurately?

Re: Tantrix

Date: 2006-12-31 12:57 am (UTC)
From: [identity profile] ciphergoth.livejournal.com
yes, my puzzle only has three colours on all the tiles. I've constructed the answers with the real tiles so I'm pretty sure I have them right - down to which colours occlude which on each tile :-)

But I could extend it to do the other puzzles... :-)

Date: 2007-01-02 04:14 pm (UTC)
From: [identity profile] drdoug.livejournal.com
I like your brains.

Date: 2007-01-12 05:56 pm (UTC)
From: [identity profile] ciphergoth.livejournal.com
Thanks :-) Spicy or non-spicy?

Date: 2007-01-12 09:38 pm (UTC)
From: [identity profile] drdoug.livejournal.com
Spicy brains smell best!

Profile

ciphergoth: (Default)
Paul Crowley

January 2025

S M T W T F S
   1234
5678 91011
12131415161718
19202122232425
262728293031 

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 27th, 2026 11:42 am
Powered by Dreamwidth Studios