Archive for Random experiments

n-queens Mexican Standoff

The first day back at work has proved fruitful in the form of someone coming up with the opposite of the traditional n-queens problem: the n-queens Mexican standoff. Instead of minimising the number of mutually attacking queens (to zero), the objective of the standoff version is to maximise the number of attacks.

We haven’t done an exhaustive search yet, but I’ve been running a simulated-annealing-ish script for a while, and it looks like the most attacks is 34 (17 pairs of mutual attacks), in two configurations:

QQ.    .QQ.
QQQ or QQQQ
QQQ    .QQ.

…either of which can be expanded by adding gaps between the queens, or rotating by multiples of 45 degrees.

Q.Q..   .Q.Q.   Q...Q..
.....   Q.Q.Q   .......
Q.Q.Q   .Q.Q.   ..Q...Q
.....   ..Q..   .......
Q.Q.Q           Q...Q..
                .......
                ..Q...Q
Q...Q...

Update: Python code below the fold.

» Continue reading “n-queens Mexican Standoff”

Leave a Comment

Fibonacci music

I spent most of today messing around with music based on the Fibonacci sequence. The result I’m happiest with has four voices, each using the Fibonacci sequence mod 12 to determine the pitch (in semitones), and using the sequence with other moduli (4, 5, 3 and 2 respectively) to determine the timing.

Fibonacci MIDI (9.8KB)

Fibonacci MP3 (3.0MB)

It could generously be described as “atonal crap”, but it sort of has moments of not-completely-awful-ness. Sort of.

Python code below the fold.

» Continue reading “Fibonacci music”

Leave a Comment