Skip to content

Instantly share code, notes, and snippets.

@masak
Created August 18, 2011 15:20
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save masak/1154298 to your computer and use it in GitHub Desktop.
Creating your little-animal-farm AI
class Farm::AI::Example {
has Str $.player;
method trade(%players, @events) {
if Bool.roll {
return {
type => "trade",
with => "stock",
selling => { sheep => 1 },
buying => { rabbit => 6 },
}
}
else {
return;
}
}
method accept(%players, @events, $trader) {
return Bool.roll;
}
}
$ perl6 farm.pl Example Example
$ perl6 farm.pl Example OtherPlayer ThirdPlayer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment