Go Fish/C++: Difference between revisions

(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 = ...")
 
Line 1:
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...
 
 
=={{header|C++}}==
<lang cpp>
Line 161 ⟶ 171:
c = hand[askedIdx].getRank();
if( rand() % 100 > 25 && asked.size() ) {
for( std::vector<char>::iterator dit = asked[rand.begin(); %it != asked.sizeend()]; it++ ) {
if( holds( d*it ) ) c = d;{
c = ( *it );
break;
}
}
}
}