Go Fish/C++: Difference between revisions
m
Fixed syntax highlighting.
(Created page with "=={{header|C++}}== <lang cpp> #include <time.h> #include <map> #include <vector> #include <algorithm> #include <string> #include <iostream> const std::string s = "CDHS", v = ...") |
m (Fixed syntax highlighting.) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1:
{{collection|Go_Fish}}
AI is really not that clever but it gets its job done (well, pretty much!).
It follows three simple rules:
* 75% the times it remembers cards asked by its opponent, and asks for the first one it also has.
* ask for a card it fished in the last round, if its different from all its other cards
* cycles thru all its cards, asking for them.
As I said, simple...
<span style='font-family: "Linux Libertine",Georgia,Times,serif;font-size:150%;'>[[C++]]</span><hr>
<syntaxhighlight lang="cpp">
#include <time.h>
#include <map>
Line 161 ⟶ 172:
c = hand[askedIdx].getRank();
if( rand() % 100 > 25 && asked.size() ) {
for( std::vector<char>::iterator
c = ( *it );
break;
}
}
}
}
Line 299 ⟶ 314:
return 0;
}
</syntaxhighlight>
|