Last active
December 31, 2018 19:53
-
-
Save XChrisUnknownX/f7abdcdd1f0113eb80efc14f54c2d6de to your computer and use it in GitHub Desktop.
presents a board with 9 spaces and allows you to move up, down, left, right. Still teaching myself python.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a1 = "-" | |
a2 = "-" | |
a3 = "-" | |
b1 = "-" | |
b2 = "-" | |
b3 = "-" | |
c1 = "-" | |
c2 = "-" | |
c3 = "-" | |
up = "up" | |
down = "down" | |
left = "left" | |
right = "right" | |
print("""a1 a2 a3 | |
b1 b2 b3 | |
c1 c2 c3""") | |
print() | |
def printboard(a,aa,aaa,b,bb,bbb,c,cc,ccc): | |
print(a,end=" ") | |
print(aa,end=" ") | |
print(aaa) | |
print(b,end=" ") | |
print(bb,end=" ") | |
print(bbb) | |
print(c,end=" ") | |
print(cc,end=" ") | |
print(ccc,end=" ") | |
while True: | |
start = input("Select your starting position: ") | |
if start == "a1": | |
a1 = "o" | |
elif start == "a2": | |
a2 = "o" | |
elif start == "a3": | |
a3 = "o" | |
elif start == "b1": | |
b1 = "o" | |
elif start == "b2": | |
b2 = "o" | |
elif start == "b3": | |
b3 = "o" | |
elif start == "c1": | |
c1 = "o" | |
elif start == "c2": | |
c2= "o" | |
elif start == "c3": | |
c3 = "o" | |
else: | |
print("Must enter valid position.") | |
continue | |
break | |
throw = False | |
while True: | |
print("This is the board:") | |
print() | |
printboard(a1,a2,a3,b1,b2,b3,c1,c2,c3) | |
print() | |
choice = input("""Would you like to go up, down, left, or right? | |
ANSWER: """) | |
if start == "a1" and choice == "up": | |
if throw == True: | |
print("You were warned that you may not move off the board, and you have now fallen off the board.") | |
input("""What do you have to say for yourself? | |
ANSWER: """) | |
break | |
else: | |
pass | |
print("You may not move up from a1, as that would throw you off the board. Take care not to make any moves that would throw you off the board.") | |
throw = True | |
continue | |
elif start == "a1" and choice == "down": | |
start = "b1" | |
a1 = "-" | |
b1 = "o" | |
elif start == "a1" and choice == "left": | |
if throw == True: | |
print("You were warned that you may not move off the board, and you have now fallen off the board.") | |
input("""What do you have to say for yourself? | |
ANSWER: """) | |
break | |
else: | |
pass | |
print("You may not move left from a1, as that would throw you off the board. Take care not to make any moves that would throw you off the board.") | |
throw = True | |
continue | |
elif start == "a1" and choice == "right": | |
start = "a2" | |
a1 = "-" | |
a2 = "o" | |
elif start == "a2" and choice == "up": | |
if throw == True: | |
print("You were warned that you may not move off the board, and you have now fallen off the board.") | |
input("""What do you have to say for yourself? | |
ANSWER: """) | |
break | |
else: | |
pass | |
print("You may not move up from a2, as that would throw you off the board. Take care not to make any moves that would throw you off the board.") | |
throw = True | |
continue | |
elif start == "a2" and choice == down: | |
start = "b2" | |
a2 = "-" | |
b2 = "o" | |
elif start == "a2" and choice == left: | |
start = "a1" | |
a2 = "-" | |
a1 = "o" | |
elif start == "a2" and choice == right: | |
start = "a3" | |
a2 = "-" | |
a3 = "o" | |
elif start =="a3" and choice == up: | |
if throw == True: | |
print("You were warned that you may not move off the board, and you have now fallen off the board.") | |
input("""What do you have to say for yourself? | |
ANSWER: """) | |
break | |
else: | |
pass | |
print("You may not move up from a3, as that would throw you off the board. Take care not to make any moves that would throw you off the board.") | |
throw = True | |
continue | |
elif start == "a3" and choice == down: | |
start = "b3" | |
a3 = "-" | |
b3 = "o" | |
elif start == "a3" and choice == left: | |
start = "a2" | |
a3 ="-" | |
a2 = "o" | |
elif start == "a3" and choice == right: | |
if throw == True: | |
print("You were warned that you may not move off the board, and you have now fallen off the board.") | |
input("""What do you have to say for yourself? | |
ANSWER: """) | |
break | |
else: | |
pass | |
print("You may not move right from a3, as that would throw you off the board. Take care not to make any moves that would throw you off the board.") | |
throw = True | |
continue | |
elif start =="b1" and choice == up: | |
start = "a1" | |
b1 = "-" | |
a1 = "o" | |
elif start == "b1" and choice == down: | |
start ="c1" | |
b1 = "-" | |
c1 = "o" | |
elif start == "b1" and choice == left: | |
if throw == True: | |
print("You were warned that you may not move off the board, and you have now fallen off the board.") | |
input("""What do you have to say for yourself? | |
ANSWER: """) | |
break | |
else: | |
pass | |
print("You may not move left from b1, as that would throw you off the board. Take care not to make any moves that would throw you off the board.") | |
throw = True | |
continue | |
elif start == "b1" and choice == right: | |
start = "b2" | |
b1 = "-" | |
b2 = "o" | |
elif start == "b2" and choice == up: | |
start = "a2" | |
b2 = "-" | |
a2 ="o" | |
elif start == "b2" and choice == down: | |
start = "c2" | |
b2 = "-" | |
c2 = "o" | |
elif start == "b2" and choice == left: | |
start = "b1" | |
b2 = "-" | |
b1 = "o" | |
elif start == "b2" and choice == right: | |
start = "b3" | |
b2 = "-" | |
b3 = "o" | |
elif start == "b3" and choice == up: | |
start = "a3" | |
b3 = "-" | |
a3 = "o" | |
elif start == "b3" and choice == down: | |
start = "c3" | |
b3 = "-" | |
c3 ="o" | |
elif start == "b3" and choice == left: | |
start = "b2" | |
b3 = "-" | |
b2 = "o" | |
elif start == "b3" and choice == right: | |
if throw == True: | |
print("You were warned that you may not move off the board, and you have now fallen off the board.") | |
input("""What do you have to say for yourself? | |
ANSWER: """) | |
break | |
else: | |
pass | |
print("You may not move right from b3, as that would throw you off the board. Take care not to make any moves that would throw you off the board.") | |
throw = True | |
continue | |
elif start == "c1" and choice == up: | |
start ="b1" | |
c1 = "-" | |
b1 = "o" | |
elif start == "c1" and choice == down: | |
if throw == True: | |
print("You were warned that you may not move off the board, and you have now fallen off the board.") | |
input("""What do you have to say for yourself? | |
ANSWER: """) | |
break | |
else: | |
pass | |
print("You may not move down from c1, as that would throw you off the board. Take care not to make any moves that would throw you off the board.") | |
throw = True | |
continue | |
elif start == "c1" and choice == left: | |
if throw == True: | |
print("You were warned that you may not move off the board, and you have now fallen off the board.") | |
input("""What do you have to say for yourself? | |
ANSWER: """) | |
break | |
else: | |
pass | |
print("You may not move left from c1, as that would throw you off the board. Take care not to make any moves that would throw you off the board.") | |
throw = True | |
continue | |
elif start == "c1" and choice == right: | |
start = "c2" | |
c1 = "-" | |
c2 = "o" | |
elif start == "c2" and choice == up: | |
start ="b2" | |
c2 = "-" | |
b2 = "o" | |
elif start == "c2" and choice == down: | |
if throw == True: | |
print("You were warned that you may not move off the board, and you have now fallen off the board.") | |
input("""What do you have to say for yourself? | |
ANSWER: """) | |
break | |
else: | |
pass | |
print("You may not move down from c2, as that would throw you off the board. Take care not to make any moves that would throw you off the board.") | |
throw = True | |
continue | |
elif start =="c2" and choice == left: | |
start = "c1" | |
c2 ="-" | |
c1 = "o" | |
elif start == "c2" and choice == right: | |
start = "c3" | |
c2 = "-" | |
c3 ="o" | |
elif start =="c3" and choice == up: | |
start ="b3" | |
c3 = "-" | |
b3 ="o" | |
elif start == "c3" and choice == down: | |
if throw == True: | |
print("You were warned that you may not move off the board, and you have now fallen off the board.") | |
input("""What do you have to say for yourself? | |
ANSWER: """) | |
break | |
else: | |
pass | |
print("You may not move down from c3, as that would throw you off the board. Take care not to make any moves that would throw you off the board.") | |
throw = True | |
continue | |
elif start == "c3" and choice == left: | |
start = "c2" | |
c3 = "-" | |
c2 = "o" | |
elif start =="c3" and choice == right: | |
if throw == True: | |
print("You were warned that you may not move off the board, and you have now fallen off the board.") | |
input("""What do you have to say for yourself? | |
ANSWER: """) | |
break | |
else: | |
pass | |
print("You may not move right from c4, as that would throw you off the board. Take care not to make any moves that would throw you off the board.") | |
throw = True | |
continue | |
else: | |
print("It appears you have given an invalid command. This program responds only to up, down, left, or right.") | |
print() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment