I'm trying to learn Prolog. This is my first steps with this language. As for exercise, I want to write a program that can recognize some poker hands (Straight flush, Four of a kind, Full house, etc.).
I'm looking for a good card representation in Prolog. I need to have the possibility to check if one card is bigger than the 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 gives mi possibility to check if rank A is bigger than for example J.
But I'm not sure how to represent a single card. This representation should contain the rank of card and also suit. There is also some issue with Ace because Ace has 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 a kind of simple question if you know the language, but it is not so easy to 'switch' thinking from languages like C or python. :-)