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
import itertools | |
class Board(object): | |
def __init__(self): | |
self.rows = [[' ', ' ', ' '], [' ', ' ', ' '], [' ', ' ', ' ']] | |
@property | |
def diagonals(self): |
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
#Implementation of Two Player Tic-Tac-Toe game in Python. | |
''' We will make the board using dictionary | |
in which keys will be the location(i.e : top-left,mid-right,etc.) | |
and initialliy it's values will be empty space and then after every move | |
we will change the value according to player's choice of move. ''' | |
theBoard = {'7': ' ' , '8': ' ' , '9': ' ' , | |
'4': ' ' , '5': ' ' , '6': ' ' , | |
'1': ' ' , '2': ' ' , '3': ' ' } |
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
#!/usr/bin/python3 | |
# Simple TicTacToe game in Python - EAO | |
import random | |
import sys | |
board=[i for i in range(0,9)] | |
player, computer = '','' | |
# Corners, Center and Others, respectively | |
moves=((1,7,3,9),(5,),(2,4,6,8)) |
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
def display_board(board): | |
for i in range(3): | |
print " ", | |
for j in range(3): | |
if board[i*3+j] == 1: | |
print 'X', | |
elif board[i*3+j] == 0: |
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
#Implementation of Two Player Tic-Tac-Toe game in Python. | |
''' We will make the board using dictionary | |
in which keys will be the location(i.e : top-left,mid-right,etc.) | |
and initialliy it's values will be empty space and then after every move | |
we will change the value according to player's choice of move. ''' | |
theBoard = {'7': ' ' , '8': ' ' , '9': ' ' , | |
'4': ' ' , '5': ' ' , '6': ' ' , | |
'1': ' ' , '2': ' ' , '3': ' ' } |