Permalink
Browse files

New bot: Nico.

  • Loading branch information...
nicosarubbi committed Jul 8, 2012
1 parent 2eefede commit c707d4dba4115b3ed9b8edfb9d12d691ea6f5eda
Showing with 23 additions and 0 deletions.
  1. +23 −0 bots/nico.py
View
@@ -0,0 +1,23 @@
+from twisted.internet.protocol import ClientFactory
+from twisted.internet import reactor
+from random import random
+
+import spacecraft
+
+
+class NicoClient(spacecraft.server.ClientBase):
+ name = 'nico bot'
+ def messageReceived(self, message):
+ self.command("throttle", value=1)
+ self.command("fire")
+ if random() < 0.2:
+ self.command("turn", value=1)
+
+def main():
+ factory = ClientFactory()
+ factory.protocol = NicoClient
+ reactor.connectTCP("localhost", 11106, factory)
+
+if __name__ == "__main__":
+ reactor.callWhenRunning(main)
+ reactor.run()

0 comments on commit c707d4d

Please sign in to comment.