Some tweaks for testing.

This commit is contained in:
Griatch 2014-11-24 20:03:20 +01:00
parent 0077408d02
commit 94cb5f9527
2 changed files with 31 additions and 3 deletions

View file

@ -111,6 +111,9 @@ DEFAULT_TIMESTEP = 2
# chance of a client performing an action, per timestep. This helps to
# spread out usage randomly, like it would be in reality.
CHANCE_OF_ACTION = 0.05
# spread out the login action separately, having many players create accounts
# and connect simultaneously is generally unlikely.
CHANCE_OF_LOGIN = 0.5
# Port to use, if not specified on command line
DEFAULT_PORT = settings.TELNET_PORTS[0]
#
@ -167,7 +170,9 @@ class DummyClient(telnet.StatefulTelnetProtocol):
# start client tick
d = LoopingCall(self.step)
d.start(self.factory.timestep, now=True).addErrback(self.error)
# dissipate exact step by up to +/- 0.5 second
timestep = self.factory.timestep + (-0.5 + (random.random()*1.0))
d.start(timestep, now=True).addErrback(self.error)
def dataReceived(self, data):
"Echo incoming data to stdout"
@ -198,8 +203,11 @@ class DummyClient(telnet.StatefulTelnetProtocol):
and causes the client to issue commands to the server.
This holds all "intelligence" of the dummy client.
"""
if random.random() > CHANCE_OF_ACTION:
if self.istep == 0 and random.random() > CHANCE_OF_LOGIN:
return
elif random.random() > CHANCE_OF_ACTION:
return
global NLOGGED_IN
if not self._cmdlist:
# no cmdlist in store, get a new one

View file

@ -76,6 +76,14 @@ def c_login(client):
return cmd, "logs in as %s ..." % cname
def c_login_nodig(client):
"logins, don't dig its own room"
cname = "Dummy-%s-%i" % (RUNID, client.cid)
cpwd = "%s-%s" % (RUNID, client.cid)
cmd = ('create %s %s' % (cname, cpwd),
'connect %s %s' % (cname, cpwd))
return cmd, "logs in as %s ..." % cname
def c_logout(client):
"logouts of the game"
return "@quit", "logs out"
@ -149,6 +157,15 @@ def c_moves(client):
if not cmd: cmd = "look"
return cmd, "moves ..."
def c_moves_n(client):
"move through north exit if available"
cmd = ("north",)
return cmd, "moves n..."
def c_moves_s(client):
"move through north exit if available"
cmd = ("north",)
return cmd, "moves s..."
# Action tuple (required)
#
@ -160,7 +177,7 @@ def c_moves(client):
# otherwise the system will normalize them.
#
## "normal builder" definition
## "normal builder" definitionj
#ACTIONS = ( c_login,
# c_logout,
# (0.5, c_looks),
@ -196,6 +213,9 @@ ACTIONS = ( c_login,
(0.39, c_looks),
(0.2, c_help),
(0.4, c_moves))
#ACTIONS = (c_login_nodig,
# c_logout,
# (1.0, c_moves_n))
## "socializing heavy builder" definition
#ACTIONS = (c_login,
# c_logout,