X-Git-Url: https://git.ucc.asn.au/?p=progcomp10.git;a=blobdiff_plain;f=rps%2Ftrunk%2FselectAlgorithms.py;fp=rps%2Ftrunk%2FselectAlgorithms.py;h=0000000000000000000000000000000000000000;hp=41be34612346c82fbd50b18994c0ded708055e26;hb=e9a8105a8f22404f4ac550d79954eaa6b7f5d8ff;hpb=4597b27a44522a5c2785cc23029435f44f60ea55 diff --git a/rps/trunk/selectAlgorithms.py b/rps/trunk/selectAlgorithms.py deleted file mode 100644 index 41be346..0000000 --- a/rps/trunk/selectAlgorithms.py +++ /dev/null @@ -1,23 +0,0 @@ -# Alternative (obsolete) algorithms for selecting agents for battle. -# They're all a bit crap and only here for comparison purposes. - - -# Selects an opponent and removes it from the list of remaining potential opponents. - # This is just an example, but the fact that the first agent will miss out on having - # a fight picked with it it, and that the last agent won't get to pick a fight, seems - # to not matter very much. Can probably be left as-is. - def ChoosePair (self): - # This approach forces each agent to defend once and attack once per round. - # Keep track of the remaining population. - remaining = self.population[:] - agentID = random.randint (0,len(remaining)-1) - defender = remaining.pop (agentID) # Not really a defender (try to work it out)! - while len (remaining) > 1: - if defender.GetPoints () < 1: # If the agent died before it got a chance to attack - attackerID = random.randint (0,len(remaining)-1) - attacker = remaining.pop (attackerID) - else: attacker = defender - defenderID = random.randint (0,len(remaining)-1) - defender = remaining.pop (defenderID) - yield attacker, defender -