#!/usr/bin/perl # (c) 2005, Ward Cunningham # Made available under EPL 1.0 # http://www.opensource.org/licenses/eclipse-1.0.txt use strict; print "Content-type: text/html\n\n"; print <<"";

L-C-R Game

my @chips = map (3, 1 .. ($ENV{QUERY_STRING} || 3)); my $chips = 0; play: for (1..100) { print "\n"; for my $p(0 .. ($#chips)) { print "
"; my $dice = ($chips[$p] < 3) ? $chips[$p] : 3; my ($l, $r) = (($p-1)%@chips, ($p+1)%@chips); for (1 .. $dice) { my @faces = ('L', 'R', 'C', '*', '*', '*'); for ($faces[int(rand()*@faces)]) { print; $chips[$p]-- if /[LRC]/; $chips[$l]++ if /L/; $chips[$r]++ if /R/; $chips++ if /C/; } } print "", map ("$_ ", @chips), " $chips \n"; last play if grep ($_, @chips) == 1; } } my $more = @chips+1; print <<"";


Each refresh plays one game of l-c-r. Columns show each player's roll followed by all player's chips and the center pot after that roll. Try more players. View the source. Try my variant, l-c-r-s, where S splits the pot.