Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

jonasbn (1153)

jonasbn
  reversethis-{gro.napc} {ta} {nbsanoj}
http://e-diot.dk/
AOL IM: BJonasN (Add Buddy, Send Message)

Perl Programmer located in Copenhagen, Denmark. Active member of Copenhagen Perl Mongers.

Author of:

  • Business::DK::CPR
  • Business::DK::CVR
  • Business::DK::PO
  • Business::OnlinePayment::CashCow
  • Date::Holidays
  • Date::Holidays::Abstract
  • Date::Holidays::Super
  • Date::Pregnancy
  • Games::Bingo
  • Games::Bingo::Bot
  • Games::Bingo::Print
  • Module::Info::File
  • Module::Template::Setup
  • Test::Timer

and maintainer of:

  • Tie::Tools
  • XML::Conf
  • Workflow

Journal of jonasbn (1153)

Sunday December 01, 2002
11:24 AM

Bingo

[ #9219 ]

Well my girlfriend invited me to a bingo friday night.

No I am not the bingo playing age, but it was fun and it was for a good cause (funding a schooltrip to Iceland).

Well the whole bingo thing was run on a large screen, actually due to the face that the organisers were def.

Looking the computer program I came to think I actually never made a bingo game for my computer, so here goes first draft for bingo.pl


#!/usr/bin/perl -w

use strict;
use POSIX;

my @numbers;
my @taken;

init(\@numbers, \@taken);

while(scalar @numbers) {
        my $pos = POSIX::floor(rand(scalar @numbers));
        my $number = $numbers[$pos];
        #print "number = $number\n";
        splice(@numbers, $pos, 1);

        take(\@taken, $number);
        system("clear");
        show_taken(\@taken);
}

sub init {
        my $numbers = shift;
        my $taken = shift;

        for(my $i = 1; $i 0)) {
                                @$taken->[$j][$k] = " ";
                        } else {
                                @$taken->[$j][$k] = "[ ]";
                        }
                }
        }
}

sub show_taken {
        my $taken = shift;

        for (my $m = 0; $m [$m][$n];
                }
                print "\n";
        }
}

sub take {
        my $taken = shift;
        my $take = shift;

        my $take2 = sprintf("%02d", $take);
        my ($x, $y) = $take2 =~ m/^(\d{1})(\d{1})$/;

        @$taken->[$x][$y] = '['.$take2.']';
}

  with the following benchmark:

0.850u 1.340s 0:05.01 43.7% 0+0k 0+7io 0pf+0w

I DO NOT recommend this game to old people it could prove hazardous.

I have committed bingo.pl to the Copenhagen.pm CVS server snippes section, check there for updates...

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • A while ago I wrote in my journal about a program I wrote for my wife (an English Teacher) that creates PDF bingo cards created from a list of words she specified. I suspect it could be just as easy to use numbers too.

    I've put the code here [axkit.org] in case anyone is bored and wants to play bingo ;-)
  • Hmmmm very interesting, I thought about this, your example code will give me a serious head start.

    I expect also to make some control mechanisms so that the program can see when a plate has bingo.

    This could also form the base for the actual game.
  • Hi Matt,

    You wouldn't happen to know how to get PDFLib running under OS X?

    - I downloaded the tarball from www.pdflib.com, but there is no installation quite, and I do not quite understand the structure of the pm file (the package name is not PDFLib).

    I will probably ask this question at the Perl OS X mailing list when I get the time.
    • I have finally gotten PDFLib to compile on my machine.

      This link [yahoo.com] holds the solution.

      Which actually just is a simple:

      bash-2.05$ CFLAGS=-I/Developer/Headers/FlatCarbon LDFLAGS="-framework CoreServices -framework ApplicationServices" ./configure