Fixed dummyrunner bug, seems to be working correctly now.

This commit is contained in:
Griatch 2015-01-10 20:45:04 +01:00
parent 8d473b7663
commit cf2b83ef0a
2 changed files with 7 additions and 8 deletions

View file

@ -70,7 +70,9 @@ INFO_STARTING = \
""" """
Dummyrunner starting using {N} dummy player(s). If you don't see Dummyrunner starting using {N} dummy player(s). If you don't see
any connection messages, make sure that the Evennia server is any connection messages, make sure that the Evennia server is
running. running. If you intend the dummies to work fully, set
settings.PERMISSION_PLAYER_DEFAULT appropriately (if so it is
recommended that you use a temporary testing database).
Use Ctrl-C to stop/disconnect clients. Use Ctrl-C to stop/disconnect clients.
""" """
@ -141,7 +143,7 @@ def gidcounter():
"makes globally unique ids" "makes globally unique ids"
global GCOUNT global GCOUNT
GCOUNT += 1 GCOUNT += 1
return "%s-%s" % (time.strftime(DATESTRING), ICOUNT) return "%s-%s" % (time.strftime(DATESTRING), GCOUNT)
def makeiter(obj): def makeiter(obj):
@ -178,7 +180,6 @@ class DummyClient(telnet.StatefulTelnetProtocol):
self._login = self.factory.actions[0] self._login = self.factory.actions[0]
self._logout = self.factory.actions[1] self._logout = self.factory.actions[1]
self._actions = self.factory.actions[2:] self._actions = self.factory.actions[2:]
print "_actions:", self._actions
reactor.addSystemEventTrigger('before', 'shutdown', self.logout) reactor.addSystemEventTrigger('before', 'shutdown', self.logout)
@ -236,7 +237,6 @@ class DummyClient(telnet.StatefulTelnetProtocol):
else: else:
# we always pick a cumulatively random function # we always pick a cumulatively random function
crand = random.random() crand = random.random()
print "actions:", self._actions
cfunc = [func for (cprob, func) in self._actions if cprob >= crand][0] cfunc = [func for (cprob, func) in self._actions if cprob >= crand][0]
self._cmdlist = list(makeiter(cfunc(self))) self._cmdlist = list(makeiter(cfunc(self)))
@ -274,8 +274,7 @@ def start_all_dummy_clients(nclients):
# create cumulative probabilies for the random actions # create cumulative probabilies for the random actions
cprobs = [sum(v for i,v in enumerate(probs) if i<=k) for k in range(len(probs))] cprobs = [sum(v for i,v in enumerate(probs) if i<=k) for k in range(len(probs))]
# rebuild a new, optimized action structure # rebuild a new, optimized action structure
print "cprobs, cfuncs:", cprobs, cfuncs actions = (flogin, flogout) + tuple(zip(cprobs, cfuncs))
actions = (flogin, flogout, zip(cprobs, cfuncs))
# setting up all clients (they are automatically started) # setting up all clients (they are automatically started)
factory = DummyFactory(actions) factory = DummyFactory(actions)

View file

@ -104,8 +104,8 @@ def c_login(client):
cmds = ('create %s %s' % (cname, cpwd), cmds = ('create %s %s' % (cname, cpwd),
'connect %s %s' % (cname, cpwd), 'connect %s %s' % (cname, cpwd),
'@dig %s' % START_ROOM % client.cid, '@dig %s' % START_ROOM % client.gid,
'@teleport %s' % START_ROOM % client.cid, '@teleport %s' % START_ROOM % client.gid,
'@dig %s = %s, %s' % (roomname, exitname1, exitname2) '@dig %s = %s, %s' % (roomname, exitname1, exitname2)
) )
return cmds return cmds