Bingo

jonasbn on 2002-12-01T16:24:26

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 < 91; $i++) { push @$numbers, $i; }

for (my $j = 0; $j < 10; $j++) { for (my $k = 0; $k < 10; $k++) { if (($j == 0 and $k == 0) or ($j == 9 and $k > 0)) { @$taken->[$j][$k] = " "; } else { @$taken->[$j][$k] = "[ ]"; } } } }

sub show_taken { my $taken = shift;

for (my $m = 0; $m < 10; $m++) { for (my $n = 0; $n < 10; $n++) { print @$taken->[$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...


Dictionary Bingo

Matts on 2002-12-02T11:07:20

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 in case anyone is bored and wants to play bingo ;-)

Bingo - there it is!

jonasbn on 2002-12-03T16:36:22

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.

PDFLib on OS X

jonasbn on 2002-12-03T21:11:49

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.

SUCCESS (was: Re:PDFLib on OS X)

jonasbn on 2002-12-19T21:50:25

I have finally gotten PDFLib to compile on my machine.

This link holds the solution.

Which actually just is a simple:

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