Skip to content

Commit

Permalink
update(cli): add --raw argument and infos
Browse files Browse the repository at this point in the history
  • Loading branch information
luckasRanarison committed Apr 24, 2024
1 parent ae74b3f commit ab8ad30
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

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

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ three-style search --gen RUE --edges UF UB LF --depth 5
# shorter versions
three-style search -g RUD -c UFR UBL RFD -d 4
three-style search -g RUE -e UF UB LF -d 5

three-style help
```

> [!NOTE]
> Depth is relative to the length of the commutator in its notation form.
> Depth is relative to the length of the commutator in its notation form and expanded commutators are reduced by default, meaning cancellations are taken into account.
## Concept

Expand Down
2 changes: 1 addition & 1 deletion three-style-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ readme = "../README.md"

[dependencies]
clap = { version = "4.5.1", features = ["derive", "color"] }
three-style-lib = "0.1.1"
three-style-lib = "0.1.2"
25 changes: 13 additions & 12 deletions three-style-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ impl Cli {
edges,
gen,
depth,
raw,
}) = self.command
{
let allowed_moves = gen
Expand All @@ -46,7 +47,7 @@ impl Cli {
};
let end = Instant::now();

print_commutators(commutators, end - start);
print_commutators(commutators, end - start, raw);
}

Ok(())
Expand All @@ -62,17 +63,20 @@ enum Command {
.args(&["corners", "edges"]),
))]
Search {
#[arg(long, short, num_args(3))]
#[arg(long, short, num_args(3), help = "Corner cycle")]
corners: Option<Vec<String>>,

#[arg(long, short, num_args(3))]
#[arg(long, short, num_args(3), help = "Edge cycle")]
edges: Option<Vec<String>>,

#[arg(long, short)]
#[arg(long, short, help = "Allwed movesets")]
gen: String,

#[arg(long, short)]
#[arg(long, short, help = "Maximum search depth")]
depth: u8,

#[arg(long, short, help = "Display the non-reduced algorithm")]
raw: bool,
},
}

Expand Down Expand Up @@ -106,21 +110,18 @@ fn search_edge_commutators(
Ok(results)
}

fn print_commutators(commutators: Vec<Commutator>, duration: Duration) {
fn print_commutators(commutators: Vec<Commutator>, duration: Duration, raw: bool) {
let count = commutators.len();
let duration = duration.as_secs_f32();
let green = Style::new().fg_color(Some(Color::Ansi(AnsiColor::Green)));

for comm in commutators {
let bold = Style::new().bold();
let cyan = Style::new().fg_color(Some(Color::Ansi(AnsiColor::Cyan)));
let alg = comm.expand();
let alg = if raw { alg } else { alg.reduce() };

println!(
"{bold}{}{bold:#}: {} {cyan}({}){cyan:#}",
comm,
comm.expand(),
comm.expand().len()
);
println!("{bold}{comm}{bold:#}: {alg} {cyan}({}){cyan:#}", alg.len());
}

if count > 0 {
Expand Down

0 comments on commit ab8ad30

Please sign in to comment.