I'm trying to learn Prolog. This are my first steps with this language. As exercise I want to write program which can recognize some poker hands (Straight flush, Four of a kind, Full house etc.).
I'm looking for good card representation in Prolog. I need to have possibility to check if one card is bigger than other, if cards are suited and so one.
I have started with code:
rank(2).
rank(3).
rank(4).
rank(5).
rank(6).
rank(7).
rank(8).
rank(9).
rank(t).
rank(j).
rank(q).
rank(k).
rank(a).
value(2, 2).
value(3, 3).
value(4, 4).
value(5, 5).
value(6, 6).
value(7, 7).
value(8, 8).
value(9, 9).
value(t, 10).
value(j, 11).
value(q, 12).
value(k, 13).
value(a, 14).
%value(a, 1).
suite(d).
suite(h).
suite(c).
suite(s).
rank_bigger(X, Y) :-
value(X, A),
value(Y, B),
A > B.
That give mi possibility to check if rank A is bigger than for example J.
But I'm not sure how to represent single card. This representation should contains rank of card and also suit. There is also some issue with Ace because Ace have rank 14 but it can be also 1 in straight.
So my question is how to represents cards if I want to make rules like:
isStraight(C1, C2, C3, C4, C5) :-
[...]
or
isStraightFlush(C1, C2, C3, C4, C5) :-
[...]
I'm sure that this is kind of simple question if you know language, but it is not so easy to 'switch' thinking from languages like C or python. :-)