Skip to content

Instantly share code, notes, and snippets.

@teaualune
Created October 16, 2014 12:12
Show Gist options
  • Save teaualune/37893b5384aec90a2db1 to your computer and use it in GitHub Desktop.
Save teaualune/37893b5384aec90a2db1 to your computer and use it in GitHub Desktop.
# 宣告變數
if 1:
import random
EmptyBoard = [[0,0,0,0,0,0],[0,0,0,0,0,0],[0,0,0,0,0,0],[0,0,0,0,0,0],[0,0,0,0,0,0]]
Board = [[1, 2, 2, 2, 1, 1], [1, 2, 1, 2, 2, 2], [1, 2, 2, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 2, 1, 2, 2]]
CancelBoard = EmptyBoard
Comboing = 0
Comboed =0
ComboOrb = 0
NextComboBool = 1
RowCounter = 0
RowCancelBool =0
ElementPowerBase = [0,0,0,0,0,0,0,0,0]
ElementPowerOrb = [0,0,0,0,0,0,0,0,0]
ElementComboTimes = [0,0,0,0,0,0,0,0,0]
ElementRowCancel = [0,0,0,0,0,0,0,0,0]
# 迴圈
while NextComboBool == 1:
NextComboBool = 0
for c in range(1,9):
CancelBoard = EmptyBoard
for i in range(3):
for j in range(6):
if (Board[i][j]==c and (Board[i+1][j]==c and Board[i+2][j]==c)):
for k in range(3):
CancelBoard[i+k][j] = 1
for i in range(5):
for j in range(4):
if (Board[i][j]==c and (Board[i][j+1]==c and Board[i][j+2]==c)):
for k in range(3):
CancelBoard[i][j+k] = 1
for i in range(5):
for j in range(6):
if CancelBoard[i][j] == 1:
CancelBoard[i][j] = 2
for a in range(9):
for i2 in range(5):
for j2 in range(6):
if CancelBoard[i2][j2] == 2:
for k1 in [-1,1]:
for k2 in [-1,1]:
if ((i2+k1 > -1) and (i2+k1 < 5)):
if CancelBoard[i2+k1][j2] ==1:
CancelBoard[i2+k1][j2] =2
if ((j2+k2 > -1) and (j2+k2 < 6)):
if CancelBoard[i2][j2+k2] ==1:
CancelBoard[i2][j2+k2] =2
for i2 in range(5):
for j2 in range(6):
if CancelBoard[i2][j2]==2:
ComboOrb += 1
CancelBoard[i2][j2]==0
Board[i2][j2] = 0
RowCounter += 1
if RowCounter == 6:
RowCancelBool =1
RowCounter = 0
ElementPowerOrb[c] += 0.25*(ComboOrb+1)
ComboOrb = 0
ElementComboTimes[c] +=1
NextComboBool = 1
if RowCancelBool ==1:
ElementRowCancel[c] += 1
RowCancelBool = 0
for i in range(5):
Board[i]
print '-------------------------'
if NextComboBool ==1:
for i in range(1,5):
for j in range(6):
if Board[i][j] == 0:
for k in range(i,0,-1):
Board[k][j] = Board[k-1][j]
Board[0][j] = 0
for i in range(5):
Board[i]
print '-------------------------'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment