Dr. Camles Brain De-Age Game
- From: ang@xxxxxxxxxxxxx (Angerstein)
- Date: Wed, 27 Sep 2006 16:22:08 +0200
Hi,
I had some spare time and write a perl version of dr. kamigawas brain
age / Big Brain Academy.
There are 6 Memory and Calculation tests. You need the Moduls
Heap-Simple and Time::HiRes.
If somebody adds further tests/games etc. please mail back.
Have Fun!
#!/usr/local/bin/perl
use Heap::Simple;
use Time::HiRes;
########################################################################
########
my @abc = (a .. z);
my $chars1 = 0;
my $chars2 = 0;
my $chars3 = 0;
my $chars4 = 0;
my $chars5 = 0;
my $string = undef;
$right = 0;
$wrong = 0;
$turns = 0;
# start timer
$start = time();
while ($turns <= 10){
$chars1 = int(rand(26));
$chars2 = int(rand(26));
$chars3 = int(rand(26));
$chars4 = int(rand(26));
$chars5 = int(rand(26));
$string = $abc[$chars1] . $abc[$chars2] . $abc[$chars3] .
$abc[$chars4] . $abc[$chars5];
print "Keep the letters in mind!\n $string\n";
sleep(1.5);
for ( my $i = 1; $i <= 30; $i++) {
print "\n\n\n\n\n\n\n\n\n\n";
}
print "Enter:\n";
$input = <STDIN>;
chomp($input);
if ( $input eq $string ) {
print "Very Good. $input is right! Feel Happy!\n";
$right++;
} else {
print "$input is wrong!!! Bad! Stupid!\n";
$wrong++;
}
$turns++;
}
# end timer
$end = time();
$tsum = ($end - $start);
print "Right: $right Wrong: $wrong\nIn $tsum seconds!";
$score += &score($right, $wrong, $tsum, '-0.2');
print "Your Score is $score!\n";
########################################################################
########
my $chars1 = 0;
my $chars2 = 0;
$right = 0;
$wrong = 0;
$turns = 0;
# start timer
$start = time();
while ($turns <= 10){
$chars1 = int(rand(100));
$chars2 = int(rand(100));
print "Please Calculate: $chars1 + $chars2\n";
print "Enter result:\n";
$input = <STDIN>;
chomp($input);
if ($input == ($chars1 + $chars2)) {
print "Very Good. $input is right!\n";
$right++;
} else {
print "$input is wrong!!! Bad! Stupid!\n";
$wrong++;
}
$turns++;
}
# end timer
$end = time();
$tsum = ($end - $start);
print "Right: $right Wrong: $wrong\nIn $tsum seconds!";
$score += &score($right, $wrong, $tsum, '-0.5');
print "Your Score is $score!\n";
########################################################################
########
my @abc = (a .. z);
my $chars1 = 0;
my $chars2 = 0;
$right = 0;
$wrong = 0;
$turns = 0;
# start timer
$start = time();
while ($turns <= 10){
$chars1 = int(rand(26));
$chars2 = int(rand(26));
print "Which letter comes first?\n 1. $abc[$chars1] 2.
$abc[$chars2]\n";
print "Enter:\n";
$input = <STDIN>;
chomp($input);
if ( ($input == 1) && ($chars1 < $chars2)) {
print "Very Good. $input is right!\n";
$right++;
} elsif ( ($input == 2) && ($chars2 < $chars1)) {
print "Very Good. $input is right!\n";
$right++;
} elsif ( ($input == 0) && ($chars1 == $chars2)) {
print "Very Good. $input is right!\n";
$right++;
} else {
print "$input is wrong!!! Bad! Stupid!\n";
$wrong++;
}
$turns++;
}
# end timer
$end = time();
$tsum = ($end - $start);
print "Right: $right Wrong: $wrong\nIn $tsum seconds!";
$score += &score($right, $wrong, $tsum, '-0.5');
print "Your Score is $score!\n";
########################################################################
########
my @list = ();
my $right = 0;
my $wrong = 0;
my $turns = 0;
# start timer
my $start = time();
while ($turns < 10) {
$list[1] = int(rand(100000));
$list[2] = int(rand(100000));
print "Tell me which number is the largest (1. or 2.):\n";
print "1. $list[1] 2. $list[2]\n";
my $input = <STDIN>;
chomp($input);
my $heap = Heap::Simple->new(order => ">");
$heap->insert($list[1], $list[2]);
$count = $heap->count;
my $larg = $heap->top;
print "$larg $count\n";
if ( $larg == $list[$input] ) {
print "Very Good. $input is right!\n";
$right++;
} else {
print "$input is wrong!!! Bad! Stupid!\n";
$wrong++;
}
$turns++;
}
# end timer
my $end = time();
my $tsum = ($end - $start);
print "Right: $right Wrong: $wrong\nIn $tsum seconds!";
$score += &score($right, $wrong, $tsum, '-5');
print "Your Score is $score!\n";
########################################################################
########
$right = 0;
$wrong = 0;
# start timer
$start = time();
$turns = 0;
while ($turns < 10) {
print "How many charakters do you see?\n";
$chars = int(rand(16))+1;
$lb = int(rand(8));
for ( my $i = 1; $i <= $chars; $i++) {
print "*";
if ($i == $lb ) {
print "\n";
$lb = int(rand(8));
}
}
print "\nEnter:\n";
my $input = <STDIN>;
chomp($input);
if ( $chars == $input) {
print "Very Good. $input is right!\n";
$right++;
} else {
print "$input is wrong!!! Bad! Stupid!\n";
$wrong++;
}
$turns++;
}
# end timer
$end = time();
$tsum = ($end - $start);
print "Right: $right Wrong: $wrong\nIn $tsum seconds!";
$score += &score($right, $wrong, $tsum, '-0.5');
print "Your Score is $score!\n";
########################################################################
########
$right = 0;
$wrong = 0;
# start timer
$start = time();
$turns = 0;
sleep(2);
while ($turns < 10) {
print "Keep the numbers in Mind!\n";
$chars = int(rand(999999))+1;
print "$chars\n";
sleep(2);
for ( my $i = 1; $i <= 30; $i++) {
print "\n\n\n\n\n\n\n\n\n\n";
}
print "Enter:\n";
my $input = <STDIN>;
chomp($input);
if ( $chars == $input) {
print "Very Good. $input is right!\n";
$right++;
} else {
print "$input is wrong!!! Bad! Stupid!\n";
$wrong++;
}
$turns++;
}
# end timer
$end = time();
$tsum = ($end - $start);
print "Right: $right Wrong: $wrong\nIn $tsum seconds!";
$score += &score($right, $wrong, $tsum, '0');
print "Your Score is $score!\n";
########################################################################
########
sub score {
my $right = shift;
my $wrong = shift;
my $seconds = shift;
my $tb = shift;
my $points = 10*$right;
my $failures = -10*$wrong;
my $tpoints = $tb*$seconds;
my $score = $points+$failures+$tpoints;
return ($score);
}
########################################################################
########
.
- Follow-Ups:
- Re: Dr. Camles Brain De-Age Game
- From: DJ Stunks
- Re: Dr. Camles Brain De-Age Game
- Prev by Date: Retain Spaces in field value
- Next by Date: can you pass an array in a form in Perl
- Previous by thread: Retain Spaces in field value
- Next by thread: Re: Dr. Camles Brain De-Age Game
- Index(es):
Relevant Pages
|