charleskawczynski / PlayingCards.jl

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

Behavior of number * suit #18

Closed scheinerman closed 3 years ago

scheinerman commented 3 years ago

Hi Charlie:

Is this the behavior you want?

julia> using PlayingCards

julia> [ k*♣ for k=1:13 ]
13-element Vector{Card{_A, Club} where _A<:Rank}:
 1♣
 2♣
 3♣
 4♣
 5♣
 6♣
 7♣
 8♣
 9♣
 T♣
 11♣
 12♣
 13♣

I've got mine rigged to do this:

julia> using PlayingCards52

julia> [ k*♣ for k=1:13 ]
13-element Vector{Card}:
 A♣
 2♣
 3♣
 4♣
 5♣
 6♣
 7♣
 8♣
 9♣
 T♣
 J♣
 Q♣
 K♣
scheinerman commented 3 years ago

Also: I think this behavior is what you want, but I don't understand why.

julia> using PlayingCards

julia> typeof(A♣) == typeof(5♣)
false

julia> typeof(5♡) == typeof(5♣)
false

Versus:

julia> using PlayingCards52

julia> typeof(5♡) == typeof(5♣)
true

julia> typeof(A♣) == typeof(5♣)
true
charleskawczynski commented 3 years ago

Hmm, yes, this should be more protective. And after looking a bit more into hand evaluators, it seems that the rank types are really not beneficial. I'm not sure that I'm ready to remove the suit type, but I think it's clear that the rank types can't be leveraged due to combinatorial explosion.

I'll start by removing the ranks in #16.

charleskawczynski commented 3 years ago

16 should address both of these. Now we can use [ k*♣ for k=1:13 ] and, in addition, 0*♣ and 14*♣ will throw errors.