Commit Graph

156 Commits

Author SHA1 Message Date
Aryadev Chavali
0839d188ec game:deck: new module for deck management
- construct empty or decks composed of n "decks" of cards
- sort by standard ordering or suit ordering, and shuffle them using
  an RNG
- get, add, remove
- deal from the tail of a deck, or from any sequence of indices

This API will be the cornerstone of how games are managed.
2026-04-16 18:38:59 +01:00
Aryadev Chavali
33d86682be game: new module for game API 2026-04-16 18:36:18 +01:00
Aryadev Chavali
e327d61a18 helper: comment change 2026-04-16 18:35:59 +01:00
Aryadev Chavali
15efa4e1b5 big-c: update for new task 2026-04-16 12:06:16 +01:00
Aryadev Chavali
6ab30cf1a1 exactsizearr: No need for default constraint on items of the ESI input 2026-04-16 11:46:55 +01:00
Aryadev Chavali
79366d60fe *: small refactors and test changes 2026-04-16 11:46:55 +01:00
Aryadev Chavali
f1d26acb0b card:impls:rank: new iter_rest function 2026-04-16 11:46:55 +01:00
Aryadev Chavali
980c7ca58b modes:triple:tests: Implement ordering and footstool tests for triples
Painful.  I hate testing with a passion.  I find it so difficult to
not be exhaustive since single pattern's aren't enough, but at the
level of complexity for triples it's actually getting computationally
difficult (read: takes a few seconds) to do.
2026-04-14 22:52:35 +01:00
Aryadev Chavali
a2df7cb58d modes:pair:tests: remove ordering test
Literally just makes my ordering frigid.  It's just testing the EXACT
same condition as how ordering is impl'd anyway.  What a useless test.
2026-04-14 22:52:35 +01:00
Aryadev Chavali
f3d0d6dab2 modes:*: Implement Hand::high_card on consumers. 2026-04-14 22:52:35 +01:00
Aryadev Chavali
25511443a5 modes:mod: Hand::high_card
A way to return the high card of any one hand for quick comparison.
2026-04-14 22:52:35 +01:00
Aryadev Chavali
e72f8b2c3a card:impls: *::iter_all and *::cards now return arrays
We know the sizes of the results of these functions beforehand.
Fitting it into an ESI was a code smell really.  Just return the
arrays!  Of course, now we need to do array::into_iter for iterator
use, but this is way better.

Excluding Card::iter_all since we can't know the size of it at compile
time.  PITA that we can't make it an ESI either.
2026-04-14 22:52:35 +01:00
Aryadev Chavali
0bab322f3a modes:{pair,triple}:tests: refinement 2026-04-14 22:52:35 +01:00
Aryadev Chavali
5d3e83d79c zipcartesian: rewording for cleanliness 2026-04-14 22:52:35 +01:00
Aryadev Chavali
8f4f72d0fd zipcartesian: minor spelling mistake 2026-04-14 22:52:35 +01:00
Aryadev Chavali
d2d7e5d805 modes:triple:tests: finish new test. 2026-04-14 22:52:35 +01:00
Aryadev Chavali
881e5988b2 modes:triple: refine footstool condition 2026-04-14 22:52:35 +01:00
Aryadev Chavali
8282bd877a modes:pair:tests: use zip_cartesian and simplify tests. 2026-04-14 22:52:35 +01:00
Aryadev Chavali
501410f725 modes:single:tests: use zip_cartesian and Card::into_iter 2026-04-14 22:52:35 +01:00
Aryadev Chavali
51f15c4b0a card:tests: use zip_cartesian. 2026-04-14 22:52:35 +01:00
Aryadev Chavali
334d9d1b6a card:impls: *:iter_all and {Rank,Suit}::cards implement Clone.
Bit of a shame, but necessary for using ZipCartesian on them.
2026-04-14 22:52:35 +01:00
Aryadev Chavali
f98b151c61 zipcartesian: iterator that does a cartesian product on two iterators
Essentially just encodes the flatmap of two iterators being tupled
together.  Different to just a standard zip.

Unfortunately we do need the second iterator to implement Clone as we
clone it for each item of the first iterator to generate the flat_map.

Type tetris masturbation has reached a new high here.
2026-04-14 22:52:35 +01:00
Aryadev Chavali
d8e8682ce7 helper: split out ExactSizeArr into its own module 2026-04-14 22:52:35 +01:00
Aryadev Chavali
414e523ba4 *: move from /*** */ doc-comments to /// 2026-04-14 22:52:35 +01:00
Aryadev Chavali
2d0e98c7f4 card: excessively simple card iterator 2026-04-14 22:52:35 +01:00
Aryadev Chavali
f1a26592ec big-c: update 2026-04-14 22:52:35 +01:00
Aryadev Chavali
364738eb94 modes:triple: finish ordering and footstools for Triples 2026-04-14 22:52:35 +01:00
Aryadev Chavali
b6d22a03ef card:tests: cleanliness 2026-04-14 22:52:35 +01:00
Aryadev Chavali
6e94f05443 modes:pair: use impl_cmp_eq_on_ord macro for ordering. 2026-04-14 22:52:35 +01:00
Aryadev Chavali
76f180d4c6 helper: macro to generate Eq,PartialEq,PartialOrd impls for an Ord type. 2026-04-14 22:52:35 +01:00
Aryadev Chavali
ddfb137fb1 card:tests: use Card::is_joker 2026-04-14 22:52:35 +01:00
Aryadev Chavali
6a4860643f modes:triple: better Triple::new
Using Card::rank we can do something similar to Pair::new.
2026-04-14 22:52:35 +01:00
Aryadev Chavali
d993f72958 modes:pair: refactor using new functions
- Better modelling for Pair::new using Card::rank optional.
- Ordering uses ~Ordering::then_with~ which maps to our previous
  pattern (cleaner)
2026-04-14 22:52:35 +01:00
Aryadev Chavali
e85f8b69d0 card:impls: Card::{is_joker,playing_card,rank,suit} 2026-04-14 22:52:35 +01:00
Aryadev Chavali
7646327f9d modes:triple:tests: start implementing tests 2026-04-14 22:52:35 +01:00
Aryadev Chavali
77fac27369 modes:triple: make new public 2026-04-14 22:52:35 +01:00
Aryadev Chavali
d538ab1600 modes:triple: ordering done 2026-04-14 22:52:35 +01:00
Aryadev Chavali
d8235b6edd modes:triple: new file encoding a Triple with new implemented
Not a difficult function to think about: we just don't want a
situation where we have all jokers.
2026-04-14 22:52:35 +01:00
Aryadev Chavali
419f1f4eb5 big-c: update for new task (creating triples) 2026-04-14 22:52:35 +01:00
Aryadev Chavali
059cb2f828 card: clippy oh clippy, clippy my beloved. 2026-04-07 12:36:48 +01:00
Aryadev Chavali
de29cab82e cards:tests: implement tests for card API 2026-04-07 12:36:48 +01:00
Aryadev Chavali
9ee1a0228d card#️⃣ implement hashing for ranks, suits, playing cards 2026-04-07 12:36:48 +01:00
Aryadev Chavali
ec31844ee7 helper: new ExactSizedArr adaptor for ExactSizedIterators
Given an ExactSizedIterator and a compile time known size (N), we
should be able to generate stack allocated arrays of the contents of
an iterator as long as the iterator has at least the required size.
2026-04-07 12:36:48 +01:00
Aryadev Chavali
9b1db4382d modes:single:tests: refactor footstool_deck_irrelevance via a combinatory argument 2026-04-07 12:36:48 +01:00
Aryadev Chavali
a1d0d72b1e modes:single|pair:tests: some adjustments based on prev refactors 2026-04-07 12:36:48 +01:00
Aryadev Chavali
b4cd7e8ea9 card:default: implemented defaults for every card type 2026-04-07 12:36:48 +01:00
Aryadev Chavali
967374d688 card:*: small changes 2026-04-07 12:36:48 +01:00
Aryadev Chavali
29e310a470 card:mod: split implementations of methods into impls.rs 2026-04-07 12:36:48 +01:00
Aryadev Chavali
285d816707 card: split up into its own module. 2026-04-07 12:36:48 +01:00
Aryadev Chavali
0d2eed5369 card: delete 2026-04-07 12:36:48 +01:00