-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhold'em main.cpp
2323 lines (1953 loc) · 47.4 KB
/
hold'em main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "holdem.h"
/////////////////////////////////////////////////////////////
//
// Analyis Software for the game of Texas Hold'em
//
// TERMS OF USE:
//
// Copyright 1995-2023 Gerold Lee Gorman
// Made Available under the GNU/MIT license
// Free to use for any open sourc application according
// to GPL, or LGPL if any portion is included as part
// of a compilier package, or other open source work
// commonly refered to as an SDK, and where that other
// work is a substantial work likely to attract a wide
// interest with respect ot similar subject matter.
//
// Also available under the ususal MIT
// license, if used in a closed source, redistributed
// commerical work.
//
// Other Restrictions: NO REDISTRIBUTION IN ANY PART
// OR IN WHOLE, in either source or binary form as a
// part of any commerical printed work, i.e., such as,
// but not limited to any published work on Poker Strategy,
// "Casino Secrets, etc", i.e., in hard copy form.
// Any other use should provide an approriate attribution,
// according the the medium in which this work or a
// deriavatie work based upon this work is used such as:
//
// "Lenes by Panavision; Color By Deluxe; Catering by XYZ Deli;
// Poker strategy tables compiled with Mister G's Poker Software,
// Copyright Gerold Lee Gorman, used by Permission"
//
// Use at your own risk. Not responsible for any damages, losses,
// whether pecuniary, incidental, or other, as a consequence
// of the use of this software, or any data produced by this
// software or any other work derived from.
//
// YOU HAVE BEEN WARNED!
//
/////////////////////////////////////////////////////////////
deck the_deck;
// ---------------------------------------------------------------------------
int
min = 3,
option = 3;
char response;
int blind, dealt, number_of_players, winner, pot;
long badbeats, games, highhands, oldTickTime, quota;
struct {
bool activateDA,betting,goaway,
debug,highhand,hitit,params,quit,reset,
resume,run,status,splitpot,PrefExists,
PlayExists,NumExists; } flag;
struct {
bool all, each, high, prob, bad; } wr;
char menuText[80];
deck new_deck, old_deck;
card the_board[5];
int ordering[13][13];
long appeared[13][13], won[13][13];
long strongest[straightflush+1];
strategies playstyle[11];
statistics stats;
ranking rankings [171];
// ------------------------------------------------------------------------
void startup (void);
void init_cash (void);
void init_rank_table (void);
void init_tallies (void);
void reset_strategies (void);
void play (long count);
//void syscheck (void);
void text_parameters (void);
// ------------------------------------------------------------------------
main()
{
startup();
init_cash();
init_rank_table();
init_tallies();
playstyle[0] = tight;
reset_strategies();
blind = 0;
quota = 100;
number_of_players = 10;
flag.run = true;
wr.each = true;
while (flag.quit == false)
{
if (flag.run == true)
play(quota);
flag.resume = false;
}
return 0;
}
// ------------------------------------------------------------------------
int random()
// linear congruential algorithm from Schneier p 347
{
const a = 7141, b = 54773, m = 259200;
static long seed;
seed = (a * seed + b) % m;
return seed & 0xFFFF;
}
bool reply (void)
{
char response[80];
scanf("%s",&response);
select (response[0])
{
case 'y': case 'Y':
return true;
break;
case 'n': case 'N':
return false;
break;
default:
printf("y/n expected\n");
return false;
}
}
// ------------------------------------------------------------------------
deck::deck ()
{
int this_card;
for_each_card_in_the_deck
{
pack[this_card].suit = (suits) ((this_card - 1)/13);
pack[this_card].name = (card_name) ((this_card - 1)%13 + 1);
};
dealt = 0;
}
void deck::cut (int depth)
{
int this_card;
card oldpack[53];
for_each_card_in_the_deck
oldpack[this_card] = pack[this_card];
for_each_card_in_the_deck
pack[this_card] = oldpack[(this_card + depth)%52 + 1];
}
void deck::interlace ()
{
int this_card;
card olddeck [53];
for_each_card_in_the_deck
olddeck[this_card] = pack[this_card];
for_each_card_in_the_deck
select (this_card%2)
{
case 1: pack[this_card] = olddeck[this_card/2 + 1];
break;
case 0: pack[this_card] = olddeck[this_card/2 + 26];
break;
}
}
void deck::shuffle (int times)
{
int time;
// pack olddeck;
for (time=1; time<=times; time++)
{
cut(23 + random() %11);
interlace();
}
cut(13 + games%11);
dealt = 0;
}
void deck::show_the_deck1()
{
int this_card;
for_each_card_in_the_deck
{
select (pack[this_card].name) {
case 1: printf("A");
break;
case 10: case 11: case 12: case 13:
printf("X");
break;
default:
printf("%d",pack[this_card].name);
break; }
if (this_card%13 == 0) printf("\n");
}
}
void write_card_description(bool capitalize, card the_card)
{
select (the_card.name)
{
case ace: printf("Ace of ");
break;
case jack: printf("Jack of ");
break;
case queen: printf("Queen of ");
break;
case king: printf("King of ");
break;
default: printf("%d of ",the_card.name);
break;
}
select (the_card.suit)
{
case club: printf("Clubs");
break;
case diamond: printf("Diamonds");
break;
case heart: printf("Hearts");
break;
case spade: printf("Spades");
break; }
}
void deck::show_the_deck2()
{
int this_card;
printf("\n");
for_each_card_in_the_deck
{
write_card_description(true,pack[this_card]);
if ((this_card%13)%5 == 0)
printf("\n");
else
printf(",");
if (this_card%13 == 0)
printf("\n");
}
}
void hand::show_a_hand ()
{
int this_card;
printf("Player %d has the ",owner->seat_number);
for_each_card_in_the_dealt_hand
{
write_card_description(true,cards[this_card]);
if (this_card == 0)
printf(" and the ");
else
printf(".\n");
}
}
void show_the_board ()
{
int this_card;
printf("\n");
printf("The board has the ");
for_each_card_on_the_board
{
write_card_description(true,the_board[this_card]);
select (this_card)
{
case 0: case 2:
printf(", ");
break;
case 1:
printf(",\n");
break;
case 3:
printf(" and the ");
break;
case 4:
printf(".\n");
break; }
}
printf("\n");
}
void dealer::deal_to_the_players (player *players)
{
int seat_number;
int this_card;
for_each_card_in_the_dealt_hand
for(seat_number=1; seat_number<=number_of_players; seat_number++)
{
dealt++;
players [seat_number].my_hand[this_card] = the_deck.pack[dealt];
}
}
void deck::deal_to_the_board ()
{
int this_card;
for_each_card_on_the_board
{
dealt++;
the_board[this_card] = pack[dealt];
}
}
void hand::pack_no_pair ()
{
int this_card;
unsigned char the_name;
bool found_the_card;
found = 0;
found_the_card = false;
if (name_count [ace] == 1)
{
for_each_card_in_the_dealt_hand
if (cards [this_card].name is_an_ace)
{
use_to_make_the_best_hand(cards[this_card]);
found_the_card = true;
}
for_each_card_on_the_board
if ((found_the_card == false)&&(the_board[this_card].name is_an_ace))
{
use_to_make_the_best_hand(the_board[this_card]);
found_the_card = true;
}
}
for (the_name=king; ((the_name>=deuce)&&(found!=5)); the_name--)
{
found_the_card = false;
if (name_count [the_name] == 1)
{
for_each_card_in_the_dealt_hand
if (cards[this_card].name == the_name)
{
use_to_make_the_best_hand(cards[this_card]);
found_the_card = true;
}
for_each_card_on_the_board
if ((found_the_card == false)
&&(the_board[the_name].name == the_name))
{
use_to_make_the_best_hand(the_board[this_card]);
found_the_card = true;
}
}
}
}
// This next void sorts the cards in a players hand when the player
// has any pairs, sets or a fullhouse. The suits are tracked as a matter
// of record, although this information is not really needed in most cases
void hand::pack_groups ()
{
int has_this_many_to_find, found, this_card;
unsigned char the_name;
found = 0;
if (stats.trips == true)
has_this_many_to_find = 3;
else
has_this_many_to_find = 2;
while ((has_this_many_to_find!=0)&&(found!=5))
{
if (name_count[ace] == has_this_many_to_find)
{
for_each_card_in_the_dealt_hand
if (cards[this_card].name is_an_ace)
use_to_make_the_best_hand(cards[this_card]);
for_each_card_on_the_board
if (the_board[this_card].name is_an_ace)
use_to_make_the_best_hand(the_board[this_card]);
}
for_each_card_name_descending
{
if ((name_count[the_name] == has_this_many_to_find)
&&(found < 5))
{
for_each_card_in_the_dealt_hand
if ((cards[this_card].name == the_name)
&&(found < 5))
use_to_make_the_best_hand(cards[this_card]);
for_each_card_on_the_board
if ((the_board[this_card].name == the_name)&&(found<5))
use_to_make_the_best_hand(the_board[this_card]);
}
if (found == 5) break;
}
has_this_many_to_find--;
}
}
void hand::use_to_make_a_flush (card the_card, int found)
{
best [found] = the_card;
found++;
}
void hand::pack_flush ()
{
unsigned char this_card, found;
unsigned char the_name;
/* This segment expropriates the variable
name_count and uses it to recount only the cards
in the hand that have the same suit as fsuit */
for(the_name=ace;the_name<=king;the_name++)
name_count[the_name] = 0;
for_each_card_in_the_dealt_hand
if (cards[this_card].suit == fsuit)
name_count[cards [this_card].name]++;
for_each_card_on_the_board if (the_board[this_card].suit == fsuit)
name_count[the_board[this_card].name]++;
/*
Now the cards that comprise the flush have been loaded into name_count.
I have copied the straight detector inline here to determine if is a
straightflush. This works here because name_count now only carries info
regarding the cards in the suit that we already have a flush from.*/
found = 0;
if (name_count[ace] == 1)
use_to_make_a_flush(ace,found);
for_each_card_name_descending
{
if (name_count[the_name] == 1)
use_to_make_a_flush(the_name,found);
else
found = 0;
if (found == 5)
stats.straightflush = true; }
if (stats.straightflush == true)
strength = straightflush;
else
// Else it is not a straight flush and the flush
// ordering routine should proceed
{ found = 0;
if (name_count[ace] == 1)
use_to_make_a_flush(ace,found);
while (found<5)
for (the_name=king; ((the_name>=deuce)&&(found<5)); the_name--)
if (name_count[the_name] == 1)
use_to_make_a_flush(the_name,found);
}
}
// The next void is specific to the rating of four of a kind.
void hand::pack_four_of_a_kind ()
{
bool found_kicker;
unsigned char found, the_name, this_card, fourof, kicker;
for(this_card=ace;this_card<=king;this_card++)
if (name_count[this_card] == 4)
fourof = this_card;
found = 0;
for_each_card_in_the_dealt_hand
if (cards [this_card].name == fourof)
use_to_make_the_best_hand(cards[this_card]);
for_each_card_on_the_board
if (the_board[this_card].name == fourof)
use_to_make_the_best_hand(the_board[this_card]);
// Identify Kicker
if ((name_count[ace] > 0)&&(fourof != ace))
kicker = ace;
else
for_each_card_name_descending
if ((name_count[the_name] > 0)&&(fourof != the_name))
{
kicker = the_name;
break;
}
// Pack kicker into best hand.
for_each_card_in_the_dealt_hand
if (cards [this_card].name == kicker)
{
use_to_make_the_best_hand(cards[this_card]);
found_kicker = true;
break; }
if (found_kicker == false)
for_each_card_on_the_board
if (the_board[this_card].name == kicker)
{
use_to_make_the_best_hand(the_board[this_card]);
found_kicker = true;
break; }
}
// ------------------------------------------------------------------------
void dealer::evaluate_the_strength_of_each_hand()
{
unsigned char found, player, this_card;
unsigned char the_name, this_suit;
my_hand.strength = unknown;
winner = 0;
for(player=1; player<=number_of_players; player++) if (my_hand.strength!=folded)
{
my_hand.strength = unknown;
stats.second = null;
stats.pairs = 0;
stats.trips = false;
stats.straight = false;
stats.flush = false;
stats.fullhouse = false;
stats.fourofakind = false;
stats.straightflush = false;
for(the_name=ace;the_name<=king;the_name++)
my_hand.name_count[the_name] = 0;
for(this_suit=club; this_suit<=spade; this_suit++)
my_hand.suit_count[this_suit] = 0;
for_each_card_in_the_dealt_hand
{
my_hand.name_count[my_hand.cards [this_card].name]++;
my_hand.suit_count[my_hand.cards [this_card].suit]++;
}
for_each_card_on_the_board
{
my_hand.name_count [the_board[this_card].name]++;
my_hand.suit_count [the_board[this_card].suit]++;
}
// Now it should be possible to determine hand strength by
// using the name_count and suit_count_of data for (this player. Use
// name_count to arbitrate pairs, trips, full houses or quads.
for(the_name=ace;the_name<=king;the_name++)
select (my_hand.name_count[the_name]) {
case 2:
stats.pairs++;
break;
case 3:
stats.trips = true;
break;
case 4:
stats.fourofakind = true;
break;
default:
break; }
// Handle nopair, one pair and two pair.
select (stats.pairs) {
case 0:
my_hand.strength = nopair;
break;
case 1:
my_hand.strength = onepair;
break;
case 2: case 3:
my_hand.strength = twopair;
break; }
// Check for trips. This can be later upgraded to
// fullhouse if (the player also has an extra pair.
if (stats.trips == true)
my_hand.strength = trips;
// Check for (a straight.
if (my_hand.name_count[ace] > 0)
{
my_hand.best[0].name = ace;
my_hand.best[0].suit = blank;
found = 1;
}
else
my_hand.found = 0;
for_each_card_name_descending
{
if (my_hand.name_count[the_name] > 0)
{
my_hand.best[found].name = the_name;
my_hand.best[found].suit = blank;
found++;
}
else
my_hand.found = 0;
if (my_hand.found == 5)
{
stats.straight = true;
break;
}
}
if (stats.straight == true) my_hand.strength = straight;
// Check for a flush.
for(this_suit=club; this_suit<=spade; this_suit++)
if (my_hand.suit_count[this_suit] > 4)
{
stats.flush = true;
my_hand.strength = flush;
my_hand.fsuit = this_suit;
}
// Assert any full house.
if (stats.trips == true)
{
if (my_hand.name_count[ace] == 3) stats.first = ace;
if (my_hand.name_count[ace] == 2) stats.second = ace;
for_each_card_name_descending
{
select (my_hand.name_count[the_name]) {
case 3:
if (stats.first == null)
stats.first = the_name;
else
if (the_name is_not_an_ace)
{
stats.second = the_name;
my_hand.strength = fullhouse;
}
break;
case 2:
if (((the_name is_not_an_ace)||
(stats.first is_not_an_ace))
&&(stats.second == null))
{
stats.second = the_name;
my_hand.strength = fullhouse;
}
break;
default:
break; }
}
}
// Assert any four of a kind.
if (stats.fourofakind == true) my_hand.strength = fourofakind;
// Now pack best declaration into best for this player.
select (my_hand.strength) {
case nopair:
my_hand.pack_no_pair();
break;
case onepair: case twopair: case trips: case fullhouse:
my_hand.pack_groups ();
break;
case flush:
my_hand.pack_flush();
break;
case fourofakind:
my_hand.pack_four_of_a_kind();
break;
default:
break; }
}
}
// ------------------------------------------------------------------------
double hand::return_strength ()
{
unsigned char index0, index1;
index0 = cards[0].name;
index1 = cards[1].name;
if (index0 > index1)
{
index0 = cards[1].name;
index1 = cards[0].name;
}
if (cards[0].suit == cards[1].suit)
{
if (appeared[index0][index1] != 0 )
return won[index0][index1] / appeared[index0][index1];
}
else if (appeared[index1][index0] != 0 )
return won[index1][index0] / appeared[index1][index0];
return nopair;
}
void init_tallies()
{
card_name the_name1, the_name2;
hand_value strength;
games = 0;
for (strength = nopair; strength<= straightflush; strength++)
strongest[strength] = 0;
for(the_name1=ace;the_name1<=king;the_name1++)
for(the_name2=ace;the_name2<=king;the_name2++)
{
appeared[the_name1][the_name2] = 0;
won[the_name1][the_name2] = 0;
}
}
// This function gets called after each hand in order
// to tabulate the various strength tables for each
// hand.
void tally_hand_performance()
{
int p_index;
card_name index1, index0;
hand *winner;
index0 = winners_first_card.name;
index1 = winners_other_card.name;
if (index1>index0)
{
index0 = winners_other_card.name;
index1 = winners_first_card.name;
}
else
{
index0 = winners_first_card.name;
index1 = winners_other_card.name;
}
if (winners_first_card.suit == winners_other_card.suit)
won[index0][index1]++;
else
won[index1][index0]++;
for(p_index=1; p_index<=number_of_players; p_index++) if the_player_was_dealt_a_hand
{
if (index0 > index1)
{
index0 = the_hand[1].name;
index1 = the_hand[0].name;
}
else
{
index0 = the_hand[0].name;
index1 = the_hand[1].name;
}
if (the_hand[0].suit == the_hand[1].suit)
appeared[index0][index1]++;
else
appeared[index1][index0]++;
}
strongest[my_hand.strength[0]]++;
}
void init_cash()
{
int player;
cash[0] = 0;
for(player=1; player<=number_of_players; player++) cash[player] = 1000;
}
void payoff()
{
if (wr.each == true)
{
printf("Player %d wins %d\n",winner, pot);
};
cash[winner] += pot;
pot = 0;
}
void call (int player)
{
cash[player] -= min;
pot += pot;
}
void init_rank_table ()
{
int count;
for (count = 0; count<=170; count++)
{
rankings [count].suited = false;
rankings [count].name1 = null;
rankings [count].name2 = null;
rankings [count].strength = 0;
}
}
void insert (double strength, int the_name1,
int the_name2, bool suited)
{
int count, scan;
enum { scanning, moving, finished } status;
scan = 1;
status = scanning;
while ((status != finished) && (scan > 169))
{
if (strength >= rankings [scan].strength)
{
count = 169;
while ((rankings [count].name1 == null)&&(count > scan))
count--;
while (count >= scan)
{
rankings [count+1] = rankings [count];
count--;
}
rankings [scan].strength = strength;
rankings [scan].name1 = the_name1;
rankings [scan].name2 = the_name2;
rankings [scan].suited = suited;
status = finished;
}
scan ++;
}
}
// This void scans the tables of hands won by and hands that
// appeared and calculates the win ratio for (each hand) it
// calls a routine; perform an insert sort into the rankings table.
void adjust_rank_table_data()
{
card_name the_name, the_name1, the_name2;
long w1, a1;
double strength;
// Pairs
for(the_name=ace;the_name<=king;the_name++)
{
w1 = won[the_name][the_name];
a1 = appeared[the_name][the_name];
if (a1 > 0)
{
strength = w1 / a1;
insert(strength,the_name,the_name,false);
}
}
// Suited Cards
for(the_name1=ace;the_name1<=king;the_name1++)
for(the_name2=ace;the_name2<=king;the_name2++)
{
w1 = won[the_name1][the_name2];
a1 = appeared[the_name1][the_name2];
if ((a1 > 0)&&(the_name1 != the_name2))
{
strength = w1 / a1;
insert(strength,the_name1,the_name2,true);
}
}
// Unsuited cards
for(the_name1=ace;the_name1<=king;the_name1++)
for(the_name2=ace;the_name2<=king;the_name2++)
{
w1 = won[the_name1][the_name2];
a1 = appeared[the_name1][the_name2];
if ((a1 > 0)&&(the_name1 != the_name2))
{
strength = w1 / a1;
insert(strength,the_name2, the_name1, false);
}
}
}
void sort_the_rank_table()
{
int count;
count = 1;
while ((rankings[count].strength > 0)&&(count < 170))
{
if (rankings [count].suited == true)
ordering[rankings[count].name1][rankings[count].name2] = count;
else
ordering[rankings[count].name2][rankings[count].name1] = count;
count++;
}
}
void update()
{
adjust_rank_table_data();
sort_the_rank_table();
}
int order (hand hands)
{
card_name index1, index0;
if (games%1024==0)
update();
if (hands[0].name < hands[1].name)
{
index1 = hands[0].name;
index0 = hands[1].name;
}
else
{
index0 = hands[0].name;
index1 = hands[1].name;
}
if (hands[0].suit == hands[1].suit)
return ordering[index1][index0];
else
return ordering[index0][index1];
}