Spaces:
Running
Running
show python action
Browse files- .prettierignore +1 -0
- src/components/rotation-controller.ts +14 -3
.prettierignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
rlcube/.venv/*
|
src/components/rotation-controller.ts
CHANGED
|
@@ -154,14 +154,25 @@ export class RotationController {
|
|
| 154 |
}
|
| 155 |
|
| 156 |
getStatus() {
|
| 157 |
-
|
| 158 |
-
|
| 159 |
const faceDirection = f as FacingDirection;
|
| 160 |
const cubes = this.getCubes(faceDirection);
|
| 161 |
const indices = cubes.map((cube) => this.getCubeFaceData(cube, faceDirection)).sort((a, b) => a.rank - b.rank);
|
| 162 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
return indices.map((i) => i.face.userData.faceColorIndex);
|
| 164 |
});
|
|
|
|
|
|
|
|
|
|
| 165 |
}
|
| 166 |
|
| 167 |
setCubeSpeed(cubeSpeed: number) {
|
|
|
|
| 154 |
}
|
| 155 |
|
| 156 |
getStatus() {
|
| 157 |
+
const rotationsPy: Array<string> = [];
|
| 158 |
+
const status = ['front', 'back', 'right', 'left', 'top', 'bottom'].map((f) => {
|
| 159 |
const faceDirection = f as FacingDirection;
|
| 160 |
const cubes = this.getCubes(faceDirection);
|
| 161 |
const indices = cubes.map((cube) => this.getCubeFaceData(cube, faceDirection)).sort((a, b) => a.rank - b.rank);
|
| 162 |
+
const positionNames = indices.map((i) => i.face.userData.name);
|
| 163 |
+
for (let i = 0; i < positionNames.length; i++) {
|
| 164 |
+
const positionName = positionNames[i];
|
| 165 |
+
if (positionName[0] !== f[0].toUpperCase() || positionName[1] !== i.toString()) {
|
| 166 |
+
rotationsPy.push(
|
| 167 |
+
`new_state[${f[0].toUpperCase()}, ${i}] = self.state[${positionName[0]}, ${positionName[1]}]`,
|
| 168 |
+
);
|
| 169 |
+
}
|
| 170 |
+
}
|
| 171 |
return indices.map((i) => i.face.userData.faceColorIndex);
|
| 172 |
});
|
| 173 |
+
console.log('Python Gym Step Code:');
|
| 174 |
+
console.log(rotationsPy.join('\n'));
|
| 175 |
+
return status;
|
| 176 |
}
|
| 177 |
|
| 178 |
setCubeSpeed(cubeSpeed: number) {
|