-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new methods for Skewb and Pyraminx
- Loading branch information
1 parent
f3b434d
commit 8975f0d
Showing
6 changed files
with
117 additions
and
3 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from rubiks_cube_gym.envs.pyraminx_wo_tips import PyraminxWoTipsEnv | ||
import numpy as np | ||
from operator import itemgetter | ||
|
||
|
||
class PyraminxWoTipsEnvLBL(PyraminxWoTipsEnv): | ||
def __init__(self): | ||
super(PyraminxWoTipsEnvLBL, self).__init__() | ||
self.FL = None | ||
self.OLL = None | ||
|
||
def check_FL(self): | ||
for pos in FL_POS: | ||
if itemgetter(*pos)(self.cube_reduced) == itemgetter(*pos)("RRRRRGBBBBBRRRGGGBBBRGGGGGBYYYYYYYYY"): | ||
return True | ||
return False | ||
|
||
def check_solved(self): | ||
if self.cube_reduced == "RRRRRGBBBBBRRRGGGBBBRGGGGGBYYYYYYYYY": | ||
return True | ||
|
||
def reward(self): | ||
reward = -40 * self.FL | ||
done = False | ||
|
||
if self.check_FL(): | ||
reward += 40 | ||
self.FL = True | ||
else: | ||
self.FL = False | ||
|
||
if self.check_solved(): | ||
reward += 60 | ||
done = True | ||
|
||
if reward <= 0: | ||
reward -= 1 | ||
|
||
return reward, done | ||
|
||
def reset(self, scramble=None): | ||
super(PyraminxWoTipsEnvLBL, self).reset(scramble=scramble) | ||
self.FL = self.check_FL() | ||
|
||
return self.cube_state | ||
|
||
|
||
FL_POS = [[0, 1, 2, 3, 4, 11, 12, 13, 20, 5, 14, 15, 20, 21, 6, 7, 8, 9, 10, 27, 28, 32, 33, 35], | ||
[5, 14, 15, 16, 21, 22, 23, 24, 25, 3, 4, 12, 13, 20, 6, 7, 17, 18, 26, 27, 28, 29, 30, 31], | ||
[6, 7, 8, 9, 10, 17, 18, 19, 26, 5, 15, 16, 24, 25, 30, 31, 33, 34, 35, 0, 1, 2, 3, 4], | ||
[27, 28, 29, 30, 31, 32, 33, 34, 35, 21, 22, 23, 24, 25, 0, 1, 11, 12, 20, 9, 10, 18, 19, 26]] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from rubiks_cube_gym.envs.skewb import SkewbEnv | ||
import numpy as np | ||
from operator import itemgetter | ||
|
||
|
||
class SkewbEnvSarah(SkewbEnv): | ||
def __init__(self): | ||
super(SkewbEnvSarah, self).__init__() | ||
self.FL = None | ||
|
||
def check_FL(self): | ||
for pos in FL_POS: | ||
if itemgetter(*pos)(self.cube_reduced) == itemgetter(*pos)("WWWWWOOOOOGGGGGRRRRRBBBBBYYYYY"): | ||
return True | ||
return False | ||
|
||
def check_solved(self): | ||
if self.cube_reduced == "WWWWWOOOOOGGGGGRRRRRBBBBBYYYYY": | ||
return True | ||
|
||
def reward(self): | ||
reward = -40 * self.FL | ||
done = False | ||
|
||
if self.check_FL(): | ||
reward += 40 | ||
self.FL = True | ||
else: | ||
self.FL = False | ||
|
||
if self.check_solved(): | ||
reward += 60 | ||
done = True | ||
|
||
if reward <= 0: | ||
reward -= 1 | ||
|
||
return reward, done | ||
|
||
def reset(self, scramble=None): | ||
super(SkewbEnvSarah, self).reset(scramble=scramble) | ||
self.FL = self.check_FL() | ||
|
||
return self.cube_state | ||
|
||
|
||
FL_POS = [[0, 1, 2, 3, 4, 5, 6, 10, 11, 15, 16, 20, 21], [5, 6, 7, 8, 9, 0, 3, 10, 13, 25, 28, 21, 24], | ||
[10, 11, 12, 13, 14, 3, 4, 15, 18, 25, 26, 6, 9], [15, 16, 17, 18, 19, 1, 4, 20, 23, 26, 29, 11, 14], | ||
[20, 21, 22, 23, 24, 16, 19, 28, 29, 5, 8, 0, 1], [25, 26, 27, 28, 29, 8, 9, 13, 14, 18, 19, 23, 24]] |
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