Last active
December 28, 2015 06:59
-
-
Save sublee/7461207 to your computer and use it in GitHub Desktop.
페리아 연대기, 고대의 언어 파이선으로 기록한 틱태토 게임 로직 (http://youtu.be/UVRBsrXvGNg?t=5m)
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
# 틱택토 게임 로직 | |
# 2013. 10. | |
import nt | |
def newBoard(): | |
return [[0,0,0], | |
[0,0,0],[0,0,0],] | |
count = 0 | |
board = newBoard() | |
player = 1 | |
def onMsg(**args): | |
global board | |
global count | |
global player | |
if count == 0: | |
count = 0 | |
player = 1 | |
board = newBoard() | |
return '리셋' | |
r = args['행'] - 1 | |
c = args['열'] - 1 | |
if board[c][r]: | |
return '' | |
board[c][r] = player | |
player = 3 - player | |
count = count + 1 | |
if checkGameSet(): | |
count = 9 | |
return '표시' + ('X', '0')[player - 1] \ | |
+ str(c + 1) + ',' + str(r + 1) | |
def checkRow(c): | |
return 0 != board[c][0] == board[c][1] == board[c][2] | |
def checkCol(r): | |
return 0 != board[0][r] == board[1][r] == board[2][r] | |
def checkDiag(): | |
return 0 != board[0][0] == board[1][1] == board[2][2] \ | |
or 0 != board[0][2] == board[1][1] == board[2][0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment