1 from uccProgComp import BaseAgent, LearningAgent, RandomAttack
4 # BOFH is something of a cross between Frechie and Lucifer
6 class BOFH (LearningAgent):
7 def Attack (self, foe):
8 attack = RandomAttack ()
11 def Defend (self, foe, bluff):
12 if bluff == Rock: attack = Scissors # Here we assume that they
13 elif bluff == Paper: attack = Rock # are lying, trying to kill us.
14 else: attack = Paper # And we try to kill them.
17 def Attack (self, foe):
18 attack = RandomAttack ()
19 if len(LearningAgent.GetWinHistory (self, foe)) > 0:
20 if attack == Rock: bluff = Paper # Here we choose the thing
21 elif attack == Paper: bluff = Scissors # that will hurt them
22 else: bluff = Rock # if they try to kill us.
24 if attack == Rock: bluff = Scissors # Here we choose the thing
25 elif attack == Paper: bluff = Rock # that will hurt them
26 else: bluff = Paper # if they go for a tie.
29 def Defend (self, foe, bluff):
30 if len(LearningAgent.GetWinHistory (self, foe)) > 0:
31 if bluff == Rock: attack = Scissors # They've fucked us in the past,
32 elif bluff == Paper: attack = Rock # so we assume they're lying and
33 else: attack = Paper # hoping we go for a kill.
35 if bluff == Rock: attack = Paper # Here we trust that they
36 elif bluff == Paper: attack = Scissors # are telling the truth.
37 else: attack = Rock # And we try to kill them.
40 #Fish is somewhat intelligent; it builds up trust and then stabs you in the back.
41 # If Fish detects that a bot is being predictably nice (tie 2+ times in a row), it will attack.
42 # If Fish detects that a bot has betrayed it (Loss), it will attack.
43 # Otherwise, Fish is nice.
45 class Fish (LearningAgent):
46 def Attack (self, foe):
47 #print "Attacking" , foe
48 #print LearningAgent.GetWinHistory (self, foe)
49 attack = RandomAttack ()
51 history = LearningAgent.GetWinHistory (self, foe)
57 #if we just lost to them, try to destroy them.
58 elif Loss == history[-1] or (len(history)>1 and [Tie,Tie] == history[-2:-1]):
59 if attack == Rock: bluff = Scissors
60 elif attack == Paper: bluff = Rock
67 def Defend (self, foe, bluff):
69 history = LearningAgent.GetWinHistory (self, foe)
71 if len(history) > 0 and Loss == history[-1]:
72 if bluff == Rock: attack = Scissors # They've fucked us in the past,
73 elif bluff == Paper: attack = Rock # so we assume they're lying and
74 else: attack = Paper # hoping we go for a kill.