support colour reinsert after resets, switch to intrinsics by default

This commit is contained in:
atagen 2024-12-05 22:19:43 +11:00
parent a4bf011cb0
commit 7146615e04
6 changed files with 54 additions and 33 deletions

View file

@ -28,30 +28,30 @@ let to_sixteen f = ints 0 |> take 16 |> f |> Array.of_seq
let permute (order : order) (colours : colour array) =
let open Array in
let make_simple = map (fun i -> Simple i) in
let make_intrinsic = map (fun i -> Intrinsic i) in
match order with
| Explicit e ->
let clen = length colours in
e
|> map (fun index ->
if index < clen then colours.(index) else Simple index)
if index < clen then colours.(index) else Intrinsic index)
| RainbowPair ->
[| 1; 9; 3; 11; 2; 10; 6; 14; 4; 12; 5; 13; 7; 15 |] |> make_simple
[| 1; 9; 3; 11; 2; 10; 6; 14; 4; 12; 5; 13; 7; 15 |] |> make_intrinsic
| RainbowSplit ->
[| 1; 3; 2; 6; 4; 5; 9; 11; 10; 14; 12; 13; 7; 15 |] |> make_simple
[| 1; 3; 2; 6; 4; 5; 9; 11; 10; 14; 12; 13; 7; 15 |] |> make_intrinsic
| TonePair ->
let open Seq in
let lows = ints 1 |> take 8 in
let highs = lows |> map (fun i -> i + 8) in
interleave lows highs |> Array.of_seq |> make_simple
interleave lows highs |> Array.of_seq |> make_intrinsic
| Straight ->
let open Seq in
ints 0 |> take 16 |> Array.of_seq |> make_simple
ints 0 |> take 16 |> Array.of_seq |> make_intrinsic
| Default ->
let open Seq in
ints 0 |> take 16
|> filter (fun i -> not (i = 0 || i = 8))
|> Array.of_seq |> make_simple
|> Array.of_seq |> make_intrinsic
| Random ->
Random.self_init ();
shuffle ~rand:Random.int colours;
@ -60,7 +60,7 @@ let permute (order : order) (colours : colour array) =
let get_colours =
let colours = get_env_colours
and order = get_env_order
and init_default_colours = to_sixteen (map (fun x -> Types.Simple x))
and init_default_colours = to_sixteen (map (fun x -> Types.Intrinsic x))
and init_order_for_colours c =
let open Seq in
ints 0 |> take (Array.length c) |> Array.of_seq