Go Fish/C: Difference between revisions

m
Fixed syntax highlighting.
mNo edit summary
m (Fixed syntax highlighting.)
 
(One intermediate revision by one other user not shown)
Line 1:
{{collection|Go Fish}}
Reasonably smart computer AI. Programs require utf-8 locale. AI keeps a record of probabilities of each card player may have and always asks for the card with highest score (which backfires quite often btw).
<langsyntaxhighlight lang="c">#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
Line 69:
int shuffle_cmp(const void * a, const void *b)
{
int x = ((const shuffle_t*)a)->n, y = ((const shuffle_t*)b)->n;
return x < y ? -1 : x > y;
}
Line 75:
int card_cmp(const void *aa, const void *bb)
{
card a = *(const card*)aa, b = *(const card*)bb;
if (aa == bb) return 0;
if (!aaa == b) return 10;
if (!bba) return -1;
if (aa == bb!b) return 0-1;
 
card a = *(card*)aa, b = *(card*)bb;
if (a->num < b->num) return -1;
if (a->num > b->num) return 1;
Line 463 ⟶ 462:
game_display(&g);
return 0;
}</langsyntaxhighlight>
9,485

edits