a norts and crosses game, currently has no win detection.
heres the code!
game = []
gameon = 1
d = 1
run = 2
x = 1
player = 1
qd = 1
##choose player name
while run > 1:
player1 = raw_input('player 1')
player2 = raw_input('player 2')
## choose table sise
while x > 0:
x = 1
sise = int(raw_input('sise?'))
if sise < 3:
print 'to small! _>3'
elif sise > 2:
x = 0
## construct gamebord
for fg in range(0,sise):
game.append(['?'])
for x in range(0,sise-1):
for fh in range(0,sise):
game[fh] = game[fh]+['?']
## draw table
for line in game:
print line
print
## main loop
while gameon>0:
if player == 1:
print player1
elif player == 2:
print player2
## player choose position
while qd in range(1,3):
placex = input('place x?')-1
placey = input('place y?')-1
## check if position is used
if game[placey][placex] =='x':
print
print 'used!'
elif game[placey][placex] =='O':
print
print 'used!'
elif game[placey][placex] == '?':
qd=4
qd=1
print
## add turn to the table
if player == 1:
game[placey][placex] = 'x'
elif player == 2:
game[placey][placex] = 'O'
## draw table and switch player
for line in game:
print line
print
if player == 1:
player = 2
elif player == 2:
player = 1
run = 0