Solving Sokobond

Another solver that I’ve been working on, after A Good Snowman Is Hard To … Solve?. This time, we have Sokobond! It’s a Sokobon… but with chemical bonds! Yeah, that’s a really good title.

The basic idea is you have a field of elements with (chemical accurate) free electrons):

A basic level

Here we have 4 hydrogens (1 bond each) and a carbon (4 bonds). It should seem pretty obvious that the carbon should end up with a hydrogen on each end. The one last bit of interest: the element with the dashed border is the one we actually control, that will never change.

This eventually gets more complicated, adding:

  • Modifiers that are placed on the map between squares:
    • One that strengthens bonds, turning a single bond into double into triple
    • One that weakens bonds, turning triple to double to single or breaking single bonds
    • One that rotates bonds as you move by it
  • More elements, eventually hydrogen (1), oxygen (2), nitrogen (3), carbon (4), and helium (0)
  • Solutions that require forming multiple elements at the same time

It’s a pretty neat puzzle game with 144 levels of increasing difficulty. Perfect to solve.


read more...


A Good Snowman Is Hard To ... Solve?

I enjoy puzzle games. I especially enjoy letting computers solve them for me 😄. Once upon a time, I set up a framework for solving random things. Let’s solve some more.

Today: A Good Snowman Is Hard To Build

It’s a Sokoban about making snowmen! You can push snowballs of three sizes around, collecting snow if you roll over it. You can push smaller snowballs onto bigger ones, stacking them. Or back off, in order to get around one another.

And that’s really it.

There are some interesting twists (multiple snowmen, the ability to leave and re-enter levels, and even a whole second ‘hard mode’), but at a basic level, it’s just pushing.

read more...


Stateful Solvers and Iterators

Rust, yet again! Let’s take what we did last time with Solving Sudoku (again) and improve the code structure a bit more.

Goals:

  • Create a ‘Solver’ struct that can maintain state (such as how many states we’ve visited, how much time we’ve spent)
  • Track the above stats
  • Turn the ‘Solver’ into an iterator which will iterate through given solutions (a single call will give the first solution or you can run through the iterator to get all of them)

If you’d like to follow along, I’ve started uploading the code here: https://github.com/jpverkamp/rust-solvers

read more...


Solving Snakebird

Snakebird!

A cute little puzzle game, where you move around snake(birds). Move any number of snakes around the level, eating fruit, and getting to the exit. The main gotchas are that you have gravity to content with–your snake will easily fall off the edge of the world–and each time you eat a fruit, your snake gets bigger. This can help get longer to get into hard to reach places or it can cause trouble when you trap yourself in corners.

Let’s use the new immutable.js solver to solve these problems!

read more...


Immutable.js Solvers

A bit ago I wrote about writing a generic brute force solver (wow, was that really two months ago?). It got … complicate. Mostly, because every time I wrote a step function, I had to be careful to undo the same. Wouldn’t it be nice if we could just write a step function and get backtracking for ‘free’?

Well, with immutability you can!

read more...