diff --git a/tools/drawState.py b/tools/drawState.py index 2f1c4570e7c16607db43f090134909f947e4ff50..ee01d4a116ae2092bd96290c34c1cf191a44d8e2 100755 --- a/tools/drawState.py +++ b/tools/drawState.py @@ -34,24 +34,25 @@ def drawPenguin(penguin): } print("Pos: {pos}, A:{A}, B:{B}, C:{C}, D:{D}, E:{E}, F:{F}, Tot: {tot}".format(**args)) -try: - while True: - read = [] - print("Enter state:") +if __name__ == "__main__": + try: while True: - line = input() - if line == "": - break - read.append(line) + read = [] + print("Enter state:") + while True: + line = input() + if line == "": + break + read.append(line) + + state = json.loads(''.join(read)) + drawBitboard(state["bitboards"]["onefish"],state["bitboards"]["twofish"],state["bitboards"]["threefish"]) + print("Red penguins") + for i in range(4): + drawPenguin(state["penguins"]["red"][i]) + print("Blue penguins") + for i in range(4): + drawPenguin(state["penguins"]["blue"][i]) - state = json.loads(''.join(read)) - drawBitboard(state["bitboards"]["onefish"],state["bitboards"]["twofish"],state["bitboards"]["threefish"]) - print("Red penguins") - for i in range(4): - drawPenguin(state["penguins"]["red"][i]) - print("Blue penguins") - for i in range(4): - drawPenguin(state["penguins"]["blue"][i]) - -except KeyboardInterrupt: - print("\nMay the fish be with you.") + except KeyboardInterrupt: + print("\nMay the fish be with you.")