Created
June 8, 2014 14:17
-
-
Save soardex/047b0f6392b59aaccd14 to your computer and use it in GitHub Desktop.
Reel check and save combinations
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
#!/usr/bin/env python | |
# Specifications: | |
# - 5x3 reel | |
# - left-to-right checking | |
# Winning Combinations: | |
# TOP TOP TOP TOP TOP | |
# MID MID MID MID MID | |
# BOT BOT BOT BOT BOT | |
# TOP MID BOT MID TOP | |
# BOT MID TOP MID BOT | |
# TOP + - TOP - + - TOP - + - TOP - + - TOP | |
# + - MID - + - BOT - + - MID - + - TOP | |
# | |
# MID + - MID - + - MID - + - MID - + - MID | |
# | |
# + - MID - + - TOP - + - MID - + - BOT | |
# BOT + - BOT - + - BOT - + - BOT - + - BOT | |
R1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 2] | |
R2 = [1, 1, 2, 4, 5, 0, 1, 7, 9, 8, 6, 0] | |
R3 = [0, 2, 4, 6, 6, 5, 7, 9, 8, 2, 1, 0] | |
R4 = [0, 2, 4, 6, 6, 5, 7, 9, 8, 2, 1, 0] | |
R5 = [0, 2, 4, 6, 6, 5, 7, 9, 8, 2, 1, 0] | |
ze = -1 | |
count = 0 | |
stack = [] | |
def main(): | |
for r1 in range(0, len(R1)): | |
u1 = len(R1) + (r1 - 1) if r1 - 1 < 0 else r1 - 1 | |
u2 = r1 | |
u3 = (r1 + 1) - len(R2) if r1 + 1 > len(R1) - 1 else r1 + 1 | |
va = [] | |
checkR2(va, u1, 'TOP') | |
checkR2(va, u2, 'MID') | |
checkR2(va, u3, 'BOT') | |
print 'Total Win Combination: ' + str(count) | |
for index, item in enumerate(stack): | |
print 'Combination ' + str(index) + ': ' \ | |
+ ', '.join(str(x) for x in item) | |
def checkR2(va, a, seq): | |
va.append(a) | |
for r2 in range(0, len(R2)): | |
u1 = len(R2) + (r2 - 1) if r2 - 1 < 0 else r2 - 1 | |
u2 = r2 | |
u3 = (r2 + 1) - len(R2) if r2 + 1 > len(R2) - 1 else r2 + 1 | |
if seq == 'TOP': | |
compareR2(va, a, u1, 'TOP') | |
compareR2(va, a, u2, 'MID') | |
elif seq == 'MID': | |
compareR2(va, a, u2, 'MID') | |
elif seq == 'BOT': | |
compareR2(va, a, u2, 'MID') | |
compareR2(va, a, u3, 'BOT') | |
def compareR2(va, a, b, seq): | |
if R1[a] == R2[b]: | |
va.append(b) | |
checkR3(va, b, seq) | |
def checkR3(va, a, seq): | |
for r3 in range(0, len(R3)): | |
u1 = len(R3) + (r3 - 1) if r3 - 1 < 0 else r3 - 1 | |
u2 = r3 | |
u3 = (r3 + 1) - len(R3) if r3 + 1 > len(R3) - 1 else r3 + 1 | |
if seq == 'TOP': | |
compareR3(va, a, u1, 'TOP') | |
elif seq == 'MID': | |
compareR3(va, a, u1, 'TOP') | |
compareR3(va, a, u2, 'MID') | |
compareR3(va, a, u3, 'BOT') | |
elif seq == 'BOT': | |
compareR3(va, a, u3, 'BOT') | |
def compareR3(va, a, b, seq): | |
if R2[a] == R3[b]: | |
va.append(b) | |
checkR4(va, b, seq) | |
def checkR4(va, a, seq): | |
for r4 in range(0, len(R4)): | |
u1 = len(R4) + (r4 - 1) if r4 - 1 < 0 else r4 - 1 | |
u2 = r4 | |
u3 = (r4 + 1) - len(R4) if r4 + 1 > len(R4) - 1 else r4 + 1 | |
if seq == 'TOP': | |
compareR4(va, a, u1, 'TOP') | |
compareR4(va, a, u2, 'MID') | |
elif seq == 'MID': | |
compareR4(va, a, u2, 'MID') | |
elif seq == 'BOT': | |
compareR4(va, a, u2, 'MID') | |
compareR4(va, a, u3, 'BOT') | |
def compareR4(va, a, b, seq): | |
if R3[a] == R4[b]: | |
va.append(b) | |
checkR5(va, b, seq) | |
def checkR5(va, a, seq): | |
for r5 in range(0, len(R5)): | |
u1 = len(R5) + (r5 - 1) if r5 - 1 < 0 else r5 - 1 | |
u2 = r5 | |
u3 = (r5 + 1) - len(R5) if r5 + 1 > len(R5) - 1 else r5 + 1 | |
if seq == 'TOP': | |
compareR5(va, a, u1, 'TOP') | |
compareR5(va, a, u2, 'MID') | |
elif seq == 'MID': | |
compareR5(va, a, u2, 'MID') | |
elif seq == 'BOT': | |
compareR5(va, a, u2, 'MID') | |
compareR5(va, a, u3, 'BOT') | |
def compareR5(va, a, b, seq): | |
global stack | |
global count | |
if R4[a] == R5[b]: | |
va.append(b) | |
value = [R1[va[0]], R2[va[1]], R3[va[2]], R4[va[3]], R5[va[4]]] | |
stack.append(value) | |
count = count + 1 | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment