Created
February 17, 2022 09:38
-
-
Save Nekodigi/973a93f88849a70b45d3e57abb2b853c 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
#genshin puzzle solver | |
def solve(state): | |
chain = [] | |
for lim in range(15): | |
for i in range(len(state)): | |
#print(i) | |
res = solve_(state.copy(), i+1, chain.copy(), lim) | |
if res != None: | |
return res | |
def solve_(state, attack, chain, lim): | |
chain.append(attack) | |
#print(attack) | |
attack -= 1 | |
if change[attack] is not None: | |
for i in change[attack]:#if change is None? | |
state[i-1] += 1 | |
state[i-1] = state[i-1] % 4 | |
if len(chain)<=lim: | |
#print(state, chain) | |
if all(val == state[0] for val in state): | |
return state, chain | |
else: | |
for i in range(len(state)): | |
res = solve_(state.copy(), i+1, chain.copy(), lim) | |
if res != None: | |
return res | |
else: | |
pass | |
state = [0,2,2,0,3]#state 0~3 | |
change = [[1,2],[1,2,3],[3,4],[4,5],[5,1]]# | |
print(solve(state)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment