/
guessWho.py
47 lines (37 loc) · 1.07 KB
/
guessWho.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import random as rand
class GuessWho:
playerTurn = 0
faceUpFigures = []
playerFigures = []
def __init__(self, dataHandler):
# Player 1 = 0
# Player 2 = 1
playerTurn = 0
# Access player 1:
# faceUpFigures[0]
# Access player 2:
# faceUpFigures[1]
indices = range(0,dataHandler.numFigures)
faceUpFigures = indices + indices
# Access player 1:
# playerFigures[0]
# Access player 2:
# playerFigures[1]
playerFigures = [0,0]
while playerFigures[0] == playerFigures[1]:
playerFigures = [rand.randInt(0,dataHandler.numFigures-1),
rand.randInt(0,dataHandler.numFigures-1)]
def playTurn(self,question):
# Question is a tuple consisting of:
# (COLUMN_INDEX,COLUMN_VALUE)
# Column values shall be mapped to corresponding integers
# for RL algorithm to be more flexible. This mapping shall
# be done in the DataHandler.
data = dataHandler.getData()
# TODO: Return true if correct, otherwise false and update game
if playerTurn == 0:
playerTurn = 1
else:
playerTurn = 0