this is a quick and dirty little script to help 2 people play twister. it uses the ‘say’ command in OS X to call out the spins.

here it is :

use strict;

my @colors=qw(red green yellow blue);
my @sides=qw(left right);
my @parts=qw(hand foot);

my ($startwait,$turnwait)[email protected];

$startwait=15 unless $startwait;
$turnwait=4 unless $turnwait;

`say 'get ready to play! you have $startwait seconds until we start, and $turnwait seconds per turn!'`;
sleep $startwait;

#my $last_command;

my %current_places;

COMMAND: while (1){
my $color=int(rand(scalar(@colors)));
my $side=int(rand(scalar(@sides)));
my $part=int(rand(scalar(@parts)));
my $command="$sides[$side] $parts[$part] $colors[$color]";
if ($current_places{"$sides[$side] $parts[$part]"} eq $colors[$color]){
$current_places{"$sides[$side] $parts[$part]"}=$colors[$color];
# if ($command eq $last_command){
# next COMMAND;
# }
# $last_command=$command;
`say -v Vicki '$command'`;
if ($turnwait >= 10){
sleep 1;
`say -v Vicki '$command' - $turnwait seconds`;
print "$command\n";
sleep $turnwait;


Leave a Reply