Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def check(opt, choice):
- if opt[0][0] == choice and opt[0][1] == choice and opt[0][2] == choice:
- return 1;
- if opt[1][0] == choice and opt[1][1] == choice and opt[1][2] == choice:
- return 1;
- if opt[2][0] == choice and opt[2][1] == choice and opt[2][2] == choice:
- return 1;
- if opt[0][0] == choice and opt[1][1] == choice and opt[2][2] == choice:
- return 1;
- if opt[0][2] == choice and opt[1][1] == choice and opt[2][0] == choice:
- return 1;
- if opt[0][0] == choice and opt[1][0] == choice and opt[2][0] == choice:
- return 1;
- if opt[0][1] == choice and opt[1][1] == choice and opt[2][1] == choice:
- return 1;
- if opt[0][2] == choice and opt[1][2] == choice and opt[2][2] == choice:
- return 1;
- p = 2
- xo = [['+','+','+'],['+','+','+'],['+','+','+']]
- wins = [0,0]
- play = 'y'
- while play == 'y':
- p = p+1
- if p % 2 == 1:
- player = 1
- ch = 'X'
- else:
- player = 2
- ch = 'O'
- print 'Player 1:', wins[0], '| Player 2:', wins[1]
- for i in xo:
- print '\t', i[0], i[1], i[2]
- print 'Player:', player, '[' + ch + ']:'
- c = input('>>> ')
- f = c/10 - 1;
- l = c%10 - 1;
- while xo[f][l] != '+':
- c = input('>>> ')
- xo[f][l] = ch
- if check(xo, ch):
- wins[player-1] = wins[player-1] + 1
- xo = [['+','+','+'],['+','+','+'],['+','+','+']]
- play = raw_input('Play again?[y/n]: ')
Advertisement
Add Comment
Please, Sign In to add comment