Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

mitd

by mitd (Curate)
on Dec 30, 1999 at 08:39 UTC ( [id://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 # rnd_player.pl - 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?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2025-01-14 15:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (42 votes). Check out past polls.