Threaded Freecell

GNOME’s Freecell implementation has a very good hint engine. The problem
is that it has had to be limited so it returns a hint in a reasonable time
after the hint button is clicked. I’ve just changed it so that a separate
thread starts calculating a good hint the moment the board is changed. So
now the limit is how much calculation we can do while the user decides
whether to ask for a hint rather than how short a time looks like “instant”.
Not that
you can notice the difference on a modern machine – but it appeals to the
hacker in me.

The really unusual thing is that it worked first time – no dead-locks
or other bugs.
I had to check quite carefully that the thread was actually being run.


Posted

in

by

Tags: