def main(): (options, args) = parse_args() cardsFilePath = args[0] tape = Tape(options.defaultValue, options.tapeSize) maxIterations = options.maxIterations with open(cardsFilePath, "r") as handle: cards = json.load(handle) currentState = "start" iterationCount = 0 while (currentState != "halt") and (iterationCount < maxIterations): instructions = cards[currentState][tape.read()] tape.write(instructions["write"]) tape.move(instructions["move"]) currentState = instructions["next"] print currentState print tape.statusToString() iterationCount += 1 if currentState != "halt": print "maximum iterations exceeded!"