Skip to content

Commit

Permalink
Update cubing for derivedMoves fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarron committed Aug 28, 2023
1 parent bd9ad02 commit 15ead0e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 48 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/cpp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
[dependencies]
clap = { version = "4.3.24", features = ["derive"] }
clap_complete = "4.3.2"
cubing = "0.7.1"
cubing = "0.7.2"
cxx = "1.0.106"
lazy_static = "1.4.0"
num_cpus = "1.16.0"
Expand Down
2 changes: 1 addition & 1 deletion src/rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ default = []
cityhash = "0.1.1"
clap = { version = "4.3.24", features = ["derive"] }
clap_complete = "4.3.2"
cubing = "0.7.1"
cubing = "0.7.2"
derive_more = "0.99.17"
indicatif = "0.17.6"
serde = { version = "1.0.186", features = ["derive", "rc"] }
Expand Down
65 changes: 21 additions & 44 deletions src/rs/packed/orientation_packer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,57 +132,34 @@ impl OrientationPacker {
#[cfg(test)]
mod tests {
use cubing::kpuzzle::{
KPattern, KPatternData, KPatternOrbitData, KPuzzle, KPuzzleDefinition,
KPuzzleOrbitDefinition, KPuzzleOrbitName, KTransformationData, KTransformationOrbitData,
KPattern, KPatternData, KPatternOrbitData, KPuzzle, KPuzzleDefinition, KPuzzleOrbitName,
};
use std::collections::HashMap;
use std::sync::Arc;

use crate::PackedKPuzzle;

// TODO: Return a `Result`.
#[test]
fn orientation_mod() {
let def = KPuzzleDefinition {
name: "custom".to_owned(),
orbits: vec![KPuzzleOrbitDefinition {
orbit_name: "PIECES".into(),
num_pieces: 2,
num_orientations: 12,
}],
default_pattern: KPatternData::from([(
KPuzzleOrbitName("PIECES".into()),
KPatternOrbitData {
pieces: vec![0, 1],
orientation: vec![0, 0],
orientation_mod: Some(vec![3, 4]),
},
)])
.into(),
moves: HashMap::from([
(
"SPIN".try_into().unwrap(),
Arc::new(KTransformationData::from([(
KPuzzleOrbitName("PIECES".to_owned()),
KTransformationOrbitData {
permutation: vec![0, 1], // TODO: is this actually L'?
orientation_delta: vec![2, 5],
},
)])),
),
(
"SWAP".try_into().unwrap(),
Arc::new(KTransformationData::from([(
KPuzzleOrbitName("PIECES".to_owned()),
KTransformationOrbitData {
permutation: vec![1, 0], // TODO: is this actually R'?
orientation_delta: vec![0, 0],
},
)])),
),
]),
derived_moves: None,
};
let def: KPuzzleDefinition = serde_json::from_str(
r#"
{
"name": "custom",
"orbits": [{ "orbitName": "PIECES", "numPieces": 2, "numOrientations": 12 }],
"defaultPattern": {
"PIECES": {
"pieces": [0, 1],
"orientation": [0, 0],
"orientationMod": [3, 4]
}
},
"moves": {
"SWAP": { "PIECES": { "permutation": [1, 0], "orientationDelta": [0, 0] } },
"SPIN": { "PIECES": { "permutation": [0, 1], "orientationDelta": [2, 5] } }
},
"derivedMoves": null
}"#,
)
.unwrap();
let kpuzzle = KPuzzle::try_new(def).unwrap();
let packed_kpuzzle = PackedKPuzzle::try_from(kpuzzle.clone()).unwrap();

Expand Down

0 comments on commit 15ead0e

Please sign in to comment.