From a565d5d81dc496307963389df990c0311603f890 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Mon, 26 Dec 2011 20:28:04 +0100 Subject: [PATCH] Example client: Avoid herps and corpses when fully fed, helps sustainability --- client/example.pl | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/client/example.pl b/client/example.pl index 8029df3..af3db25 100755 --- a/client/example.pl +++ b/client/example.pl @@ -4,7 +4,7 @@ # # This client is meant only as an example of implementation of all # the main features without sophisticated architecture or decision -# making strategies. +# making strategies. It should have some basic sustainability, though. # # Usage: example.pl [PORT [AGENTID [GENDER]]] # @@ -159,12 +159,20 @@ sub take_action($$) { if ($agent eq 'x') { # Herp - $move[dirindex($dir)] += 2; + if ($state->{energy} < 18000) { + $move[dirindex($dir)] += 2; + } else { + $move[dirindex($dir)] -= 2; + } } if ($agent eq 'a') { # Corpse - $move[dirindex($dir)] += 4; + if ($state->{energy} < 17000) { + $move[dirindex($dir)] += 4; + } else { + $move[dirindex($dir)] -= 4; + } } if ($agent eq 'A') {