Author image Cosimo Streppone




This is a crazy experiment in game algorithms and list iterators. And the algorithm to generate BonDigi sequences is quite interesting...


    use Games::BonDigi;

    my $iter = Games::BonDigi->sequence();

    while(my $word = $iter->())
        print $word, '!', "\n";
        # Wait for other players...


This is a crazy, crazy, crazy, crazy, *crazy* module. There is absolutely *no* reason to download it. Please, stay away from it, by any means!

Ok, I've warned you.

If you don't know what Bon-Digi is, you are really lucky.

Actually, this is a quite interesting experiment in software design of clever algorithms. Either I'm stupid or generating the sequence of "Bon" "Digi" words is really much harder than I thought at first.

Try to think of an algorithm and to build *elegant* and *concise* code. You will find that is not so easy...

For any meaning of elegant and concise, of course.


Esteban, I promised to do that... And there it is!


  This is (did I say it?) rather crazy. I will describe it as an
  RFC and then give you an example.

  BonDigi works with its own internal protocol. The protocol
  consists of a HEADER ("fixed part"), and a PAYLOAD ("the part
  that grows").

  HEADER is *always*: "Bon", "Digi", "Bon", "Digi"

  PAYLOAD is "Bon", "Bon", "Digi", "Digi" (2 repeats the first
  time, then it grows with 3, 4, 5, you get it)



  <HEADER>   := "Bon" "Digi" "Bon" "Digi"

  <PAYLOAD>  := "Bon" (<n> times) "Digi" (<n> times)
                where <n> grows over time

Mmmh, a recursive stateful grammar. Gets hard. Ok, just kidding...


Suppose you are ten people in the same room, drinking beers or something. Then someone starts this *crazy* game.

At turn, each of you must say the next word in the sequence. If you say the wrong word, you must drink beer, write Games::BonDigi, make yourself foolish, and so on...

Sequence starts like this:

    Bon, Digi, Bon, Digi, /*header*/, Bon, Bon, Digi, Digi, /*payload x 2*/,
    Bon, Digi, Bon, Digi, /*header*/, Bon, Bon, Bon, Digi, Digi, Digi, /*payload x 3*/

and you got it. Right?


I didn't find any serious information about this game on the internet. If you find it, please tell me about.



Just a class constructor, useless anyway. If you want to use it, please do. Otherwise, you can use class name.

sequence( [$start [,$end [,@words]]] )

Returns an iterator that generates the BonDigi(tm) sequence of words. Without any parameters, the iterator will return words forever, in an endless crazy sequence of BonDigi words.

Parameters are:


Start of repeats sequence. Default is 2. Means that the payload starts by repeating each word $start times.


End of repeats sequence. Just puts a cruel end to insane fun. Why? By default, there's no end. If you set $end, iterator will stop exactly when the payload reaches $end length in repeats.


If you supply your own words, the game won't really be BonDigi anymore. I warned you. Don't do evil.


You are kidding me?


Cosimo Streppone <>


Copyright (C) 2008 Cosimo Streppone.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the licenses can be found in the Artistic and COPYING files included with this module, or in perlartistic and perlgpl in Perl 5.8.1 or later.