The maze book for programmers!

Algorithms, circle mazes, hex grids, masking, weaving, braiding, 3D and 4D grids, spheres, and more!

DRM-Free Ebook

The Buckblog

assorted ramblings by Jamis Buck

Dec 2016

Process Roulette

23 December 2016 — Announcing a party game for developers, but with a few caveats — 3-minute read

A week or so ago I posted a throw-away tweet with an idea that (I’m sure) is neither original, nor worthy of actually spending time on:

However, once posted, I couldn’t stop thinking about it, and so here we are, a week and a half later, and I’m announcing the initial release of “Process Roulette”. It gave me a chance to experiment with the atom editor, as well as to try and finally learn the pros and cons of rubocop. (I’ll try and do a separate post for each of those in the near future.)

But right now, we’re here because of process roulette. The premise is just what I said in my tweet: each player whacks random processes on their machine until their player process goes away. Whoever lasts the longest, wins.

There are three parts to this game:

  1. The croupier. This is the supervisor process that manages the game, tracks the rounds, and ultimately decides the winner.
  2. The controller. This is a separate process that connects to the croupier and declares when each bout should start. The controller is notified whenever a new player joins, as well as when a game ends. (There are also spectators, who are like controllers, but read-only.)
  3. The players. These are the processes that actually whack processes. These should always be run on machines that you hate. Or, you know, virtual machines. The players connect to the croupier, and when the signal is given, they proceed to kill processes at random.

Want to give it a try? It’s easy! First, install the gem:

$ gem install process-roulette

You’ll need to install it on every computer that will be involved.

Then, fire up the croupier. Just tell it which port to listen on, and what password the controllers should use to authenticate:

$ croupier -p 8192 password

Once the croupier is running, start up at least one controller. Tell it where the croupier is running, and give the password as well:

$ roulette-ctl localhost:8192 password
Starting controller process...

waiting for bout to begin

This will give you a command prompt–for now, just leave it be. We’ll talk about what you can do as the controller in a moment.

Optionally, you can also start up multiple spectators, to watch the game. (This is useful for people who are starting up the player processes, since otherwise they won’t know who won the game!) The spectators are just controllers, minus the password.

$ roulette-ctl localhost:8192

Lastly, on each virtual machine (or otherwise despised host), fire up a player process. Make sure and run it as a superuser, otherwise it won’t be able to kill the really important processes! Tell it where the croupier is, and what username should identify the player.

$ sudo roulette-player [email protected]:port

The player will then display “connecting”, and will wait for the signal from the croupier. As each player connects, the controllers should display the username of the player, along with the total number of registered players.

When everyone has joined and the game is ready, one of the controllers should type “GO” at their prompt, and press return:

$ roulette-ctl localhost:8192 password
Starting controller process...

waiting for bout to begin
controller> GO

telling croupier to start game

At this point, the players will all begin whacking processes, and the controllers (and spectators) will indicate the beginning of each subsequent round. As players die, the controllers will show that as well. When the last player dies, the controllers will summarize the bout with a scoreboard, and then return to the command prompt, ready to start a new game when players (re)join.

   | Name       | Killer     | Rounds
 1 | bob        | bash       |    63
 2 | crazy      | login      |    51
 3 | juliet     | ruby       |    49
 4 | grinch     | login      |    13

waiting for bout to begin

The controller itself may be terminated by typing “QUIT” (or ^D). Typing “EXIT” will tell the croupier process itself to terminate.

Give it a try and let me know what you think! If you want to tinker with it a bit yourself, check out the source code on GitHub.

Nov 2016

Weekly Programming Challenges -- Recap

19 November 2016 — Recapping the last 16 weeks of weekly programming challenges — 2-minute read

Weekly Programming Challenge #16

12 November 2016 — The Midpoint Displacement Algorithm — 4-minute read

Weekly Programming Challenge #15

5 November 2016 — Turtle Graphics — 3-minute read
Oct 2016

Weekly Programming Challenge #14

29 October 2016 — Lindenmayer Systems — 4-minute read

Weekly Programming Challenge #13

22 October 2016 — 4-minute read

Weekly Programming Challenge #12

15 October 2016 — 4-minute read

Weekly Programming Challenge #11

8 October 2016 — 3-minute read

Weekly Programming Challenge #10

1 October 2016 — 5-minute read

Sep 2016

Weekly Programming Challenge #9

24 September 2016 — 5-minute read

Weekly Programming Challenge #8

17 September 2016 — 5-minute read

Weekly Programming Challenge #7

10 September 2016 — 1-minute read

Aug 2016

Weekly Programming Challenge #5

27 August 2016 — 1-minute read

Jul 2016

Weekly Programming Challenges

30 July 2016 — 1-minute read

Jun 2016

Truth: Generating Truth Tables

11 June 2016 — 2-minute read

May 2016

Disrupting Your Comfort Zone

28 May 2016 — 1-minute read

Think You’re Failing? Look Around.

14 May 2016 — 1-minute read

The Minimalist Programmer

7 May 2016 — 1-minute read

Apr 2016

Tapping ActiveRecord Relations

23 April 2016 — 2-minute read

2 April 2016 — 1-minute read

Mar 2016

Introducing the Query Composer

26 March 2016 — 4-minute read

The Poverty of Constraints

19 March 2016 — 1-minute read

Variations on a Theme: "I Becomes We..."

12 March 2016 — 2-minute read

Being a Good Neighbor...

5 March 2016 — 6-minute read

Feb 2016

Implementing a Bloom Effect with Swift+Metal

27 February 2016 — 7-minute read

Don't Feed the Hamster the Whole Stalk

20 February 2016 — 6-minute read

The weakly-flowing stream

13 February 2016 — 4-minute read

Living with Your Eyes Open

6 February 2016 — 6-minute read

Jan 2016

Software Proverbs

30 January 2016 — 4-minute read

Mazes in Swift

23 January 2016 — 4-minute read

Way Back

The Buckblog Archives

Dating to 2004 — Hundreds more articles