charleskawczynski / PlayingCards.jl

A package for representing playing cards for card games.
MIT License
14 stars 4 forks source link

Card values #11

Closed scheinerman closed 3 years ago

scheinerman commented 3 years ago

Hi again. I'd like to see the functions low_value and high_value defined for all cards.

julia> C = 5♠
5♠

julia> value(C)
5

julia> high_value(C)
ERROR: UndefVarError: high_value not defined
Stacktrace:
 [1] top-level scope
   @ REPL[15]:1

julia> low_value(C)
5

For Poker, you'd want to use high_value; for solitaire, I'd use low_value. This makes PlayingCards "agnostic" about ace high vs. ace low.

My further suggestion is not to define value at all, and let the user either choose which value function to use, or else define their own function either value=low_value or value=high_value.

Let me know if you'd like me to edit PlayingCards.jl to implement, or send some code snippets you can cut/paste.

Thanks, Ed

charleskawczynski commented 3 years ago

I’m happy to change the name, I was 50-50 on which to use (value vs high_value). I’ll open a PR

scheinerman commented 3 years ago

Thanks!