Created
March 1, 2017 19:58
-
-
Save guilhermemauro/6781b5e4fc19caa37761618e9aa6b437 to your computer and use it in GitHub Desktop.
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
#get the player play and write in game board (tic.game). | |
def getPlayer(points, frame): | |
global choose_user, init, last_time, player | |
hW,wW = frame.shape[0:2] | |
cv2.line(frame,(0,hW-25),(wW,hW-25),(35,35,155),25) | |
cv2.putText(frame, "Jogador, escolha uma jogada.",(150, hW-20), FONTE, 0.7,(0,255,0),2,cv2.LINE_AA) | |
field_key = 0 | |
gameboard = np.array(tic.game[0]+tic.game[1]+tic.game[2]) | |
indexs = np.where(gameboard == 0)[0] | |
for field in points: | |
cropped = getField(field, frame) | |
cnt = getContoursHSV(cropped) | |
value = compareContourHSV(cnt) | |
old_played = np.where(indexs== field_key)[0] | |
if value != False and init == False and len(old_played) == 1: | |
print "Achou nova jogada! Aguarde 3 segundos." | |
last_time = int(time.time()) | |
init = True | |
if value != False and int(time.time()) - last_time > 3 and init == True and len(old_played) == 1: | |
print "Jogada player:", field_key | |
tic.writePosition(field_key, value) | |
init = False | |
choose_user = False | |
return tic.verifyWinner(value) | |
field_key += 1 | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment