Creating your little-animal-farm AI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | |
| } | |
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ 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