Skip to content
Snippets Groups Projects
Commit 592340da authored by Bariatti Francesco's avatar Bariatti Francesco
Browse files

Condensed all drawing in one python script

parent 437d964a
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python3
#-*- encoding: utf-8 -*-
try:
while True:
bitboard = int(input("Enter board : "))
output = [" "]
for i in range(59, -1, -1):
if((bitboard >> i) & 1 == 1):
output.append("|x")
else:
output.append("| ")
if(i % 15 == 0):
output.append("|\n ")
elif(i % 15 == 8):
output.append("|\n")
print(''.join(output))
except KeyboardInterrupt:
print("\nMay the fish be with you.")
#!/usr/bin/env python3
#-*- encoding: utf-8 -*-
import json
def drawBitboard(onefish, twofish, threefish):
output = [" "]
for i in range(59, -1, -1):
if((onefish >> i) & 1) == 1:
output.append("|1")
elif ((twofish >> i) & 1) == 1:
output.append("|2")
elif ((threefish >> i) & 1) == 1:
output.append("|3")
else:
output.append("| ")
if(i % 15 == 0):
output.append("|\n ")
elif(i % 15 == 8):
output.append("|\n")
print(''.join(output))
def drawPenguin(penguin):
args = {
"pos": str(penguin & 63).rjust(2),
"A" : str((penguin >> 12) & 7),
"B" : str((penguin >> 15) & 7),
"C" : str((penguin >> 18) & 7),
"D" : str((penguin >> 21) & 7),
"E" : str((penguin >> 24) & 7),
"F" : str((penguin >> 27) & 7),
"tot" : str((penguin >> 6) & 63).rjust(2)
}
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:")
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])
except KeyboardInterrupt:
print("\nMay the fish be with you.")
#!/usr/bin/env python3
#-*- encoding: utf-8 -*-
import sys
while True:
p = int(input("Enter penguin: "))
print("Position: ", p & 63)
print("Nb moves: ", (p >> 6) & 63)
print("Nb moves A: ", (p >> 12) & 7)
print("Nb moves B: ", (p >> 15) & 7)
print("Nb moves C: ", (p >> 18) & 7)
print("Nb moves D: ", (p >> 21) & 7)
print("Nb moves E: ", (p >> 24) & 7)
print("Nb moves F: ", (p >> 27) & 7)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment