| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316 |
- a = "a"
- b = "b"
- c = "c"
- A = [a,b,c]
- B = []
- C = []
- aloc = ""
- bloc = ""
- cloc = ""
- def error():
- print("Error: You cant do this move.")
- #--------------------a-----------------------------------------------------#
- def a_location():
- global a
- global b
- global c
- global A
- global B
- global C
- global aloc
-
- if a in A:
- aloc = "A"
- return aloc
- elif a in B:
- aloc = "B"
- return aloc
- elif a in C:
- aloc = "C"
- return aloc
- def a_bewegen():
- global a
- global b
- global c
- global A
- global B
- global C
- global aloc
- global bloc
- global cloc
- if aloc == bloc or aloc == cloc:
- error()
- return
- elif aloc == "A":
- move = input("Wohin möchtest du a bewegen? (B/C) ")
- if move == "A":
- error()
- return
- elif aloc == "B":
- move = input("Where do you want to move? (A/C) ")
- if move == "B":
- error()
- return
- elif aloc == "C":
- move = input("Where do you want to move? (A/B) ")
- if move == "C":
- error()
- return
- if move == "A":
- if cloc == "A" or bloc == "A":
- error()
- return
- else:
- A.append(a)
- if aloc == "B":
- B.remove(a)
- elif aloc == "C":
- C.remove(a)
- elif move == "B":
- if cloc == "B" or bloc == "B":
- error()
- return
- else:
- B.append(a)
- if aloc == "A":
- A.remove(a)
- elif aloc == "C":
- C.remove(a)
- elif move == "C":
- if cloc == "C" or bloc == "C":
- error()
- return
- else:
- C.append(a)
- if aloc == "A":
- A.remove(a)
- elif aloc == "B":
- B.remove(a)
-
- #--------------------b-----------------------------------------------------#
- def b_location():
- global a
- global b
- global c
- global A
- global B
- global C
- global bloc
- if b in A:
- bloc = "A"
- return bloc
- elif b in B:
- bloc = "B"
- return bloc
- elif b in C:
- bloc = "C"
- return bloc
- def b_bewegen():
- global a
- global b
- global c
- global A
- global B
- global C
- global aloc
- global bloc
- global cloc
- if bloc == cloc :
- print("You can't move this.")
- return
- elif bloc == "A":
- move = input("Wohin möchtest du a bewegen? (B/C) ")
- if move == "A":
- error()
- return
- elif bloc == "B":
- move = input("Where do you want to move? (A/C) ")
- if move == "B":
- error()
- return
- elif bloc == "C":
- move = input("Where do you want to move? (A/B) ")
- if move == "C":
- error()
- return
- if move == "A":
- if cloc == "A":
- error()
- return
- else:
- A.append(b)
- if bloc == "B":
- B.remove(b)
- elif bloc == "C":
- C.remove(b)
- elif move == "B":
- if cloc == "B":
- error()
- return
- else:
- B.append(b)
- if bloc == "A":
- A.remove(b)
- elif bloc == "C":
- C.remove(b)
- elif move == "C":
- if cloc == "C":
- error()
- return
- else:
- C.append(b)
- if bloc == "A":
- A.remove(b)
- elif bloc == "B":
- B.remove(b)
- #--------------------c-----------------------------------------------------#
- def c_location():
- global a
- global b
- global c
- global A
- global B
- global C
- global aloc
- global bloc
- global cloc
- if c in A:
- cloc = "A"
- return cloc
- elif c in B:
- cloc = "B"
- return cloc
- elif c in C:
- cloc = "C"
- return cloc
- def c_bewegen():
- global a
- global b
- global c
- global A
- global B
- global C
- global cloc
- if cloc == "A":
- move = input("Wohin möchtest du a bewegen? (B/C) ")
- if move == "A":
- error()
- elif cloc == "B":
- move = input("Where do you want to move? (A/C) " )
- if move == "B":
- error()
- elif cloc == "C":
- move = input("Where do you want to move? (A/B) ")
- if move == "C":
- error()
- if move == "A":
- if cloc == "A":
- error()
- return
- else:
- A.append(c)
- if cloc == "B":
- B.remove(c)
- elif cloc == "C":
- C.remove(c)
- elif move == "B":
- if cloc == "B":
- error()
- return
- else:
- B.append(c)
- if cloc == "A":
- A.remove(c)
- elif cloc == "C":
- C.remove(c)
- elif move == "C":
- if cloc == "C":
- error()
- return
- else:
- C.append(c)
- if cloc == "A":
- A.remove(c)
- elif cloc == "B":
- B.remove(c)
- #----------------------------------Schleife-------------------------------------------#
- def game():
- while True:
- global a
- global b
- global c
- global A
- global B
- global C
- global aloc
- global bloc
- global cloc
- a_location()
- b_location()
- c_location()
- print("Plates:")
- print(" a -> large, b -> middle, c -> small")
- print(A)
- print(B)
- print(C)
- choose_move = input("Which plate do you want to move? (a/b/c) " )
- if choose_move == "a":
- a_bewegen()
- elif choose_move == "b":
- b_bewegen()
- elif choose_move == "c":
- c_bewegen()
- else:
- "unvalid input."
- #End of game
- if C == [a,b,c]:
- print("You solved the game! Congratulations!")
- trigger = input("Do you want to play again? (y/n) ")
- if trigger == "y":
- #Variabel reset
- A = [a,b,c]
- B = []
- C = []
- aloc = ""
- bloc = ""
- cloc = ""
- #Lauching game
- game()
- elif trigger == "n":
- break
- else:
- return
- game()
|