I’m attempting to make a game called nine men’s morris in python, and I can’t figure out
why the string won’t replace when conditions are satisfied the next time the
gameplay_board()
function is called. anyone have any ideas?
I was expecting the value of a1
to be changed from ' '
to ○
, but it doesn’t seem to work.
#ring 1
a1="1"
b1="2"
c1="3"
d1="4"
e1="5"
f1="6"
g1="7"
h1="8"
#ring 2
a2="1"
b2="2"
c2="3"
d2="4"
e2="5"
f2="6"
g2="7"
h2="8"
#ring 3
a3="1"
b3="2"
c3="3"
d3="4"
e3="5"
f3="6"
g3="7"
h3="8"
def example_board():
global a1, b1, c1, d1, e1, f1, g1, h1, a2, b2, c2, d2, e2, f2, g2, h2, a3, b3, c3, d3, e3, f3, g3, h3
print("\n" +
a1 + "----------" + b1 + "----------" + c1 + "\n" +
"| | |" + "<---Ring 1" + "\n" +
"| " + a2 + "-------" + b2 + "-------" + c2 + " |" + "\n" +
"| | | |<---Ring 2" + "\n" +
"| | " + a3 + "----" + b3 + "----" + c3 + " | |" + "\n" +
"| | | |<---Ring 3" + "\n" +
d1 + "--" + d2 + "--" + d3 + " " + e3 + "--" + e2 + "--" + e1 + "\n" +
"| | | | | |" + "\n" +
"| | " + f3 + "----" + g3 + "----" + h3 + " | |" + "\n" +
"| | | | |" + "\n" +
"| " + f2 + "-------" + g2 + "-------" + h2 + " |" + "\n" +
"| | |" + "\n" +
f1 + "----------" + g1 + "----------" + h1 + "\n" + "_______________________" + "\n")
a1=" "
b1=" "
c1=" "
d1=" "
e1=" "
f1=" "
g1=" "
h1=" "
a2=" "
b2=" "
c2=" "
d2=" "
e2=" "
f2=" "
g2=" "
h2=" "
a3=" "
b3=" "
c3=" "
d3=" "
e3=" "
f3=" "
g3=" "
h3=" "
example_board()
def gameplay_board():
print("\n" +
" " + "----------" + " " + "----------" + " " + "\n" +
"| | |" + "\n" +
"| " + " " + "-------" + " " + "-------" + " " + " |" + "\n" +
"| | | | |" + "\n" +
"| | " + " " + "----" + " " + "----" + " " + " | |" + "\n" +
"| | | | | |" + "\n" +
d1 + "--" + d2 + "--" + d3 + " " + e3 + "--" + e2 + "--" + e1 + "\n" +
"| | | | | |" + "\n" +
"| | " + f3 + "----" + g3 + "----" + h3 + " | |" + "\n" +
"| | | | |" + "\n" +
"| " + f2 + "-------" + g2 + "-------" + h2 + " |" + "\n" +
"| | |" + "\n" +
f1 + "----------" + g1 + "----------" + h1 + "\n" + "_______________________" + "\n")
#gameplay_board()
def update():
gameplay_board()
turn=1
bpp=0
wpp=0
def place_pieces():
ringchoice=int(input("Player 1, please select a ring to place your piece on. "))
if ringchoice==1: #and ringchoice=="one":
spotchoice=input("Player 1, please chose a spot to place your piece on. ")
if spotchoice==1:
a1="○"
gameplay_board()