Created
March 7, 2021 08:11
-
-
Save okayshankha/cbdde5565387efd00ec1c34e236ca9a2 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
Selector:= white | |
Foreach black tile b | |
do h(b):= tile-distance to the first white tile to its right | |
Foreach white tile w | |
do h(w):= tile-distance to the first black tile to its left * -1 | |
While any tile has a non-zero h value | |
Do | |
If selector:= white then, | |
Select the while-tile with the highest h value, say X | |
If the h(X):= 0 and it does not have the blank space to its left then, | |
Select another while-tile with the next-highest h value, say X | |
Selector := black | |
Else | |
Select the black-tile with the highest h value, say X | |
If the h(X):= 0 and it does not have the blank space to its left then, | |
Select another black-tile with the next-highest h value, say X | |
Selector:= white | |
If X and the blank space is in 2-tiles distance then, | |
Move X to the blank space and record the cost | |
Foreach black tile b | |
do h(b):= tile-distance to the first white tile to its right | |
Foreach white tile w | |
do h(w):= tile-distance to the first black tile to its left * -1 | |
End while |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
can you share java or python implementation on this that help me a lots? plz