You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.2 KiB
Python
52 lines
1.2 KiB
Python
import fiar
|
|
|
|
game = fiar.FIAR();
|
|
|
|
def declareWinner():
|
|
game.printField();
|
|
print("And the winner is P", game.proveWinner(), "!")
|
|
|
|
|
|
def isnumber(val):
|
|
try:
|
|
val = int(val)
|
|
return True
|
|
except ValueError:
|
|
return False
|
|
|
|
|
|
while True:
|
|
game.printField();
|
|
|
|
player_input = input("P1, where do you put your stone? ")
|
|
|
|
while not (isnumber(player_input) and 7 >= int(player_input) >= 1):
|
|
player_input = input("P1, your input has to be a number between 1 and 7! New input: ")
|
|
|
|
try:
|
|
game.setStone(int(player_input)-1, 1);
|
|
except OverflowError:
|
|
print("This Column is already full, maybe try again next time...")
|
|
|
|
if(game.proveWinner()):
|
|
declareWinner()
|
|
break
|
|
|
|
# --------------- #
|
|
|
|
game.printField();
|
|
|
|
player_input = input("P2, where do you put your stone? ")
|
|
|
|
while not (isnumber(player_input) and 7 >= int(player_input) >= 1):
|
|
player_input = input("P2, your input has to be a number between 1 and 7! New input: ")
|
|
|
|
try:
|
|
game.setStone(int(player_input)-1, 2);
|
|
except OverflowError:
|
|
print("This Column is already full, maybe try again next time...")
|
|
|
|
if(game.proveWinner()):
|
|
declareWinner()
|
|
break
|