Files
scandocs/uni/masterarbeit/source/scripts/analysis/createCommandSequenz.py
2014-06-30 13:58:10 +02:00

33 lines
816 B
Python

import random
import sys
def createCommand(joins, joinRate):
nextLeaveNumber = 2
joinCount = 0
commands = []
while joinCount < joins:
if random.random() < joinRate:
commands.append("J")
joinCount += 1
elif nextLeaveNumber < joinCount:
commands.append("L" + repr(nextLeaveNumber))
nextLeaveNumber += 1
resultStr = ""
resultStr += "###\n"
jsString = "{"
index = 0
for command in commands:
jsString += "\"" + repr(index) + "\":\"" + command + "\","
index += 1
resultStr += command + "\n"
jsString = jsString[:-1] + "}"
resultStr += "###" + "\n"
resultStr += jsString + "\n"
return resultStr
if __name__ == "__main__":
createCommand(int(sys.argv[1]), float(sys.argv[2]))