Skip to content

Instantly share code, notes, and snippets.

@hdorothea
hdorothea / tictactoe.py
Created August 21, 2016 02:16
A simple tic-tac-toe game in Python
import itertools
class Board(object):
def __init__(self):
self.rows = [[' ', ' ', ' '], [' ', ' ', ' '], [' ', ' ', ' ']]
@property
def diagonals(self):
@jamesshah
jamesshah / tictactoe.py
Last active March 28, 2022 07:06
TicTacToe Game implemented in python3
#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': ' ' }
@simrit1
simrit1 / tictactoe.py
Created March 28, 2022 07:03 — forked from eaorak/tictactoe.py
Python - TicTacToe Game
#!/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))
@simrit1
simrit1 / Tix-tac-toe
Created March 28, 2022 07:05 — forked from pgaijin66/Tix-tac-toe
simple Tic tac toe game made in python
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:
@simrit1
simrit1 / tictactoe.py
Created March 28, 2022 07:06 — forked from jamesshah/tictactoe.py
TicTacToe Game implemented in python3
#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': ' ' }