Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
Python Bot?

 
Post new topic   Reply to topic Printable version
 View previous topic  Cross-platform C# chatnet core with op... Post :: Post chasm -- python parts of subspace  View next topic  
Author Message
cycad
Novice


Gender:Gender:Male
Joined: Feb 12 2004
Posts: 29
Offline

PostPosted: Fri Jan 29, 2010 2:05 pm    Post subject: Python Bot? Reply to topic Reply with quote

Just kidding, this topic isn't really a question.

I wrote a Python bot core for the sake of learning a little about Python. It logs in over the Subspace protocol and then sits there printing out the events it receives. I only created a couple of events but it could be extended if there's any interest.

I broke down the Game Stack and the Core Stack into 2 classes, so the core stack can be reused, say, for connecting to the biller. It handles reliability and cluster packets.

If you have interest in writing a core or want to have a fun way to learn Python then this might be useful to you. I didn't write it as a production solution (there isn't really a problem to be solved;) but I hope at least 1 person can find this useful or learn something from it.

Here's an example:
Code: Show/Hide

#!/usr/bin/env python

from SubspaceGameStack import *

if __name__ == '__main__':
   stack = SubspaceGameStack(False)
   stack.connectToServer('127.0.0.1', 7900, 'username', 'password*smodpassword', '#master')
   
   connected = True
   while connected:
      event = stack.waitForEvent()
      if event.type == EVENT_TICK:
         #lets not be too noisy
         #print 'EVENT_TICK'
         pass
      if event.type == EVENT_ENTER:
         print 'EVENT_ENTER'
         print "Player Joined:", event.name
      elif event.type == EVENT_LEAVE:
         print 'EVENT_LEAVE'
         print 'Player with PID %04X left' % event.pid
      elif event.type == EVENT_MESSAGE:
         print 'EVENT_MESSAGE'
         print 'Type:%d Text:%s' % (event.message_type, event.message)
      elif event.type == EVENT_DISCONNECT:
         print 'EVENT_DISCONNECT'
         connected = False
      elif event.type == EVENT_LOGIN:
         print 'EVENT_LOGIN'


And some output:
Code: Show/Hide

EVENT_LOGIN
EVENT_ENTER
Player Joined: Bot-EG-Public-2
EVENT_ENTER
Player Joined: Bot-PubSup-2
EVENT_ENTER
Player Joined: supers bro1
EVENT_ENTER
Player Joined: Conceptronic
EVENT_ENTER
Player Joined: Leap
EVENT_ENTER
Player Joined: Skype
EVENT_ENTER
Player Joined: Ummagumma
EVENT_ENTER
Player Joined: Scooby!
EVENT_ENTER
Player Joined: H0ST
EVENT_ENTER
Player Joined: SupaFlyTNT
EVENT_ENTER
Player Joined: Luft
EVENT_ENTER
Player Joined: apex
EVENT_ENTER
Player Joined: Emergen-C
EVENT_ENTER
Player Joined: King of Borg
EVENT_ENTER
Player Joined: AyhA
EVENT_ENTER
Player Joined: trodd21
EVENT_ENTER
Player Joined: Azn_Street_Hooker
EVENT_ENTER
Player Joined: droog
EVENT_ENTER
Player Joined: WarHunter
EVENT_ENTER
Player Joined: Jugulate$6
EVENT_ENTER
Player Joined: Vengren
EVENT_ENTER
Player Joined: SLAP ~ HAPPY
EVENT_ENTER
Player Joined: su-34
EVENT_ENTER
Player Joined: final ride
EVENT_ENTER
Player Joined: G]-[()ST
EVENT_ENTER
Player Joined: zombie
EVENT_ENTER
Player Joined: coldielox
EVENT_ENTER
Player Joined: oDb
EVENT_ENTER
Player Joined: Duckie
EVENT_ENTER
Player Joined: BulletiN
EVENT_ENTER
Player Joined: Gilthaniel
EVENT_ENTER
Player Joined: stoned i am
EVENT_ENTER
Player Joined: leen
EVENT_ENTER
Player Joined: ritzand
EVENT_ENTER
Player Joined: aquabox
EVENT_MESSAGE
Type:0 Text:This arena is Continuum-only. Please get Continuum client from http://www.subspace.net to play here
EVENT_MESSAGE
Type:0 Text:Welcome to Extreme Games - Visit our website at www.extreme-games.net


You can message me in SS if you have any questions. Have fun.




PythonBot

PythonBot.zip - 6.73 KB
File downloaded or viewed 50 time(s)
Back to top
View users profile Send private message Add User to Ignore List
divine.216
Newbie


Joined: Jun 12 2005
Posts: 18
Offline

PostPosted: Sun Jan 31, 2010 11:01 pm    Post subject: Reply to topic Reply with quote

I haven't played with it yet; but wonderful stuff. Thanks for this.
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Misc User Apps All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 27 page(s) served in previous 5 minutes.

phpBB Created this page in 0.108465 seconds : 29 queries executed (14.7%): GZIP compression disabled