Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine


by mitd (Curate)
on Dec 30, 1999 at 08:39 UTC ( #1553=user: print w/replies, xml ) Need Help??

These guys were really nice to me until I told them they weren't at Hooters.

Old fart coder, John MacDonald handed me the the Pink Camel book in 1991, bought my own have had a hump every since.

AI Competition -- 'The Learning Machine Challenge'
Sample Player

#!/usr/bin/perl -w # - a random, game independent, challenge player # # This player can be used as an example for a rather generalized playe +r. # The player's logic is quite simple: it response to a request to play +, # it emits a single symbol which is picked in random from the alphabet # received from the game organizer (judge). The player logic ignores # the score it receives during the game and contains with generating # random moved until it is told by the organizer that the game is over # The program also ignores any symbols it receives, which might be rel +ated # to the moves of other game participants. # # usage: invoke though a judge/game program. for debug, simple invoke +with # command line arguments # ## MitD 08/10/2001 - ported from tcl -> perl # use strict; use Carp; my $Version = "1.0"; my $Me = "MitD"; # ## we keep our game symbols in a global # my $DEBUG = 0;en my @symbols = (); my $score = 0; $|++; println ('@command info MitDRnd'); println( '# Made in the Dark'); println( '# Artificial Intelligence NV Challenge'); println ('# Player'); println( '# Copyright Peter G. Marshall'); println( '# This is free software; you can redistribute it'); println ('# and/or modify it under the same terms as Perl itself.'); while (<STDIN>) { chomp; process_line($_); } # ## input channel processor # sub chan_input { my $sym = shift; } # ## score channel processor # sub chan_score { my $arg = shift; $score += $arg; } # ## command channel processor # sub chan_command { my ($verb, $args) = split(/ /,$_[0]); if (defined($args)) { eval "command_$verb(\"$args\")"; croak "chan_command with args eval failed: $@\n" if ($@); } else { eval "command_$verb()"; croak "process no args \@ eval failed: $@\n" if ($@); } } # ## process exit command # sub command_exit { exit; } # ## process symbol command # sub command_symbol { my $sym = shift; push(@symbols, $sym); debug ( "SYM: " . join(' ',@symbols) . "\n"); } # ## process new game command # sub command_new { debug ("command new done"); @symbols = (); } # ## process play command # sub command_play { my $sym = $symbols[rand scalar(@symbols)]; println ("\@output $sym"); } sub process_line { my $line = shift; debug ("PL: $line"); # ignore empty lines or lines that begin with # (commennts); return if ( length($line) == 0 or ($line =~ /^#/) ); if ( index($line,'@') == -1) { eval "chan_input(\"$line\")"; croak "process no \@ eval failed: $@\n" if ($@); } else { $line = substr($line,1); my ($channel, $args) = split(/ /,$line,2); eval "&chan_$channel(\"$args\")"; croak "process with \@ eval failed: $@\n" if ($@); } } sub println { print shift() . "\n"; } sub debug { print STDERR $_[0],"\n" if $DEBUG; }

Log In?

What's my password?
Create A New User
[Corion]: Hi marto!
[Corion]: I hope you were able to catch up on some sleep
Corion is slowly, slowly relaxing. Yesterday I spent vegging out in front of the PC, today at a friends, and hopefully I have the books for our Perl club done by Monday. I guess I'll only really relax once I get back from LPW
[marto]: last night, well this morning was a 5am finish, up from 4 am the previous day. Oddly I feel better today than I did yesterday
[Corion]: marto: I think the first thing sleep deprivation does is kill your sense of how tired you are :)

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2017-11-19 11:25 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (280 votes). Check out past polls.