ctm / mb2-doc

Mb2, poker software
https://devctm.com
7 stars 2 forks source link

Redundancy in tournament.rs #1354

Closed ctm closed 3 months ago

ctm commented 3 months ago

Create a macro to populate TOURNAMENTS in mb2/src/tournament.rs.

Currently, TOURNAMENTS is populated in a manner that requires adding a module to a huge use declaration, and then a ton of calls to map.insert where the same identifier is used in three different places. This dates back to when I didn't know a better way to do it in Rust. I knew there had to be a better way, but I never got around to doing it.

Yesterday I spent a bunch of time adding new tournaments in anticipation of WSOPS 2024 (#1353) and I continued playing that stupid redundancy game. In emacs, it's not that big of a deal, because the identifier can be pasted into the four places it's needed, however, this morning I woke up and decided to do a spike to see if I could come up with something better, and I have.

I think the proof-of-concept work I did earlier today is sufficient proof that I can do this fairly quickly. I'll still need emacs to remove all the redundancy and collapse everything into a single macro invocation, but when I'm finished, adding a new structure to tournaments should just be a matter of adding the short_name (which is also the module name, which is also the name of the builder function).

ctm commented 3 months ago

Uh oh. I fleshed out my idea, populated it, and got a compilation error complaining about chorse, which is probably a case where I wasn't consistent with my naming. The old way of doing things would allow such inconsistency. The new way requires it. However, when I unnarrowed my buffer, emacs went blank and before too long my laptop fan came on. Emacs is now spinning its wheels, using 100% of a core.

I was hoping as I wrote this little note to myself (and Ed!), that emacs would finish doing what it's doing and let me continue. It looks, however, like I'm going to have to kill it and then see if I can open tournaments.rs again w/o the blow-up.

Whee!?

ctm commented 3 months ago

So, emacs has been well behaved since I restarted it. The chorse complaint had to do with me adding suffixes to show which year various structures came from. I only did that for a little while and then I introduced prefixes. Still, I had to rename a bunch of files to their short names, since the short names are stored in the database:

    renamed:    mb2/src/tournament/structure/barge_nlhe_2019.rs -> mb2/src/tournament/structure/barge_nlhe.rs
    renamed:    mb2/src/tournament/structure/chorse_barge_2020.rs -> mb2/src/tournament/structure/chorse.rs
    renamed:    mb2/src/tournament/structure/f_cancer_2019.rs -> mb2/src/tournament/structure/f_cancer.rs
    modified:   mb2/src/tournament/structure/hoe.rs
    renamed:    mb2/src/tournament/structure/hoe_2020.rs -> mb2/src/tournament/structure/hoe_no_button_ante.rs
    renamed:    mb2/src/tournament/structure/irish_2020.rs -> mb2/src/tournament/structure/irish.rs
    renamed:    mb2/src/tournament/structure/jam_or_fold_short_nl_omaha_2020.rs -> mb2/src/tournament/structure/jof_short_nlo.rs
    renamed:    mb2/src/tournament/structure/korean_2019.rs -> mb2/src/tournament/structure/korean.rs
    renamed:    mb2/src/tournament/structure/limit_6_2019.rs -> mb2/src/tournament/structure/limit_6.rs
    renamed:    mb2/src/tournament/structure/limit_he_win_the_button_2019.rs -> mb2/src/tournament/structure/limit_he_win_the_button.rs
    renamed:    mb2/src/tournament/structure/monte_2019.rs -> mb2/src/tournament/structure/monte.rs
    renamed:    mb2/src/tournament/structure/oklahoma_2019.rs -> mb2/src/tournament/structure/oklahoma.rs
    renamed:    mb2/src/tournament/structure/pl_horse_2019.rs -> mb2/src/tournament/structure/pl_horse.rs
    renamed:    mb2/src/tournament/structure/plo_2019.rs -> mb2/src/tournament/structure/plo.rs
    renamed:    mb2/src/tournament/structure/sardm.rs -> mb2/src/tournament/structure/sardmm.rs
    renamed:    mb2/src/tournament/structure/six_handed_nlhe_2020.rs -> mb2/src/tournament/structure/six_handed_nlhe.rs
    renamed:    mb2/src/tournament/structure/so_mixed_hold_em_2019.rs -> mb2/src/tournament/structure/so_mixed_hold_em.rs
    modified:   mb2/src/tournament/structure/tesla.rs
    new file:   mb2/src/tournament/structure/tesla_20000.rs
    deleted:    mb2/src/tournament/structure/tesla_2019.rs
    renamed:    mb2/src/tournament/structure/toc_2019.rs -> mb2/src/tournament/structure/toc.rs
ctm commented 3 months ago

Deploying now.