Collect results from previous versions in a README.
This commit is contained in:
parent
5b0a1716b5
commit
f14dab9547
|
@ -1,55 +1,66 @@
|
||||||
# benchmarks
|
# (No Fib) Benchmarks
|
||||||
|
|
||||||
Write validators in the `validators` folder, and supporting functions in the `lib` folder using `.ak` as a file extension.
|
This folder contains a set of benchmarks inspired and ported from the [plutus-benchmarks](https://github.com/IntersectMBO/plutus/tree/master/plutus-benchmark/nofib#plutus-nofib-benchmarks), written in Haskell. The idea is to provide benchmarks which can capture more realistic patterns and behaviours than usual "Fibonacci" benchmarks often used for benchmarking applications but falling short in capturing real-world scenarios.
|
||||||
|
|
||||||
For example, as `validators/always_true.ak`
|
Note that the primary use-case of those benchmarks is to compare Aiken with itself across compiler versions. As optimizations get implemented, it comes as a supplimentary means to assess their impact.
|
||||||
|
|
||||||
```gleam
|
## Summary
|
||||||
validator {
|
|
||||||
fn spend(_datum: Data, _redeemer: Data, _context: Data) -> Bool {
|
|
||||||
True
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Building
|
Results are summarized below, relatively to the previous version. For brevity, we only report versions for which there's a deviation from a previous version.
|
||||||
|
|
||||||
```sh
|
<!--
|
||||||
aiken build
|
v1.0.29-alpha & v1.0.28-alpha
|
||||||
```
|
┍━ benchmarks/knights ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||||
|
│ PASS [mem: 172256715, cpu: 71851995726] bench_knights_100_4x4
|
||||||
|
│ PASS [mem: 321712271, cpu: 159767368294] bench_knights_100_6x6
|
||||||
|
│ PASS [mem: 601065675, cpu: 319834775948] bench_knights_100_8x8
|
||||||
|
┕━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3 tests | 3 passed | 0 failed
|
||||||
|
|
||||||
## Testing
|
==== There's no 1.0.27-alpha
|
||||||
|
|
||||||
You can write tests in any module using the `test` keyword. For example:
|
v1.0.26-alpha & V1.0.25-alpha
|
||||||
|
┍━ benchmarks/knights ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||||
|
│ PASS [mem: 171421863, cpu: 72861467671] bench_knights_100_4x4
|
||||||
|
│ PASS [mem: 354137347, cpu: 174027736310] bench_knights_100_6x6
|
||||||
|
│ PASS [mem: 688090183, cpu: 356296429240] bench_knights_100_8x8
|
||||||
|
┕━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3 tests | 3 passed | 0 failed
|
||||||
|
|
||||||
```gleam
|
v1.0.24-alpha & V1.0.23-alpha
|
||||||
test foo() {
|
┍━ benchmarks/knights ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||||
1 + 1 == 2
|
│ PASS [mem: 180946463, cpu: 75052125671] bench_knights_100_4x4
|
||||||
}
|
│ PASS [mem: 374910247, cpu: 178805503310] bench_knights_100_6x6
|
||||||
```
|
│ PASS [mem: 729107683, cpu: 365730454240] bench_knights_100_8x8
|
||||||
|
┕━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3 tests | 3 passed | 0 failed
|
||||||
|
|
||||||
To run all tests, simply do:
|
==== There's no 1.0.22-alpha
|
||||||
|
|
||||||
```sh
|
V1.0.21-alpha
|
||||||
aiken check
|
┍━ benchmarks/knights ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||||
```
|
│ PASS [mem: 180697463, cpu: 74944457471] bench_knights_100_4x4
|
||||||
|
│ PASS [mem: 374661247, cpu: 178697835110] bench_knights_100_6x6
|
||||||
|
│ PASS [mem: 728858683, cpu: 365622786040] bench_knights_100_8x8
|
||||||
|
┕━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3 tests | 3 passed | 0 failed
|
||||||
|
|
||||||
To run only tests matching the string `foo`, do:
|
V1.0.20-alpha, v1.0.19-alpha & v1.0.18-alpha
|
||||||
|
┍━ benchmarks/knights ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||||
|
│ PASS [mem: 182244075, cpu: 75300076471] bench_knights_100_4x4
|
||||||
|
│ PASS [mem: 380548699, cpu: 180051720110] bench_knights_100_6x6
|
||||||
|
│ PASS [mem: 740194031, cpu: 368229509040] bench_knights_100_8x8
|
||||||
|
┕━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3 tests | 3 passed | 0 failed
|
||||||
|
-->
|
||||||
|
|
||||||
```sh
|
### CPU
|
||||||
aiken check -m foo
|
|
||||||
```
|
|
||||||
|
|
||||||
## Documentation
|
| Benchmark | `v1.0.29` | vs `v1.0.25` | vs `v1.0.23` | vs `v1.0.21` | vs `v1.0.18` |
|
||||||
|
| --- | ---: | ---: | ---: | ---: | ---: |
|
||||||
|
| `knights_100_4x4` | 71851995726 | +1.40% | +4.45% | +4.30% | +4.80% |
|
||||||
|
| `knights_100_6x6` | 159767368294 | +8.93% | +11.92% | +11.85% | +12.70% |
|
||||||
|
| `knights_100_8x8` | 319834775948 | +11.40% | +14.35% | +14.32% | +15.13% |
|
||||||
|
|
||||||
If you're writing a library, you might want to generate an HTML documentation for it.
|
### Mem
|
||||||
|
|
||||||
Use:
|
| Benchmark | `v1.0.29` | vs `v1.0.25` | vs `v1.0.23` | vs `v1.0.21` | vs `v1.0.18` |
|
||||||
|
| --- | ---: | ---: | ---: | ---: | ---: |
|
||||||
```sh
|
| `knights_100_4x4` | 172256715 | -0.48% | +5.04% | +4.90% | +5.80% |
|
||||||
aiken docs
|
| `knights_100_6x6` | 321712271 | +10.08% | +16.54% | +16.46% | +18.29% |
|
||||||
```
|
| `knights_100_8x8` | 601065675 | +14.48% | +21.30% | +21.26% | +23.15% |
|
||||||
|
|
||||||
## Resources
|
|
||||||
|
|
||||||
Find more on the [Aiken's user manual](https://aiken-lang.org).
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ fn done(item: (Int, ChessSet)) -> Bool {
|
||||||
|
|
||||||
// ------------------------------------------------------------------ Fixtures
|
// ------------------------------------------------------------------ Fixtures
|
||||||
|
|
||||||
fn solution_100_6x6() {
|
fn solution_100_6x6() -> Solution {
|
||||||
[
|
[
|
||||||
(
|
(
|
||||||
0,
|
0,
|
||||||
|
@ -268,7 +268,7 @@ fn solution_100_6x6() {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn solution_100_8x8() {
|
fn solution_100_8x8() -> Solution {
|
||||||
[
|
[
|
||||||
(
|
(
|
||||||
0,
|
0,
|
||||||
|
@ -278,32 +278,36 @@ fn solution_100_8x8() {
|
||||||
start: Some((1, 1)),
|
start: Some((1, 1)),
|
||||||
visited: [
|
visited: [
|
||||||
(3, 2),
|
(3, 2),
|
||||||
(5, 3),
|
|
||||||
(4, 5),
|
|
||||||
(5, 7),
|
|
||||||
(7, 6),
|
|
||||||
(8, 8),
|
|
||||||
(6, 7),
|
|
||||||
(5, 5),
|
|
||||||
(3, 4),
|
|
||||||
(1, 5),
|
|
||||||
(2, 7),
|
|
||||||
(4, 8),
|
|
||||||
(3, 6),
|
|
||||||
(1, 7),
|
|
||||||
(3, 8),
|
|
||||||
(4, 6),
|
|
||||||
(6, 5),
|
|
||||||
(4, 4),
|
(4, 4),
|
||||||
(5, 6),
|
(5, 6),
|
||||||
(6, 4),
|
(6, 4),
|
||||||
(7, 2),
|
(8, 5),
|
||||||
|
(7, 7),
|
||||||
|
(6, 5),
|
||||||
(8, 4),
|
(8, 4),
|
||||||
|
(7, 2),
|
||||||
|
(5, 3),
|
||||||
|
(3, 4),
|
||||||
|
(4, 6),
|
||||||
|
(5, 8),
|
||||||
|
(6, 6),
|
||||||
|
(4, 5),
|
||||||
|
(3, 7),
|
||||||
|
(1, 8),
|
||||||
|
(2, 6),
|
||||||
|
(4, 7),
|
||||||
|
(5, 5),
|
||||||
(6, 3),
|
(6, 3),
|
||||||
(5, 1),
|
(5, 1),
|
||||||
(4, 3),
|
(4, 3),
|
||||||
(3, 5),
|
(3, 5),
|
||||||
(5, 4),
|
(5, 4),
|
||||||
|
(7, 3),
|
||||||
|
(8, 1),
|
||||||
|
(6, 2),
|
||||||
|
(4, 1),
|
||||||
|
(2, 2),
|
||||||
|
(1, 4),
|
||||||
(3, 3),
|
(3, 3),
|
||||||
(2, 5),
|
(2, 5),
|
||||||
(1, 3),
|
(1, 3),
|
||||||
|
@ -314,31 +318,27 @@ fn solution_100_8x8() {
|
||||||
(7, 4),
|
(7, 4),
|
||||||
(8, 6),
|
(8, 6),
|
||||||
(7, 8),
|
(7, 8),
|
||||||
(6, 6),
|
(5, 7),
|
||||||
(8, 5),
|
(3, 8),
|
||||||
(7, 7),
|
(1, 7),
|
||||||
(5, 8),
|
(3, 6),
|
||||||
(3, 7),
|
(2, 8),
|
||||||
(1, 8),
|
(1, 6),
|
||||||
(2, 6),
|
(2, 4),
|
||||||
(1, 4),
|
(1, 2),
|
||||||
(2, 2),
|
(3, 1),
|
||||||
(4, 1),
|
|
||||||
(6, 2),
|
|
||||||
(8, 1),
|
|
||||||
(7, 3),
|
|
||||||
(5, 2),
|
(5, 2),
|
||||||
(7, 1),
|
(7, 1),
|
||||||
(8, 3),
|
(8, 3),
|
||||||
(7, 5),
|
(7, 5),
|
||||||
(8, 7),
|
(8, 7),
|
||||||
(6, 8),
|
(6, 8),
|
||||||
(4, 7),
|
(7, 6),
|
||||||
(2, 8),
|
(8, 8),
|
||||||
(1, 6),
|
(6, 7),
|
||||||
(2, 4),
|
(4, 8),
|
||||||
(1, 2),
|
(2, 7),
|
||||||
(3, 1),
|
(1, 5),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
(1, 1),
|
(1, 1),
|
||||||
],
|
],
|
||||||
|
@ -352,32 +352,36 @@ fn solution_100_8x8() {
|
||||||
start: Some((1, 1)),
|
start: Some((1, 1)),
|
||||||
visited: [
|
visited: [
|
||||||
(3, 2),
|
(3, 2),
|
||||||
(5, 3),
|
|
||||||
(4, 5),
|
|
||||||
(5, 7),
|
|
||||||
(7, 6),
|
|
||||||
(8, 8),
|
|
||||||
(6, 7),
|
|
||||||
(4, 8),
|
|
||||||
(2, 7),
|
|
||||||
(1, 5),
|
|
||||||
(3, 4),
|
|
||||||
(5, 5),
|
|
||||||
(3, 6),
|
|
||||||
(1, 7),
|
|
||||||
(3, 8),
|
|
||||||
(4, 6),
|
|
||||||
(6, 5),
|
|
||||||
(4, 4),
|
(4, 4),
|
||||||
(5, 6),
|
(5, 6),
|
||||||
|
(7, 7),
|
||||||
|
(8, 5),
|
||||||
(6, 4),
|
(6, 4),
|
||||||
(7, 2),
|
(7, 2),
|
||||||
(8, 4),
|
(8, 4),
|
||||||
|
(6, 5),
|
||||||
|
(5, 3),
|
||||||
|
(3, 4),
|
||||||
|
(4, 6),
|
||||||
|
(5, 8),
|
||||||
|
(6, 6),
|
||||||
|
(4, 5),
|
||||||
|
(3, 7),
|
||||||
|
(1, 8),
|
||||||
|
(2, 6),
|
||||||
|
(4, 7),
|
||||||
|
(5, 5),
|
||||||
(6, 3),
|
(6, 3),
|
||||||
(5, 1),
|
(5, 1),
|
||||||
(4, 3),
|
(4, 3),
|
||||||
(3, 5),
|
(3, 5),
|
||||||
(5, 4),
|
(5, 4),
|
||||||
|
(7, 3),
|
||||||
|
(8, 1),
|
||||||
|
(6, 2),
|
||||||
|
(4, 1),
|
||||||
|
(2, 2),
|
||||||
|
(1, 4),
|
||||||
(3, 3),
|
(3, 3),
|
||||||
(2, 5),
|
(2, 5),
|
||||||
(1, 3),
|
(1, 3),
|
||||||
|
@ -388,184 +392,101 @@ fn solution_100_8x8() {
|
||||||
(7, 4),
|
(7, 4),
|
||||||
(8, 6),
|
(8, 6),
|
||||||
(7, 8),
|
(7, 8),
|
||||||
(6, 6),
|
(5, 7),
|
||||||
(8, 5),
|
(3, 8),
|
||||||
(7, 7),
|
(1, 7),
|
||||||
(5, 8),
|
(3, 6),
|
||||||
(3, 7),
|
(2, 8),
|
||||||
(1, 8),
|
(1, 6),
|
||||||
(2, 6),
|
(2, 4),
|
||||||
(1, 4),
|
(1, 2),
|
||||||
(2, 2),
|
(3, 1),
|
||||||
(4, 1),
|
|
||||||
(6, 2),
|
|
||||||
(8, 1),
|
|
||||||
(7, 3),
|
|
||||||
(5, 2),
|
|
||||||
(7, 1),
|
|
||||||
(8, 3),
|
|
||||||
(7, 5),
|
|
||||||
(8, 7),
|
|
||||||
(6, 8),
|
|
||||||
(4, 7),
|
|
||||||
(2, 8),
|
|
||||||
(1, 6),
|
|
||||||
(2, 4),
|
|
||||||
(1, 2),
|
|
||||||
(3, 1),
|
|
||||||
(2, 3),
|
|
||||||
(1, 1),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
),
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
fn solution_80_8x8() {
|
|
||||||
[
|
|
||||||
(
|
|
||||||
0,
|
|
||||||
ChessSet {
|
|
||||||
size: 8,
|
|
||||||
move_number: 64,
|
|
||||||
start: Some((1, 1)),
|
|
||||||
visited: [
|
|
||||||
(3, 2),
|
|
||||||
(5, 3),
|
|
||||||
(4, 5),
|
|
||||||
(5, 7),
|
|
||||||
(7, 6),
|
|
||||||
(8, 8),
|
|
||||||
(6, 7),
|
|
||||||
(5, 5),
|
|
||||||
(3, 4),
|
|
||||||
(1, 5),
|
|
||||||
(2, 7),
|
|
||||||
(4, 8),
|
|
||||||
(3, 6),
|
|
||||||
(1, 7),
|
|
||||||
(3, 8),
|
|
||||||
(4, 6),
|
|
||||||
(6, 5),
|
|
||||||
(4, 4),
|
|
||||||
(5, 6),
|
|
||||||
(6, 4),
|
|
||||||
(7, 2),
|
|
||||||
(8, 4),
|
|
||||||
(6, 3),
|
|
||||||
(5, 1),
|
|
||||||
(4, 3),
|
|
||||||
(3, 5),
|
|
||||||
(5, 4),
|
|
||||||
(3, 3),
|
|
||||||
(2, 5),
|
|
||||||
(1, 3),
|
|
||||||
(2, 1),
|
|
||||||
(4, 2),
|
|
||||||
(6, 1),
|
|
||||||
(8, 2),
|
|
||||||
(7, 4),
|
|
||||||
(8, 6),
|
|
||||||
(7, 8),
|
|
||||||
(6, 6),
|
|
||||||
(8, 5),
|
|
||||||
(7, 7),
|
|
||||||
(5, 8),
|
|
||||||
(3, 7),
|
|
||||||
(1, 8),
|
|
||||||
(2, 6),
|
|
||||||
(1, 4),
|
|
||||||
(2, 2),
|
|
||||||
(4, 1),
|
|
||||||
(6, 2),
|
|
||||||
(8, 1),
|
|
||||||
(7, 3),
|
|
||||||
(5, 2),
|
|
||||||
(7, 1),
|
|
||||||
(8, 3),
|
|
||||||
(7, 5),
|
|
||||||
(8, 7),
|
|
||||||
(6, 8),
|
|
||||||
(4, 7),
|
|
||||||
(2, 8),
|
|
||||||
(1, 6),
|
|
||||||
(2, 4),
|
|
||||||
(1, 2),
|
|
||||||
(3, 1),
|
|
||||||
(2, 3),
|
|
||||||
(1, 1),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
0,
|
|
||||||
ChessSet {
|
|
||||||
size: 8,
|
|
||||||
move_number: 64,
|
|
||||||
start: Some((1, 1)),
|
|
||||||
visited: [
|
|
||||||
(3, 2),
|
|
||||||
(5, 3),
|
|
||||||
(4, 5),
|
|
||||||
(5, 7),
|
|
||||||
(7, 6),
|
|
||||||
(8, 8),
|
|
||||||
(6, 7),
|
|
||||||
(4, 8),
|
|
||||||
(2, 7),
|
|
||||||
(1, 5),
|
|
||||||
(3, 4),
|
|
||||||
(5, 5),
|
|
||||||
(3, 6),
|
|
||||||
(1, 7),
|
|
||||||
(3, 8),
|
|
||||||
(4, 6),
|
|
||||||
(6, 5),
|
|
||||||
(4, 4),
|
|
||||||
(5, 6),
|
|
||||||
(6, 4),
|
|
||||||
(7, 2),
|
|
||||||
(8, 4),
|
|
||||||
(6, 3),
|
|
||||||
(5, 1),
|
|
||||||
(4, 3),
|
|
||||||
(3, 5),
|
|
||||||
(5, 4),
|
|
||||||
(3, 3),
|
|
||||||
(2, 5),
|
|
||||||
(1, 3),
|
|
||||||
(2, 1),
|
|
||||||
(4, 2),
|
|
||||||
(6, 1),
|
|
||||||
(8, 2),
|
|
||||||
(7, 4),
|
|
||||||
(8, 6),
|
|
||||||
(7, 8),
|
|
||||||
(6, 6),
|
|
||||||
(8, 5),
|
|
||||||
(7, 7),
|
|
||||||
(5, 8),
|
|
||||||
(3, 7),
|
|
||||||
(1, 8),
|
|
||||||
(2, 6),
|
|
||||||
(1, 4),
|
|
||||||
(2, 2),
|
|
||||||
(4, 1),
|
|
||||||
(6, 2),
|
|
||||||
(8, 1),
|
|
||||||
(7, 3),
|
|
||||||
(5, 2),
|
(5, 2),
|
||||||
(7, 1),
|
(7, 1),
|
||||||
(8, 3),
|
(8, 3),
|
||||||
(7, 5),
|
(7, 5),
|
||||||
(8, 7),
|
(8, 7),
|
||||||
(6, 8),
|
(6, 8),
|
||||||
|
(7, 6),
|
||||||
|
(8, 8),
|
||||||
|
(6, 7),
|
||||||
|
(4, 8),
|
||||||
|
(2, 7),
|
||||||
|
(1, 5),
|
||||||
|
(2, 3),
|
||||||
|
(1, 1),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
0,
|
||||||
|
ChessSet {
|
||||||
|
size: 8,
|
||||||
|
move_number: 64,
|
||||||
|
start: Some((1, 1)),
|
||||||
|
visited: [
|
||||||
|
(3, 2),
|
||||||
|
(4, 4),
|
||||||
|
(6, 5),
|
||||||
|
(8, 4),
|
||||||
|
(7, 2),
|
||||||
|
(5, 3),
|
||||||
|
(3, 4),
|
||||||
|
(4, 6),
|
||||||
|
(5, 8),
|
||||||
|
(7, 7),
|
||||||
|
(5, 6),
|
||||||
|
(6, 4),
|
||||||
|
(8, 5),
|
||||||
|
(6, 6),
|
||||||
|
(4, 5),
|
||||||
|
(3, 7),
|
||||||
|
(1, 8),
|
||||||
|
(2, 6),
|
||||||
(4, 7),
|
(4, 7),
|
||||||
|
(5, 5),
|
||||||
|
(6, 3),
|
||||||
|
(5, 1),
|
||||||
|
(4, 3),
|
||||||
|
(3, 5),
|
||||||
|
(5, 4),
|
||||||
|
(7, 3),
|
||||||
|
(8, 1),
|
||||||
|
(6, 2),
|
||||||
|
(4, 1),
|
||||||
|
(2, 2),
|
||||||
|
(1, 4),
|
||||||
|
(3, 3),
|
||||||
|
(2, 5),
|
||||||
|
(1, 3),
|
||||||
|
(2, 1),
|
||||||
|
(4, 2),
|
||||||
|
(6, 1),
|
||||||
|
(8, 2),
|
||||||
|
(7, 4),
|
||||||
|
(8, 6),
|
||||||
|
(7, 8),
|
||||||
|
(5, 7),
|
||||||
|
(3, 8),
|
||||||
|
(1, 7),
|
||||||
|
(3, 6),
|
||||||
(2, 8),
|
(2, 8),
|
||||||
(1, 6),
|
(1, 6),
|
||||||
(2, 4),
|
(2, 4),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(3, 1),
|
(3, 1),
|
||||||
|
(5, 2),
|
||||||
|
(7, 1),
|
||||||
|
(8, 3),
|
||||||
|
(7, 5),
|
||||||
|
(8, 7),
|
||||||
|
(6, 8),
|
||||||
|
(7, 6),
|
||||||
|
(8, 8),
|
||||||
|
(6, 7),
|
||||||
|
(4, 8),
|
||||||
|
(2, 7),
|
||||||
|
(1, 5),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
(1, 1),
|
(1, 1),
|
||||||
],
|
],
|
||||||
|
|
|
@ -133,11 +133,11 @@ fn possible_moves(board: ChessSet) -> List<Direction> {
|
||||||
direction_list() |> list.filter(can_move(board, _))
|
direction_list() |> list.filter(can_move(board, _))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn compare_tile(a: Tile, b: Tile) -> Ordering {
|
fn compare_chess_set(a: (Int, ChessSet), b: (Int, ChessSet)) -> Ordering {
|
||||||
if a.1st == b.1st {
|
if a.1st != b.1st {
|
||||||
int.compare(a.2nd, b.2nd)
|
|
||||||
} else {
|
|
||||||
int.compare(a.1st, b.1st)
|
int.compare(a.1st, b.1st)
|
||||||
|
} else {
|
||||||
|
compare_list(a.2nd.visited, b.2nd.visited)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,37 +163,10 @@ fn compare_list(xs: List<Tile>, ys: List<Tile>) -> Ordering {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn compare_chess_set(a: (Int, ChessSet), b: (Int, ChessSet)) -> Ordering {
|
fn compare_tile(a: Tile, b: Tile) -> Ordering {
|
||||||
if a.1st != b.1st {
|
if a.1st == b.1st {
|
||||||
|
int.compare(a.2nd, b.2nd)
|
||||||
|
} else {
|
||||||
int.compare(a.1st, b.1st)
|
int.compare(a.1st, b.1st)
|
||||||
} else {
|
|
||||||
let ChessSet {
|
|
||||||
size: size_a,
|
|
||||||
move_number: move_a,
|
|
||||||
start: start_a,
|
|
||||||
visited: visited_a,
|
|
||||||
} = a.2nd
|
|
||||||
let ChessSet {
|
|
||||||
size: size_b,
|
|
||||||
move_number: move_b,
|
|
||||||
start: start_b,
|
|
||||||
visited: visited_b,
|
|
||||||
} = b.2nd
|
|
||||||
if size_a != size_b {
|
|
||||||
int.compare(size_a, size_b)
|
|
||||||
} else if move_a != move_b {
|
|
||||||
int.compare(move_a, move_b)
|
|
||||||
} else if start_a != start_b {
|
|
||||||
when start_a is {
|
|
||||||
Some(a) ->
|
|
||||||
when start_b is {
|
|
||||||
Some(b) -> compare_tile(a, b)
|
|
||||||
None -> Greater
|
|
||||||
}
|
|
||||||
None -> Less
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
compare_list(visited_a, visited_b)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue