# Bowntz

An audio-visual pseudo-physical simulation of colliding circles.

Originally implemented in Haskell using SuperCollider3 in 2010, ported to C and extended in 2023: blog post.

# 1 Examples

Bowntz screenshot

Ten video files on archive.org.

# 2 Notes

The world is a collection of N circles which each move at a constant speed in a straight line (in the absence of collisions). Given two such circles it is possible to calculate the precise time of their next collision. For N circles, O(N2) such “next” collisions may occur.

Pick the soonest next collision between circles A and B. This collision will change the velocities of A and B, but no other circle. Update the collection of collisions, by removing all the other “next” collisions involving either A or B, and computing the new collisions of A and B with all the other circles (O(N) collisions). For maintaining a consistent time-base for all circles in the world, it makes sense to advance in a straight line each circle to its position at the time of the collision.

Given a world at time T, to find the world at time T+dT simply step through the future collisions one by one until the soonest collision is after T+dT, at which point one can just advance the circles in straight lines to T+dT.

    T       T+1      T+2      T+3      T+4      T+5      T+6      T+7
... |        |        |        |        |        |        |        | ...

Care needs to be taken in case of numerical imprecision: one can get an infinite number of collisions without time increasing.

# 3 Todo

  • adjustable audio/video offset for synchronisation

  • don’t hard-code 60fps display

  • web browser based version using Emscripten

  • for exhibition installation using an old laptop:

    • disable keyboard input (apart from power button)

    • disable trackpad input

    • disable magic SysRq key

    • shut down when mains power unplugged to preserve battery

  • for exhibition installation using a Raspberry Pi:

    • use TV/composite analogue A/V out to a 4:3 CRT

    • may require aspect ratio tweaks to ensure circles are circular

# 4 Code


git clone https://code.mathr.co.uk/bowntz.git

# 4.1 C Version

bowntz.c is the current C version (2023). Build with make, run like ./bowntz. Command line arguments:

  • --seed=42 set pseudo-random number generator seed.
  • --record=1 render a video.
  • --fs=1 start in fullscreen mode, toggle with F or F11 keys.

Close window or press Q or ESCAPE keys to quit (not operational when record mode is active).

# 4.2 Haskell Version

bowntz.hs is the original Haskell version (2010), which may be hard to get working as Haskell ecosystem changes fast. Build with the cabal-install tool.

To run you need to start SuperCollider3 first:

$ scsynth -u 57110 &
-- wait for scsynth to start, connect its JACK ports --
$ ./bowntz

Bowntz requires a “clean” SC3 server to be running on its usual port. Bowntz leaves this SC3 server in an “unclean” state when it exits.