repl.it
@VesterDE/

FinalProjectEdits4

Python (with Turtle)

No description

fork
loading
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import turtle

t = turtle
t.speed(0)

def square(x,y):
  t.up()
  t.goto(x,y)
  t.down()
  for i in range(4):
    t.forward(100)
    t.left(90)

def drawGrid():
  for i in range(3):
    for j in range(3):
      square(i * 100, j*100)

def cross(x,y):
  size = 40
  t.penup()
  t.goto(x+50,y+50)
  t.pendown()
  t.right(45)
  t.forward(size)
  t.backward(size * 2)
  t.forward(size)
  t.left(90)
  t.forward(size)
  t.backward(size * 2)
  t.forward(40)
  t.right(45)

def circle(x,y):
  size = 25
  t.penup()
  t.goto(x+50,y+50)
  t.right(90)
  t.forward(25)
  t.left(90)
  t.pendown()
  t.circle(size)

def ticTacToe(roundNumber, ):
  player = (roundNumber % 2) + 1
  print "Player ", str(player)+".", "Choose a square. (Round ", str(roundNumber)+")"
  chosenSquare = int(input(emptyspots))
  spot = coordinates[chosenSquare - 1]
  emptyspots.remove(chosenSquare)
  if player == 1:
    cross(spot[0], spot[1])
  else:
    circle(spot[0], spot[1])
  ticTacToe(roundNumber+1)

emptyspots = [1,2,3,4,6,7,8,9]
crossSpots = []
circleSpots = []
coordinates = [
  [0,0], 
  [100,0],
  [200,0],
  [0,100],
  [100,100],
  [200,100],
  [0,200],
  [100,200],
  [200,200]
]

drawGrid()
print("Are you ready to play? YES/NO")
answer = input("Enter yes or no: ")
if answer == "yes":
  ticTacToe(0)
elif answer == "no":
  print("Have a nice day")

result
console
?