def __init__(self, bot): self.constructor = bot self.nickname = bot.__name__ def clientConnectionLost(self, connector, reason): print("Connection lost.", reason) connector.connect() def clientConnectionFailed(self, connector, reason): print("Connection failed.", reason) reactor.stop() if __name__ == "__main__": import importlib import sys if len(sys.argv) == 1: print("USAGE: client.py file.BotName [...]") sys.exit(-1) server = "localhost" if "irc." in sys.argv[1]: server = sys.argv.pop(1) for cls in getCompetitors(sys.argv[1:]): reactor.connectTCP(server, 6667, ResistanceFactory(cls)) reactor.run()
def __init__(self, bot): self.constructor = bot self.nickname = bot.__name__ def clientConnectionLost(self, connector, reason): print('Connection lost.', reason) connector.connect() def clientConnectionFailed(self, connector, reason): print('Connection failed.', reason) reactor.stop() if __name__ == '__main__': import importlib import sys if len(sys.argv) == 1: print('USAGE: client.py file.BotName [...]') sys.exit(-1) server = 'localhost' if 'irc.' in sys.argv[1]: server = sys.argv.pop(1) for cls in getCompetitors(sys.argv[1:]): reactor.connectTCP(server, 6667, ResistanceFactory(cls)) reactor.run()
import sys from time import time import itertools from competition import CompetitionRunner, getCompetitors if __name__ == '__main__': if len(sys.argv) <= 2: print('USAGE: competition.py 10000 file.BotName [...]') sys.exit(-1) competitors = getCompetitors(sys.argv[2:]) opponents = getCompetitors([# 'bots.RandomBot', 'bots.RuleFollower', 'bots.Deceiver', 'bots.Jammer', 'bots.Hippie', 'bots.Neighbor', 'aigd.Statistician', 'aigd.LogicalBot']) pool = competitors + opponents rnd = 1 while len(pool) >= 5: r = int(sys.argv[1]) if len(pool) == 5: runner = CompetitionRunner(pool, rounds = int(r * 2.5), quiet = False) else: runner = CompetitionRunner(pool, rounds = r, quiet = True) runner.main() if len(pool) == 5: runner.show(summary=True) break else: last, other = runner.last() print "ROUND #%i: Eliminated %s." % (rnd, last[0].__name__),
self.nickname = bot.__name__ def clientConnectionLost(self, connector, reason): print('DISCONNECT %s.' % self.nickname) connector.connect() def clientConnectionFailed(self, connector, reason): print('FAILURE %s.' % self.nickname) reactor.stop() if __name__ == '__main__': import importlib import sys import argparse parser = argparse.ArgumentParser() parser.add_argument( '--server', type=str, required=False, default='irc.aigamedev.com', help="Name of the IRC server to connect the specified bots to.") args, remaining = parser.parse_known_args() for cls in getCompetitors(remaining): reactor.connectTCP(args.server, 6667, ResistanceFactory(cls)) reactor.run()
protocol = ResistanceProtocol def __init__(self, bot): self.constructor = bot self.nickname = bot.__name__ def clientConnectionLost(self, connector, reason): print('DISCONNECT %s.' % self.nickname) connector.connect() def clientConnectionFailed(self, connector, reason): print('FAILURE %s.' % self.nickname) reactor.stop() if __name__ == '__main__': import importlib import sys import argparse parser = argparse.ArgumentParser() parser.add_argument('--server', type=str, required=False, default='irc.aigamedev.com', help="Name of the IRC server to connect the specified bots to.") args, remaining = parser.parse_known_args() for cls in getCompetitors(remaining): reactor.connectTCP(args.server, 6667, ResistanceFactory(cls)) reactor.run()
import sys from time import time import itertools from competition import CompetitionRunner, getCompetitors if __name__ == '__main__': if len(sys.argv) <= 2: print('USAGE: competition.py 10000 file.BotName [...]') sys.exit(-1) competitors = getCompetitors(sys.argv[2:]) opponents = getCompetitors( [ # 'bots.RandomBot', 'bots.RuleFollower', 'bots.Deceiver', 'bots.Jammer', 'bots.Hippie', 'bots.Neighbor', 'aigd.Statistician', 'aigd.LogicalBot' ]) pool = competitors + opponents rnd = 1 while len(pool) >= 5: r = int(sys.argv[1]) if len(pool) == 5: runner = CompetitionRunner(pool, rounds=int(r * 2.5), quiet=False) else: runner = CompetitionRunner(pool, rounds=r, quiet=True) runner.main() if len(pool) == 5: runner.show(summary=True) break else: last, other = runner.last()