Mastodon
sungate.co.uk

sungate.co.uk

Ramblings about stuff

Here comes Bod

Well, it was a Friday afternoon and I got distracted enough to write a small program which plays Bod Snap.

$ bod
Bod and PC Copper ...
... that's not snap!

Farmer Barleymow and PC Copper ...
... that's not snap!

Aunt Flo and Bod ...
... that's not snap!

Farmer Barleymow and Aunt Flo ...
... that's not snap!

Aunt Flo and Aunt Flo ...
... SNAP!

If you’re the same age as me, then you’ll remember. If not, then I’m banging on about Bod, the Children’s TV series from the 1970s. And, because it’s not very long or complicated, here’s the source code, also downloadable as bod.c:

/*
########################################################################
#                                                                      #
# bod - plays Bod Snap                                                 #
#                                                                      #
# Copyright (C)2007 Dave Ewart (davee@sungate.co.uk)                   #
#                                                                      #
########################################################################
#                                                                      #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License, or    #
# (at your option) any later version.                                  #
#                                                                      #
# This program is distributed in the hope that it will be useful,      #
# but WITHOUT ANY WARRANTY; without even the implied warranty of       #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        #
# GNU General Public License for more details.                         #
#                                                                      #
########################################################################
*/

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i;
    int j;
    char *people[5];
    int snap = 0;

    unsigned int iseed = (unsigned int) time(NULL);

    srand(iseed);

    people[0] = "Bod";
    people[1] = "PC Copper";
    people[2] = "Farmer Barleymow";
    people[3] = "Postman Frank";
    people[4] = "Aunt Flo";

    while (!snap) {

        i = (int) 5 *(rand() / (RAND_MAX + 1.0));
        j = (int) 5 *(rand() / (RAND_MAX + 1.0));

        printf("%s and %s ...\n", people[i], people[j]);
        sleep(1);
        if (i == j) {
            printf("... SNAP!\n");
            snap = 1;
        }
        else {
            printf("... that's not snap!\n\n");
            sleep(2);
        }
    }
}

Enjoy!

4 Responses to Here comes Bod

  1. It was Friday evening, and I got bored, so I had a little time to Pythonise this:

    http://jehaisleprintemps.net/lugradio/bod.py

    (even if I have NO CHANCE to have watched Bod when I was a lad)

    Enjoy!

    Permalink
  2. We should perhaps have a competition for the most esoteric implementation of ‘Bod’. I can see Will wading in with a Haskell version…

    Permalink
  3. I can’t believe I did this.

    http://willthompson.co.uk/tmp/Bod.hs

    Permalink
  4. Yay, nice work Will 🙂

    Permalink

Comments are closed.