cleanup
This commit is contained in:
@@ -30,11 +30,9 @@ def normalGame(p1,p2):
|
|||||||
return [p1,p2]
|
return [p1,p2]
|
||||||
|
|
||||||
def recurseGame(p1,p2,n):
|
def recurseGame(p1,p2,n):
|
||||||
print("start subgame of level "+str(n))
|
|
||||||
rounds = []
|
rounds = []
|
||||||
while len(p1) > 0 and len(p2) > 0:
|
while len(p1) > 0 and len(p2) > 0:
|
||||||
if [p1,p2] in rounds:
|
if [p1,p2] in rounds:
|
||||||
print("subgame level " + str(n) + " has ended")
|
|
||||||
return [p1,[]]
|
return [p1,[]]
|
||||||
if p1[0] <= len(p1)-1 and p2[0] <= len(p2)-1:
|
if p1[0] <= len(p1)-1 and p2[0] <= len(p2)-1:
|
||||||
res = recurseGame(copy.deepcopy(p1[1:(p1[0]+1)]),copy.deepcopy(p2[1:(p2[0]+1)]),n+1)
|
res = recurseGame(copy.deepcopy(p1[1:(p1[0]+1)]),copy.deepcopy(p2[1:(p2[0]+1)]),n+1)
|
||||||
@@ -55,7 +53,6 @@ def recurseGame(p1,p2,n):
|
|||||||
rounds.append([copy.deepcopy(p1),copy.deepcopy(p2)])
|
rounds.append([copy.deepcopy(p1),copy.deepcopy(p2)])
|
||||||
p1 = res[0]
|
p1 = res[0]
|
||||||
p2 = res[1]
|
p2 = res[1]
|
||||||
print("subgame level "+str(n)+" has ended")
|
|
||||||
return[p1,p2]
|
return[p1,p2]
|
||||||
|
|
||||||
|
|
||||||
@@ -79,4 +76,4 @@ scnorm = calcScore(norm[0]) if len(norm[0])>0 else calcScore(norm[1])
|
|||||||
rec = recurseGame(copy.deepcopy(p1),copy.deepcopy(p2),0)
|
rec = recurseGame(copy.deepcopy(p1),copy.deepcopy(p2),0)
|
||||||
screc = calcScore(rec[0]) if len(rec[0])>0 else calcScore(rec[1])
|
screc = calcScore(rec[0]) if len(rec[0])>0 else calcScore(rec[1])
|
||||||
print("Normal game winner has score of " + str(scnorm))
|
print("Normal game winner has score of " + str(scnorm))
|
||||||
print("Recursive game winner has score of " + str(screc))
|
print("Recursive game winner has score of " + str(screc))
|
||||||
|
|||||||
Reference in New Issue
Block a user