Added the boardgame tic-tac-toe without winning conditions, written entirely in Python.

This commit is contained in:
Kallfaktorn 2011-01-28 01:21:12 +01:00
parent 0590fa6ca1
commit affcb739b4
28 changed files with 448 additions and 0 deletions

View file

@ -0,0 +1,18 @@
from rectangle import Rectangle
from gamerectangle import GameRectangle
from math import sqrt
#param: nr_of_squares, dimensions(could be a Rectangle)
#creates an array of gamerectangles within itself with correct
#positions from each other
class Board(object):
def __init__(self, nr_of_rectangles, dimensions):
self.game_rectangles = []
axis = sqrt(nr_of_rectangles)
width = dimensions.width
height = dimensions.height
for index in range(nr_of_rectangles):
x = width * (index % axis)
y = height * int(index / axis)
gr = GameRectangle(index, x, y, width, height)
self.game_rectangles.append(gr)