harphield / riichi-tools-cli

MIT License
1 stars 0 forks source link

[Feature Request] Ukeire for Tenpai #1

Open Cubostar opened 2 months ago

Cubostar commented 2 months ago

I like using riichi-tools-cli when reviewing my games. Sometimes, I want to know how many and which tiles could improve a hand in tenpai. This would help determine whether damaten is the right move. However, currently the command riichi-tools-cli ukeire will only show the outs to complete the hand when given a hand in tenpai.

I understand that this project has not been updated in a while, and I'm willing to try to implement this myself (I assume the actual implementation of this would be done in riichi-tools-rs), but I figured it wouldn't hurt to add this in case someone who is more familiar with this project would be interested. I would also appreciate any discourse for where to begin on implementing this feature.

Cubostar commented 2 months ago

As an example of what I mean, consider the hand 456m24566778p55s. When running riichi-tools-cli ukeire, only 3s appears, however tiles such as 9p would improve the wait as you can discard 2p and increase the ukeire to 5p and 8p. It would be nice to see tiles like this when running riichi-tools-cli ukeire on a hand in tenpai.

harphield commented 2 months ago

@Cubostar hi! I'm glad that you like the project. It's true, it's been a while since I (or anyone) has done anything on it. As usual, my motivation went elsewhere and time is short.

I understand what you mean, and it does make sense to also count ukeire and show potential improving tiles for tenpai hands.

The changes would need to be done, as you pointed out, in riichi-tools-rs, but from first glance it won't be easy :) If I see correctly (I don't actually remember any of the code at this point lol), the functions counting ukeire work with current shanten, and only include a tile if the shanten goes down (https://github.com/harphield/riichi-tools-rs/blob/cc3eb9faad91edd5dd3fc7509a171b8840926f49/src/riichi/hand.rs#L1395 for example, but the fast_shanten feature uses a different function, so that might work a bit differently). What would be needed is also including tiles that have the same shanten, but improve ukeire.

That leads me to some issues - I would like to always see the distinction between tiles that:

a) in case of tenpai are the winning tiles b) improve shanten of the hand c) don't improve shanten but improve ukeire

There's stuff to think about :) What I might do first is to update both projects to be up to date with latest Rust and libraries. If you want to try to implement this feature, you are welcome to! I'd love to come back to the project (and Rust generally), hopefully I can find the time.