A visible solver to water sort puzzle base on python.
To get this game: App Store | Google Play
Game:
Solver:
... ...
Click HERE and wait for 1 minute to get into an online environment for free!
After get into this ↑ environment, you need to Shift + Enter to execute this block first to install matplotlib
Then use Shift + Enter to execute this block to get the Solver's result
Finally you can get the results!
We define the state of current by these Label of colors:
Then you can define a status like this:
bottle_state = [
[PU,YE,PI,PI],
[PU,YE,PU,YE],
[PI,PU,YE,PI],
[],
[],
]
Then let the Solver to give you the solutions:
solve_puzzle(bottle_state)
You can customize the process and outputs by rewriting this function:
Or if you can ignore this if you don't understand it
def solve_puzzle(bottle_state):
pvb = PlotableVialBoard(bottle_state) # Initialize
solved_pvb = solve(pvb) # Solve puzzle
paths = solved_pvb.path # Save Solution
# Print out Solution:
new_pvb = pvb.clone()
print('Origin Status:')
new_pvb.show()
for n, path in enumerate(paths):
print('Step %d: %d --> %d' % (n+1, path[0]+1, path[1]+1))
new_pvb.move(*path)
new_pvb.show()
print()
Download:
git clone https://github.com/wjfjfm/water_sort_puzzle.git
Install jupyter notebook (Skip this if you already installed):
pip install jupyter
Use jupyter notebook to to open this page
cd water_sort_puzzle && jupyter notebook water-sort-puzzle-solver.ipynb