TypeError: 'tuple' object is not callable
When I try to write a randomly selected string from an array to a file. This is my code:
import os.path
import random
version = 1
relOp = (">", "=", "<")
facts = ("true", "false", "attack-soldier-count", "attack-warboat-count")
while version < 30:
if not os.path.exists("Recruits"):
print "Recruits folder does not exist."
print "Creating recruits folder."
os.mkdir("Recruits")
version = 1
spawnPath = "C:\Documents and Settings\User\Desktop\Desktop\Tama\Genetic Algorithms\AoK\Recruits\\recruit" + str(version) + ".py"
while os.path.exists(spawnPath):
version += 1
spawnPath = "C:\Documents and Settings\User\Desktop\Desktop\Tama\Genetic Algorithms\AoK\Recruits\\recruit" + str(version) + ".py"
fileHandle = open(spawnPath, "w")
maximumVillagers = random.randint(5,150)
attackSoldierAmount = random.randint(5,150)
fileHandle.write("(defrule\n")
fileHandle.write(" (unit-type-count-total villager < " + str(maximumVillagers) + ")\n")
fileHandle.write(" (can-train villager)\n")
fileHandle.write("=>")
fileHandle.write(" (train villager)\n")
fileHandle.write(")\n")
fileHandle.write("(defrule\n")
fact = facts(random.randint(1,4))
relOpCur = relOp(random.randint(1,3))
fileHandle.write(" " + fact + relOpCur + str(attackSoldierAmount) + ")\n")
fileHandle.write(" (can-train villager)\n")
fileHandle.write("=>")
fileHandle.write(" (train villager)\n")
fileHandle.write(")\n")
fileHandle.close()
Any help would be greatly appreciated. =D
This post has been edited by Tama: 19 October 2008 - 03:09 PM

New Topic/Question
Reply




MultiQuote




|