% Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite
\noindent
\mbox{}\texttt{001:} \textit{//} \\
\mbox{}\texttt{002:} \textit{//\ bridge.cc} \\
\mbox{}\texttt{003:} \textit{//\ Eerste\ programmeeropgave\ voor\ AI,\ 28\ januari\ 2008,\ Bridge} \\
\mbox{}\texttt{004:} \textit{//\ Walter\ Kosters} \\
\mbox{}\texttt{005:} \textit{//} \\
\mbox{}\texttt{006:}  \\
\mbox{}\texttt{007:} \textbf{\#include}\ \texttt{$<$iostream$>$} \\
\mbox{}\texttt{008:} \textbf{\#include}\ \texttt{$<$iomanip$>$} \\
\mbox{}\texttt{009:} \textbf{\#include}\ \texttt{$<$cstdlib$>$} \\
\mbox{}\texttt{010:} \textbf{\#include}\ \texttt{$<$ctime$>$} \\
\mbox{}\texttt{011:} \textbf{using}\ \textbf{namespace}\ std; \\
\mbox{}\texttt{012:}  \\
\mbox{}\texttt{013:} \textit{/*\ Maak\ array\ verwijzingen\ expliciet\ en\ uniform\ */} \\
\mbox{}\texttt{014:} \textbf{\#define}\ NOORD\ 0 \\
\mbox{}\texttt{015:} \textbf{\#define}\ OOST\ \ 1 \\
\mbox{}\texttt{016:} \textbf{\#define}\ ZUID\ \ 2 \\
\mbox{}\texttt{017:} \textbf{\#define}\ WEST\ \ 3 \\
\mbox{}\texttt{018:}  \\
\mbox{}\texttt{019:} \textit{/*\ Kaartdefinities\ */} \\
\mbox{}\texttt{020:} \textbf{\#define}\ KLAVEREN\ 0 \\
\mbox{}\texttt{021:} \textbf{\#define}\ RUITEN\ \ \ 1 \\
\mbox{}\texttt{022:} \textbf{\#define}\ HARTEN\ \ \ 2 \\
\mbox{}\texttt{023:} \textbf{\#define}\ SCHOPPEN\ 3 \\
\mbox{}\texttt{024:}  \\
\mbox{}\texttt{025:} \textit{/*\ Contract\ mogelijkheden\ */} \\
\mbox{}\texttt{026:} \textbf{\#define}\ CONTRACT$\_$RANDOM\ 0\ \textit{/*\ Agent\ EEN\ */} \\
\mbox{}\texttt{027:} \textbf{\#define}\ CONTRACT$\_$SLIM\ 1\ \ \ \textit{/*\ Agent\ DRIE\ */} \\
\mbox{}\texttt{028:}  \\
\mbox{}\texttt{029:} \textit{/*\ Niveau's\ */} \\
\mbox{}\texttt{030:} \textbf{\#define}\ NIVEAU$\_$RANDOM\ 0\ \textit{/*\ Agent\ TWEE\ */} \\
\mbox{}\texttt{031:} \textbf{\#define}\ NIVEAU$\_$SLIM\ 1\ \textit{/*\ Agent\ VIER\ */} \\
\mbox{}\texttt{032:}  \\
\mbox{}\texttt{033:} \textit{/*\ Speeltype\ */} \\
\mbox{}\texttt{034:} \textbf{\#define}\ SPEEL$\_$KOSTER$\_$BRIDGE\ 0 \\
\mbox{}\texttt{035:}  \\
\mbox{}\texttt{036:} \textbf{\#define}\ VERBOSE\ 1 \\
\mbox{}\texttt{037:} \textbf{\#define}\ SILENT\ \ 0 \\
\mbox{}\texttt{038:}  \\
\mbox{}\texttt{039:} \textit{/*\ Afsluit\ codes,\ teveel\ is\ positief,\ teweinig\ negetief\ */} \\
\mbox{}\texttt{040:} \textbf{\#define}\ GEHAALD\ =\ 0 \\
\mbox{}\texttt{041:}  \\
\mbox{}\texttt{042:} \textit{//sorteer\ array\ A\ (met\ n\ elementen)\ via\ bubblesort} \\
\mbox{}\texttt{043:} void\ \textbf{bubblesort\ }(int\ A[\ ],\ int\ n)\ \{ \\
\mbox{}\texttt{044:} \ \ int\ i,\ j,\ temp; \\
\mbox{}\texttt{045:} \ \ \textbf{for}\ (\ j\ =\ 1;\ j\ $<$\ n;\ j++\ ) \\
\mbox{}\texttt{046:} \ \ \ \ \textbf{for}\ (\ i\ =\ 0;\ i\ $<$\ n-j;\ i++\ ) \\
\mbox{}\texttt{047:} \ \ \ \ \ \ \textbf{if}\ (\ A[i]\ $>$\ A[i+1]\ )\ \{ \\
\mbox{}\texttt{048:} \ \ \ \ \ \ \ \ temp\ =\ A[i];\  \\
\mbox{}\texttt{049:} \ \ A[i]\ =\ A[i+1];\  \\
\mbox{}\texttt{050:} \ \ A[i+1]\ =\ temp; \\
\mbox{}\texttt{051:} \ \ \ \ \ \ \}\textit{//if} \\
\mbox{}\texttt{052:} \}\textit{//bubblesort} \\
\mbox{}\texttt{053:}  \\
\mbox{}\texttt{054:} \textit{//welke\ getalswaarde\ heeft\ kaart\ i?} \\
\mbox{}\texttt{055:} \textit{//1..13\ zijn\ Klaver1..13,\ 14..26\ zijn\ Ruiten1..13,} \\
\mbox{}\texttt{056:} \textit{//27..39\ zijn\ Harten1..13\ en\ 40..52\ zijn\ Schoppen1..13} \\
\mbox{}\texttt{057:} \textit{//eigenlijk\ is\ 13\ de\ aas,\ dus\ 1\ is\ een\ 2\ ;-)} \\
\mbox{}\texttt{058:} int\ \textbf{dewaarde\ }(int\ i)\ \{ \\
\mbox{}\texttt{059:} \ \ \textbf{if}\ (\ i\ $<$=\ 13\ ) \\
\mbox{}\texttt{060:} \ \ \ \ \textbf{return}\ i; \\
\mbox{}\texttt{061:} \ \ \textbf{else}\ \textbf{if}\ (\ i\ $<$=\ 26\ ) \\
\mbox{}\texttt{062:} \ \ \ \ \textbf{return}\ i-13; \\
\mbox{}\texttt{063:} \ \ \textbf{else}\ \textbf{if}\ (\ i\ $<$=\ 39\ ) \\
\mbox{}\texttt{064:} \ \ \ \ \textbf{return}\ i-26; \\
\mbox{}\texttt{065:} \ \ \textbf{else} \\
\mbox{}\texttt{066:} \ \ \ \ \textbf{return}\ i-39; \\
\mbox{}\texttt{067:} \}\textit{//dewaarde} \\
\mbox{}\texttt{068:}  \\
\mbox{}\texttt{069:} \textit{//welke\ kleurwaarde\ heeft\ kaart\ i?} \\
\mbox{}\texttt{070:} char\ \textbf{dekleurwaarde\ }(int\ i)\ \{ \\
\mbox{}\texttt{071:} \ \ \textbf{if}\ (\ i\ $<$=\ 13\ ) \\
\mbox{}\texttt{072:} \ \ \ \ \textbf{return}\ KLAVEREN; \\
\mbox{}\texttt{073:} \ \ \textbf{else}\ \textbf{if}\ (\ i\ $<$=\ 26\ ) \\
\mbox{}\texttt{074:} \ \ \ \ \textbf{return}\ RUITEN; \\
\mbox{}\texttt{075:} \ \ \textbf{else}\ \textbf{if}\ (\ i\ $<$=\ 39\ ) \\
\mbox{}\texttt{076:} \ \ \ \ \textbf{return}\ HARTEN; \\
\mbox{}\texttt{077:} \ \ \textbf{else} \\
\mbox{}\texttt{078:} \ \ \ \ \textbf{return}\ SCHOPPEN; \\
\mbox{}\texttt{079:} \}\textit{//dekleur} \\
\mbox{}\texttt{080:}  \\
\mbox{}\texttt{081:} \textit{//welke\ kleur\ heeft\ kaart\ i?} \\
\mbox{}\texttt{082:} char\ \textbf{dekleur\ }(int\ i)\ \{ \\
\mbox{}\texttt{083:} \ \ \ \ \textbf{switch}\ (\ \textbf{dekleurwaarde\ }(i)\ )\ \{ \\
\mbox{}\texttt{084:} \ \ \ \ \textbf{case}\ KLAVEREN: \\
\mbox{}\texttt{085:} \ \ \ \ \ \ \ \ \textbf{return}\ \texttt{'K'}; \\
\mbox{}\texttt{086:} \ \ \ \ \textbf{case}\ RUITEN: \\
\mbox{}\texttt{087:} \ \ \ \ \ \ \ \ \textbf{return}\ \texttt{'R'}; \\
\mbox{}\texttt{088:} \ \ \ \ \textbf{case}\ HARTEN: \\
\mbox{}\texttt{089:} \ \ \ \ \ \ \ \ \textbf{return}\ \texttt{'H'}; \\
\mbox{}\texttt{090:} \ \ \ \ \textbf{case}\ SCHOPPEN: \\
\mbox{}\texttt{091:} \ \ \ \ \ \ \ \ \textbf{return}\ \texttt{'S'}; \\
\mbox{}\texttt{092:} \ \ \ \ \} \\
\mbox{}\texttt{093:} \}\textit{//dekleur} \\
\mbox{}\texttt{094:}  \\
\mbox{}\texttt{095:}  \\
\mbox{}\texttt{096:} \textit{//print\ kaart\ i\ netjes} \\
\mbox{}\texttt{097:} void\ \textbf{printkaart\ }(int\ i)\ \{ \\
\mbox{}\texttt{098:} \ \ cout\ $<$$<$\ \textbf{dekleur\ }(i)\ $<$$<$\ \textbf{dewaarde\ }(i); \\
\mbox{}\texttt{099:} \ \ \textbf{if}\ (\ \textbf{dewaarde\ }(i)\ $<$\ 10\ ) \\
\mbox{}\texttt{100:} \ \ \ \ cout\ $<$$<$\ \texttt{"{}\ "{}}; \\
\mbox{}\texttt{101:} \}\textit{//printkaart} \\
\mbox{}\texttt{102:}  \\
\mbox{}\texttt{103:} \textit{//welke\ speler\ is\ i?} \\
\mbox{}\texttt{104:} char\ \textbf{despeler\ }(int\ i)\ \{ \\
\mbox{}\texttt{105:} \ \ \textbf{switch}\ (\ i\ )\ \{ \\
\mbox{}\texttt{106:} \ \ \ \ \textbf{case}\ NOORD:\ \textbf{return}\ \texttt{'N'}; \\
\mbox{}\texttt{107:} \ \ \ \ \textbf{case}\ OOST:\ \textbf{return}\ \texttt{'O'}; \\
\mbox{}\texttt{108:} \ \ \ \ \textbf{case}\ ZUID:\ \textbf{return}\ \texttt{'Z'}; \\
\mbox{}\texttt{109:} \ \ \ \ \textbf{case}\ WEST:\ \textbf{return}\ \texttt{'W'}; \\
\mbox{}\texttt{110:} \ \ \}\textit{//switch} \\
\mbox{}\texttt{111:} \ \ \textbf{return}\ \texttt{'X'}; \\
\mbox{}\texttt{112:} \}\textit{//despeler} \\
\mbox{}\texttt{113:}  \\
\mbox{}\texttt{114:} \textit{//===} \\
\mbox{}\texttt{115:}  \\
\mbox{}\texttt{116:} \textbf{class}\ spel\ \{ \\
\mbox{}\texttt{117:} \ \ \textbf{public}: \\
\mbox{}\texttt{118:} \ \ \ \ int\ aantalkaarten;\ \ \ \ \ \textit{//hoeveel\ kaarten\ heeft\ iedere\ speler?} \\
\mbox{}\texttt{119:} \ \ \ \ char\ troef;\ \ \ \ \ \ \ \ \ \ \ \ \textit{//KRHS} \\
\mbox{}\texttt{120:} \ \ \ \ int\ hoogte;\ \ \ \ \ \ \ \ \ \ \ \ \textit{//1..13} \\
\mbox{}\texttt{121:} \ \ \ \ bool\ NZ;\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textit{//true\ betekent\ NZ,\ false\ betekent\ OW} \\
\mbox{}\texttt{122:} \ \ \ \ int\ dekaarten[4][13];\ \ \textit{//N:0,O:1,Z:2,W:3} \\
\mbox{}\texttt{123:} \ \ \ \ int\ slagenNZ;\ \ \ \ \ \ \ \ \ \ \textit{//aantal\ slagen\ voor\ NZ} \\
\mbox{}\texttt{124:} \ \ \ \ int\ slagenOW;\ \ \ \ \ \ \ \ \ \ \textit{//idem\ voor\ OW} \\
\mbox{}\texttt{125:} \ \ \ \ int\ spelerniveau[3];\ \ \ \textit{/*\ Kwaliteit\ van\ speler\ */} \\
\mbox{}\texttt{126:} \ \ \ \ void\ \textbf{schud\ }(\ ); \\
\mbox{}\texttt{127:} \ \ \ \ void\ \textbf{print\ }(\ ); \\
\mbox{}\texttt{128:} \ \ \ \ void\ \textbf{maakcontract\ }(int\ hoe,\ bool\ printdetails); \\
\mbox{}\texttt{129:} \ \ \ \ void\ \textbf{afspelen\ }(int\ speeltype,\ bool\ printdetails); \\
\mbox{}\texttt{130:} \ \ \ \ int\ \textbf{trekkaart\ }(int\ hoe,\ char\ kleur,\ int\ A[\ ],\ int\ aantal); \\
\mbox{}\texttt{131:} \ \ \ \ int\ \textbf{uitslag\ }(bool\ printdetails); \\
\mbox{}\texttt{132:} \};\textit{//spel} \\
\mbox{}\texttt{133:}  \\
\mbox{}\texttt{134:} \textit{//verdeel\ de\ kaarten,\ en\ schud\ ze\ over\ de\ 4\ spelers} \\
\mbox{}\texttt{135:} void\ spel::\textbf{schud\ }(\ )\ \{ \\
\mbox{}\texttt{136:} \ \ int\ kaarten[52]; \\
\mbox{}\texttt{137:} \ \ int\ i,\ j,\ temp; \\
\mbox{}\texttt{138:} \ \ aantalkaarten\ =\ 13; \\
\mbox{}\texttt{139:} \ \ \textbf{for}\ (\ i\ =\ 0;\ i\ $<$\ 52;\ i++\ ) \\
\mbox{}\texttt{140:} \ \ \ \ kaarten[i]=\ i+1; \\
\mbox{}\texttt{141:} \ \ \textbf{for}\ (\ i\ =\ 52-1;\ i\ $>$\ 0;\ i-\/-\ )\ \{ \\
\mbox{}\texttt{142:} \ \ \ \ j\ =\ \textbf{rand\ }(\ )\ \%\ (i+1); \\
\mbox{}\texttt{143:} \ \ \ \ temp\ =\ kaarten[i]; \\
\mbox{}\texttt{144:} \ \ \ \ kaarten[i]\ =\ kaarten[j]; \\
\mbox{}\texttt{145:} \ \ \ \ kaarten[j]\ =\ temp; \\
\mbox{}\texttt{146:} \ \ \}\textit{//for} \\
\mbox{}\texttt{147:} \ \ \textbf{for}\ (\ i\ =\ 0;\ i\ $<$\ 13;\ i++\ )\ \{ \\
\mbox{}\texttt{148:} \ \ \ \ dekaarten[NOORD][i]\ =\ kaarten[i]; \\
\mbox{}\texttt{149:} \ \ \ \ dekaarten[OOST][i]\ =\ kaarten[i+13]; \\
\mbox{}\texttt{150:} \ \ \ \ dekaarten[ZUID][i]\ =\ kaarten[i+26]; \\
\mbox{}\texttt{151:} \ \ \ \ dekaarten[WEST][i]\ =\ kaarten[i+39]; \\
\mbox{}\texttt{152:} \ \ \}\textit{//for} \\
\mbox{}\texttt{153:} \ \ \textbf{bubblesort\ }(dekaarten[NOORD],13); \\
\mbox{}\texttt{154:} \ \ \textbf{bubblesort\ }(dekaarten[OOST],13); \\
\mbox{}\texttt{155:} \ \ \textbf{bubblesort\ }(dekaarten[ZUID],13); \\
\mbox{}\texttt{156:} \ \ \textbf{bubblesort\ }(dekaarten[WEST],13); \\
\mbox{}\texttt{157:} \ \ slagenNZ\ =\ slagenOW\ =\ 0; \\
\mbox{}\texttt{158:} \}\textit{//spel::schud} \\
\mbox{}\texttt{159:}  \\
\mbox{}\texttt{160:} \textit{//print\ huidige\ kaarten} \\
\mbox{}\texttt{161:} void\ spel::\textbf{print\ }(\ )\ \{ \\
\mbox{}\texttt{162:} \ \ int\ i; \\
\mbox{}\texttt{163:} \ \ cout\ $<$$<$\ \texttt{"{}=Kaart\ configuratie="{}}\ $<$$<$endl; \\
\mbox{}\texttt{164:} \ \ cout\ $<$$<$\ endl\ $<$$<$\ \texttt{"{}Noord\ :\ "{}}; \\
\mbox{}\texttt{165:} \ \ \textbf{for}\ (\ i\ =\ 0;\ i\ $<$\ aantalkaarten;\ i++\ )\ \{ \\
\mbox{}\texttt{166:} \ \ \ \ \textbf{printkaart\ }(dekaarten[NOORD][i]); \\
\mbox{}\texttt{167:} \ \ \ \ cout\ $<$$<$\ \texttt{"{}\ $|$\ "{}}; \\
\mbox{}\texttt{168:} \ \ \}\textit{//for} \\
\mbox{}\texttt{169:} \ \ cout\ $<$$<$\ endl; \\
\mbox{}\texttt{170:} \ \ cout\ $<$$<$\ \texttt{"{}Oost\ \ :\ "{}}; \\
\mbox{}\texttt{171:} \ \ \textbf{for}\ (\ i\ =\ 0;\ i\ $<$\ aantalkaarten;\ i++\ )\ \{ \\
\mbox{}\texttt{172:} \ \ \ \ \textbf{printkaart\ }(dekaarten[OOST][i]); \\
\mbox{}\texttt{173:} \ \ \ \ cout\ $<$$<$\ \texttt{"{}\ $|$\ "{}}; \\
\mbox{}\texttt{174:} \ \ \}\textit{//for} \\
\mbox{}\texttt{175:} \ \ cout\ $<$$<$\ endl; \\
\mbox{}\texttt{176:} \ \ cout\ $<$$<$\ \texttt{"{}Zuid\ \ :\ "{}}; \\
\mbox{}\texttt{177:} \ \ \textbf{for}\ (\ i\ =\ 0;\ i\ $<$\ aantalkaarten;\ i++\ )\ \{ \\
\mbox{}\texttt{178:} \ \ \ \ \textbf{printkaart\ }(dekaarten[ZUID][i]); \\
\mbox{}\texttt{179:} \ \ \ \ cout\ $<$$<$\ \texttt{"{}\ $|$\ "{}}; \\
\mbox{}\texttt{180:} \ \ \}\textit{//for} \\
\mbox{}\texttt{181:} \ \ cout\ $<$$<$\ endl; \\
\mbox{}\texttt{182:} \ \ cout\ $<$$<$\ \texttt{"{}West\ \ :\ "{}}; \\
\mbox{}\texttt{183:} \ \ \textbf{for}\ (\ i\ =\ 0;\ i\ $<$\ aantalkaarten;\ i++\ )\ \{ \\
\mbox{}\texttt{184:} \ \ \ \ \textbf{printkaart\ }(dekaarten[WEST][i]); \\
\mbox{}\texttt{185:} \ \ \ \ cout\ $<$$<$\ \texttt{"{}\ $|$\ "{}}; \\
\mbox{}\texttt{186:} \ \ \}\textit{//for} \\
\mbox{}\texttt{187:} \ \ cout\ $<$$<$\ endl; \\
\mbox{}\texttt{188:} \}\textit{//spel::print} \\
\mbox{}\texttt{189:}  \\
\mbox{}\texttt{190:} \textit{//maak\ een\ contract} \\
\mbox{}\texttt{191:} void\ spel::\textbf{maakcontract\ }(int\ hoe,\ bool\ printdetails)\ \{ \\
\mbox{}\texttt{192:} \ \ int\ spelerA,\ spelerB; \\
\mbox{}\texttt{193:} \ \ int\ zoekpuntA,\ zoekpuntB; \\
\mbox{}\texttt{194:} \ \ int\ slagen; \\
\mbox{}\texttt{195:} \ \ int\ kleurAantal[]\ =\ \{0,\ 0,\ 0,\ 0\}; \\
\mbox{}\texttt{196:}  \\
\mbox{}\texttt{197:} \ \ \textit{/*\ Speler\ volledig\ random\ */} \\
\mbox{}\texttt{198:} \ \ NZ\ =\ (\ \textbf{rand\ }(\ )\ \%\ 2\ ==\ 1\ ); \\
\mbox{}\texttt{199:}  \\
\mbox{}\texttt{200:} \ \ \textbf{switch}\ (hoe)\ \{ \\
\mbox{}\texttt{201:} \ \ \textbf{case}\ CONTRACT$\_$RANDOM: \\
\mbox{}\texttt{202:} \ \ \ \ troef\ =\ \textbf{dekleur\ }(\textbf{rand\ }(\ )\ \%\ 52); \\
\mbox{}\texttt{203:} \ \ \ \ hoogte\ =\ 1\ +\ \textbf{rand\ }(\ )\ \%\ 13; \\
\mbox{}\texttt{204:} \ \ \ \ \textbf{break}; \\
\mbox{}\texttt{205:} \ \ \textbf{case}\ CONTRACT$\_$SLIM: \\
\mbox{}\texttt{206:} \ \ \ \ \textit{/*\ Variable\ om\ de\ juiste\ array\ rijen\ te\ selecteren\ */} \\
\mbox{}\texttt{207:} \ \ \ \ \textbf{if}\ (\ NZ\ )\ \{ \\
\mbox{}\texttt{208:} \ \ \ \ \ \ \ \ spelerA\ =\ NOORD; \\
\mbox{}\texttt{209:} \ \ \ \ \ \ \ \ spelerB\ =\ ZUID; \\
\mbox{}\texttt{210:} \ \ \ \ \}\ \textbf{else}\ \{ \\
\mbox{}\texttt{211:} \ \ \ \ \ \ \ \ spelerA\ =\ OOST; \\
\mbox{}\texttt{212:} \ \ \ \ \ \ \ \ spelerB\ =\ WEST; \\
\mbox{}\texttt{213:} \ \ \ \ \} \\
\mbox{}\texttt{214:}  \\
\mbox{}\texttt{215:} \ \ \ \ \textit{/*\ Bepaal\ aantal\ kaarten\ per\ kleur\ */} \\
\mbox{}\texttt{216:} \ \ \ \ \textbf{for}\ (\ int\ i\ =\ 0;\ i\ $<$\ 13;\ i++\ )\ \{ \\
\mbox{}\texttt{217:} \ \ \ \ \ \ \ \ kleurAantal[\textbf{dekleurwaarde\ }(dekaarten[spelerA][i])]++; \\
\mbox{}\texttt{218:} \ \ \ \ \ \ \ \ kleurAantal[\textbf{dekleurwaarde\ }(dekaarten[spelerB][i])]++; \\
\mbox{}\texttt{219:} \ \ \ \ \} \\
\mbox{}\texttt{220:}  \\
\mbox{}\texttt{221:} \ \ \ \ \textit{/*\ Troef\ is\ de\ meeste\ kaarten\ in\ handen\ */} \\
\mbox{}\texttt{222:} \ \ \ \ troef\ =\ 0; \\
\mbox{}\texttt{223:} \ \ \ \ \textbf{for}\ (\ int\ i\ =\ 1;\ i\ $<$\ 4;\ i++\ ) \\
\mbox{}\texttt{224:} \ \ \ \ \ \ \ \ \textbf{if}\ (\ kleurAantal[i]\ $>$\ kleurAantal[i\ -\ 1]\ ) \\
\mbox{}\texttt{225:} \ \ \ \ \ \ \ \ \ \ \ \ troef\ =\ i; \\
\mbox{}\texttt{226:}  \\
\mbox{}\texttt{227:} \ \ \ \ \textit{/*\ Elke\ troef\ levert\ een\ slag\ op\ */} \\
\mbox{}\texttt{228:} \ \ \ \ hoogte\ =\ kleurAantal[troef]; \\
\mbox{}\texttt{229:}  \\
\mbox{}\texttt{230:} \ \ \ \ \textit{/*\ Hoogste\ kaart(en)\ leveren\ ook\ slagen\ op\ */} \\
\mbox{}\texttt{231:} \ \ \ \ slagen\ =\ 0; \\
\mbox{}\texttt{232:} \ \ \ \ \textit{/*\ i\ is\ de\ zoekkaart\ */} \\
\mbox{}\texttt{233:} \ \ \ \ \textbf{for}\ (int\ i\ =\ 52;\ i\ $>$=\ 0;)\ \{ \\
\mbox{}\texttt{234:} \ \ \ \ \ \ \ \ \textbf{while}\ (zoekpuntA\ !=\ -1\ \&\&\ dekaarten[spelerA][zoekpuntA]\ $>$\ i) \\
\mbox{}\texttt{235:} \ \ \ \ \ \ \ \ \ \ \ \ zoekpuntA-\/-; \\
\mbox{}\texttt{236:} \ \ \ \ \ \ \ \ \textbf{while}\ (zoekpuntB\ !=\ -1\ \&\&\ dekaarten[spelerB][zoekpuntB]\ $>$\ i) \\
\mbox{}\texttt{237:} \ \ \ \ \ \ \ \ \ \ \ \ zoekpuntB-\/-; \\
\mbox{}\texttt{238:}  \\
\mbox{}\texttt{239:} \ \ \ \ \ \ \ \ \textit{/*\ Hebben\ we\ de\ kaart\ in\ bezit\ of\ moeten\ we\ naar\ een\ aas\ van} \\
\mbox{}\texttt{240:} \textit{\ \ \ \ \ \ \ \ \ *\ een\ andere\ kleur\ gaan\ zoeken\ */} \\
\mbox{}\texttt{241:} \ \ \ \ \ \ \ \ \textbf{if}\ (zoekpuntA\ ==\ -1\ \&\&\ zoekpuntB\ ==\ -1)\ \{ \\
\mbox{}\texttt{242:} \ \ \ \ \ \ \ \ \ \ \ \ \textbf{break}; \\
\mbox{}\texttt{243:} \ \ \ \ \ \ \ \ \}\ \textbf{else}\ \textbf{if}\ (zoekpuntA\ !=\ -1\ \&\&\ dekaarten[spelerA][zoekpuntA]\ ==\ i)\ \{ \\
\mbox{}\texttt{244:} \ \ \ \ \ \ \ \ \ \ \ \ slagen++; \\
\mbox{}\texttt{245:} \ \ \ \ \ \ \ \ \ \ \ \ i-\/-; \\
\mbox{}\texttt{246:} \ \ \ \ \ \ \ \ \}\ \textbf{else}\ \textbf{if}\ (zoekpuntB\ !=\ -1\ \&\&\ dekaarten[spelerB][zoekpuntB]\ ==\ i)\ \{ \\
\mbox{}\texttt{247:} \ \ \ \ \ \ \ \ \ \ \ \ slagen++; \\
\mbox{}\texttt{248:} \ \ \ \ \ \ \ \ \ \ \ \ i-\/-; \\
\mbox{}\texttt{249:} \ \ \ \ \ \ \ \ \}\ \textbf{else}\ \{ \\
\mbox{}\texttt{250:} \ \ \ \ \ \ \ \ \ \ \ \ \textbf{if}\ (\ i\ $<$=\ 13\ )\ \{ \\
\mbox{}\texttt{251:} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textit{/*\ KLAVEREN\ aas\ is\ niet\ in\ bezit\ */} \\
\mbox{}\texttt{252:} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textbf{break}; \\
\mbox{}\texttt{253:} \ \ \ \ \ \ \ \ \ \ \ \ \}\ \textbf{else}\ \{ \\
\mbox{}\texttt{254:} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textit{/*\ Spring\ naar\ de\ volgende\ aas\ */} \\
\mbox{}\texttt{255:} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textbf{if}\ ((i\ \%\ 13)\ ==\ 0) \\
\mbox{}\texttt{256:} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ i\ =\ i\ -\ 13; \\
\mbox{}\texttt{257:} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textbf{else} \\
\mbox{}\texttt{258:} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ i\ =\ i\ -\ (i\ \%\ 13); \\
\mbox{}\texttt{259:} \ \ \ \ \ \ \ \ \ \ \ \ \} \\
\mbox{}\texttt{260:} \ \ \ \ \ \ \ \ \} \\
\mbox{}\texttt{261:} \ \ \ \ \} \\
\mbox{}\texttt{262:} \ \ \ \ hoogte\ =\ hoogte\ +\ slagen; \\
\mbox{}\texttt{263:}  \\
\mbox{}\texttt{264:} \ \ \ \ \textit{/*\ Set\ troef\ naar\ ASCII\ waarde\ om\ */} \\
\mbox{}\texttt{265:} \ \ \ \ troef\ =\ \textbf{dekleur\ }(\ (troef\ +\ 1)\ *\ 13); \\
\mbox{}\texttt{266:} \ \ \ \ \textbf{break}; \\
\mbox{}\texttt{267:} \ \ \} \\
\mbox{}\texttt{268:}  \\
\mbox{}\texttt{269:} \ \ \textbf{if}\ (printdetails)\ \{ \\
\mbox{}\texttt{270:} \ \ \ \ cout\ $<$$<$\ endl\ $<$$<$\ \texttt{"{}=Contract="{}}\ $<$$<$\ endl; \\
\mbox{}\texttt{271:} \ \ \ \ cout\ $<$$<$\ \texttt{"{}Paar\ \ \ :\ "{}}\ $<$$<$\ (\ NZ\ ?\ \texttt{"{}NZ\ "{}}\ :\ \texttt{"{}OW\ "{}}\ )\ $<$$<$\ endl; \\
\mbox{}\texttt{272:} \ \ \ \ cout\ $<$$<$\ \texttt{"{}Slagen\ :\ "{}}\ $<$$<$\ hoogte\ $<$$<$endl; \\
\mbox{}\texttt{273:} \ \ \ \ cout\ $<$$<$\ \texttt{"{}Troef\ \ :\ "{}}\ $<$$<$\ troef\ $<$$<$\ endl\ $<$$<$\ endl; \\
\mbox{}\texttt{274:} \ \ \} \\
\mbox{}\texttt{275:} \}\textit{//spel::maakcontract} \\
\mbox{}\texttt{276:}  \\
\mbox{}\texttt{277:} \textit{//trek\ een\ random\ kaart\ uit\ A\ (die\ er\ aantal\ heeft)} \\
\mbox{}\texttt{278:} \textit{//voorkeur\ voor\ kleur,\ anders\ random} \\
\mbox{}\texttt{279:} int\ spel::\textbf{trekkaart\ }(int\ hoe,\ char\ kleur,\ int\ A[\ ],\ int\ aantal)\ \{ \\
\mbox{}\texttt{280:} \ \ int\ j,\ i\ =\ \textbf{rand\ }(\ )\ \%\ aantal,\ vanaf,\ totenmet,\ dekaart; \\
\mbox{}\texttt{281:} \ \ int\ hoogstekaart\ =\ 0; \\
\mbox{}\texttt{282:} \ \ bool\ heeftkleur\ =\ \textbf{false}; \\
\mbox{}\texttt{283:}  \\
\mbox{}\texttt{284:} \ \ \textit{/*\ Bepaal\ of\ gevraagde\ kleur\ in\ bezit\ is\ */} \\
\mbox{}\texttt{285:} \ \ \textbf{for}\ (\ j\ =\ 0;\ j\ $<$\ aantal;\ j++\ )\ \{ \\
\mbox{}\texttt{286:} \ \ \ \ \textbf{if}\ (\ \textbf{dekleur\ }(A[j])\ ==\ kleur\ )\ \{ \\
\mbox{}\texttt{287:} \ \ \ \ \ \ \textbf{if}\ (\ heeftkleur\ ) \\
\mbox{}\texttt{288:} \ \ \ \ \ \ \ \ totenmet\ =\ j; \\
\mbox{}\texttt{289:} \ \ \ \ \ \ \textbf{else} \\
\mbox{}\texttt{290:} \ \ \ \ \ \ \ \ totenmet\ =\ vanaf\ =\ j; \\
\mbox{}\texttt{291:} \ \ \ \ \ \ heeftkleur\ =\ \textbf{true}; \\
\mbox{}\texttt{292:} \ \ \ \ \}\textit{//if} \\
\mbox{}\texttt{293:} \ \ \}\textit{//for} \\
\mbox{}\texttt{294:}  \\
\mbox{}\texttt{295:} \ \ \textbf{switch}\ (hoe)\ \{ \\
\mbox{}\texttt{296:} \ \ \textbf{case}\ NIVEAU$\_$RANDOM: \\
\mbox{}\texttt{297:} \ \ \ \ \textbf{if}\ (\ heeftkleur\ ) \\
\mbox{}\texttt{298:} \ \ \ \ \ \ i\ =\ vanaf\ +\ \textbf{rand\ }(\ )\ \%\ (\ totenmet\ -\ vanaf\ +\ 1\ ); \\
\mbox{}\texttt{299:} \ \ \ \ \textbf{break}; \\
\mbox{}\texttt{300:} \ \ \textbf{case}\ NIVEAU$\_$SLIM: \\
\mbox{}\texttt{301:} \ \ \ \ \textit{/*\ Als\ eerste\ kiezen,\ levert\ bepaalde\ privileges\ */} \\
\mbox{}\texttt{302:} \ \ \ \ \textbf{if}\ (\ kleur\ ==\ \texttt{'X'}\ )\ \{ \\
\mbox{}\texttt{303:} \ \ \ \ \ \ \ \ \textit{/*\ bepalen\ beste\ kaart,\ hoogste\ troef,\ dan\ hoogste\ andere\ kaart\ */} \\
\mbox{}\texttt{304:} \ \ \ \ \ \ \ \ \textbf{for}\ (\ j\ =\ 1;\ j\ $<$\ aantal;\ j++\ )\ \{ \\
\mbox{}\texttt{305:} \ \ \ \ \ \ \ \ \ \ \ \ \textbf{if}\ (\ \textbf{dewaarde\ }(A[j])\ \ $>$\ \textbf{dewaarde\ }(hoogstekaart)\ )\ \{ \\
\mbox{}\texttt{306:} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ hoogstekaart\ =\ j; \\
\mbox{}\texttt{307:} \ \ \ \ \ \ \ \ \ \ \ \ \}\ \textbf{else}\ \textbf{if}\ (\ \textbf{dewaarde\ }(A[j])\ ==\ \textbf{dewaarde\ }(hoogstekaart)\ )\ \{ \\
\mbox{}\texttt{308:} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textit{/*\ Troef\ is\ beter\ */} \\
\mbox{}\texttt{309:} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textbf{if}\ (\ \textbf{dekleur\ }(A[j])\ ==\ troef\ )\ \{ \\
\mbox{}\texttt{310:} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ hoogstekaart\ =\ j; \\
\mbox{}\texttt{311:} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \} \\
\mbox{}\texttt{312:} \ \ \ \ \ \ \ \ \ \ \ \ \} \\
\mbox{}\texttt{313:} \ \ \ \ \ \ \ \ \} \\
\mbox{}\texttt{314:} \ \ \ \ \ \ \ \ i\ =\ hoogstekaart; \\
\mbox{}\texttt{315:} \ \ \ \ \ \ \ \ \textbf{break}; \\
\mbox{}\texttt{316:} \ \ \ \ \} \\
\mbox{}\texttt{317:}  \\
\mbox{}\texttt{318:} \ \ \ \ \textit{/*\ Troef\ spelen,\ levert\ aparte\ regels\ */} \\
\mbox{}\texttt{319:} \ \ \ \ \textbf{if}\ (\ kleur\ ==\ troef\ )\ \{ \\
\mbox{}\texttt{320:} \ \ \ \ \ \ \ \ \textit{/*\ Hoogste\ troef\ als\ present,\ anders\ laagste\ kaart\ */} \\
\mbox{}\texttt{321:} \ \ \ \ \ \ \ \ \textbf{if}\ (\ heeftkleur\ ) \\
\mbox{}\texttt{322:} \ \ \ \ \ \ \ \ \ \ \ \ i\ =\ totenmet; \\
\mbox{}\texttt{323:} \ \ \ \ \ \ \ \ \textbf{else} \\
\mbox{}\texttt{324:} \ \ \ \ \ \ \ \ \ \ \ \ i\ =\ 0; \\
\mbox{}\texttt{325:} \ \ \ \ \ \ \ \ \textbf{break}; \\
\mbox{}\texttt{326:} \ \ \ \ \} \\
\mbox{}\texttt{327:}  \\
\mbox{}\texttt{328:} \ \ \ \ \textit{/*\ Als\ kleur\ present\ dan\ meespelen\ met\ hoogste\ kaart\ */} \\
\mbox{}\texttt{329:} \ \ \ \ \textbf{if}\ (\ heeftkleur\ )\ \{ \\
\mbox{}\texttt{330:} \ \ \ \ \ \ \ \ i\ =\ totenmet; \\
\mbox{}\texttt{331:} \ \ \ \ \ \ \ \ \textbf{break}; \\
\mbox{}\texttt{332:} \ \ \ \ \} \\
\mbox{}\texttt{333:}  \\
\mbox{}\texttt{334:} \ \ \ \ \textit{/*\ Bij\ ontbreken\ van\ kleur,\ bepaal\ of\ troef\ present\ is\ \ */} \\
\mbox{}\texttt{335:} \ \ \ \ \textbf{for}\ (\ j\ =\ 0;\ j\ $<$\ aantal;\ j++\ ) \\
\mbox{}\texttt{336:} \ \ \ \ \ \ \textbf{if}\ (\ \textbf{dekleur\ }(A[j])\ ==\ troef\ )\ \{ \\
\mbox{}\texttt{337:} \ \ \ \ \ \ \ \ \textbf{if}\ (\ heeftkleur\ ) \\
\mbox{}\texttt{338:} \ \ \ \ \ \ \ \ \ \ totenmet\ =\ j; \\
\mbox{}\texttt{339:} \ \ \ \ \ \ \ \ \textbf{else} \\
\mbox{}\texttt{340:} \ \ \ \ \ \ \ \ \ \ totenmet\ =\ vanaf\ =\ j; \\
\mbox{}\texttt{341:} \ \ \ \ \ \ \ \ heeftkleur\ =\ \textbf{true}; \\
\mbox{}\texttt{342:} \ \ \ \ \ \ \}\textit{//if} \\
\mbox{}\texttt{343:} \ \ \ \ \textit{/*\ 'Steel'\ het\ slag\ door\ kleinste\ troefje\ te\ spelen\ */} \\
\mbox{}\texttt{344:} \ \ \ \ \textbf{if}\ (\ heeftkleur\ )\ \{ \\
\mbox{}\texttt{345:} \ \ \ \ \ \ \ \ i\ =\ vanaf; \\
\mbox{}\texttt{346:} \ \ \ \ \ \ \ \ \textbf{break}; \\
\mbox{}\texttt{347:} \ \ \ \ \} \\
\mbox{}\texttt{348:}  \\
\mbox{}\texttt{349:} \ \ \ \ \textit{/*\ Niets\ kunnen\ betekenen\ hier,\ laagste\ kaart\ dan\ maar\ ;-)\ */} \\
\mbox{}\texttt{350:} \ \ \ \ i\ =\ 0; \\
\mbox{}\texttt{351:} \ \ \ \ \textbf{break}; \\
\mbox{}\texttt{352:} \ \ \} \\
\mbox{}\texttt{353:}  \\
\mbox{}\texttt{354:} \ \ \textit{/*\ Doe\ de\ boekhouding\ en\ werk\ het\ de\ eigen\ hand\ bij\ */} \\
\mbox{}\texttt{355:} \ \ dekaart\ =\ A[i]; \\
\mbox{}\texttt{356:} \ \ \textbf{for}\ (\ j\ =\ i;\ j\ $<$\ aantal-1;\ j++\ ) \\
\mbox{}\texttt{357:} \ \ \ \ A[j]\ =\ A[j+1]; \\
\mbox{}\texttt{358:} \ \ A[aantal-1]\ =\ 0; \\
\mbox{}\texttt{359:} \ \ \textbf{return}\ dekaart; \\
\mbox{}\texttt{360:} \}\textit{//spel::trekkaart} \\
\mbox{}\texttt{361:}  \\
\mbox{}\texttt{362:} \textit{//speel\ af;\ printdetails\ geeft\ meer\ informatie} \\
\mbox{}\texttt{363:} void\ spel::\textbf{afspelen\ }(int\ speeltype,\ bool\ printdetails)\ \{ \\
\mbox{}\texttt{364:} \ \ int\ speler,\ winnaar,\ hoogste,\ winkleur,\ vraagkleur; \\
\mbox{}\texttt{365:} \ \ int\ kaart[\ ]\ =\ \{0,\ 0,\ 0,\ 0\}; \\
\mbox{}\texttt{366:} \ \ int\ buurt\ =\ 1; \\
\mbox{}\texttt{367:}  \\
\mbox{}\texttt{368:} \ \ \textit{/*\ Laat\ random\ speler\ \ beginnen\ */} \\
\mbox{}\texttt{369:} \ \ speler\ =\ \textbf{rand\ }(\ )\ \%\ 4;\ \textit{//\ 0123} \\
\mbox{}\texttt{370:}  \\
\mbox{}\texttt{371:} \ \ \textbf{if}\ (printdetails)\ \{ \\
\mbox{}\texttt{372:} \ \ \ \ cout\ $<$$<$\ \texttt{"{}=Spel="{}}\ $<$$<$endl; \\
\mbox{}\texttt{373:} \ \ \ \ cout\ $<$$<$\ \texttt{"{}S\ =\ Speelt,\ Kx\ =\ Kaart\ x"{}}\ $<$$<$\ endl; \\
\mbox{}\texttt{374:} \ \ \ \ cout\ $<$$<$\ \texttt{"{}Noord\ -$>$\ Oost\ -$>$\ Zuid\ -$>$\ West\ -$>$\ Noord\ -\/-$>$\ Oost\ -$>$\ Zuid"{}}\ $<$$<$endl; \\
\mbox{}\texttt{375:} \ \ \ \ cout\ $<$$<$\ \texttt{"{}Buurt\ $|$\ S\ $|$\ K1\ \ $|$\ K2\ \ $|$\ K3\ \ $|$\ K4\ \ $|$\ Winnaar\ $|$"{}}\ $<$$<$\ endl; \\
\mbox{}\texttt{376:} \ \ \ \ cout\ $<$$<$\ \texttt{"{}-\/-\/--\/-\/-$|$-\/-\/-$|$-\/-\/--\/-$|$-\/-\/--\/-$|$-\/-\/--\/-$|$-\/-\/--\/-$|$-\/-\/--\/-\/--\/-\/-$|$"{}}\ $<$$<$\ endl; \\
\mbox{}\texttt{377:} \ \ \} \\
\mbox{}\texttt{378:}  \\
\mbox{}\texttt{379:} \ \ \textbf{switch}\ (speeltype)\ \{ \\
\mbox{}\texttt{380:} \ \ \textbf{case}\ SPEEL$\_$KOSTER$\_$BRIDGE: \\
\mbox{}\texttt{381:} \ \ \ \ \textbf{while}\ (\ aantalkaarten\ $>$\ 0\ )\ \{ \\
\mbox{}\texttt{382:} \ \ \ \ \ \ \textbf{if}\ (printdetails)\ \{ \\
\mbox{}\texttt{383:} \ \ \ \ \ \ \ \ \textbf{if}\ (\ buurt\ $<$\ 10\ ) \\
\mbox{}\texttt{384:} \ \ \ \ \ \ \ \ \ \ cout\ $<$$<$\ \texttt{"{}\ "{}}; \\
\mbox{}\texttt{385:} \ \ \ \ \ \ \ \ cout\ $<$$<$\ buurt\ $<$$<$\ \texttt{"{}\ \ \ \ $|$\ "{}}; \\
\mbox{}\texttt{386:} \ \ \ \ \ \ \} \\
\mbox{}\texttt{387:}  \\
\mbox{}\texttt{388:} \ \ \ \ \ \ \textit{/*\ Initiele\ kaart,\ geen\ voorkeur\ voor\ kleur\ */} \\
\mbox{}\texttt{389:} \ \ \ \ \ \ kaart[0]\ =\ \textbf{trekkaart\ }(spelerniveau[speler],\texttt{'X'},dekaarten[speler], \\
\mbox{}\texttt{390:} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ aantalkaarten); \\
\mbox{}\texttt{391:} \ \ \ \ \ \ vraagkleur\ =\ \textbf{dekleur\ }(kaart[0]); \\
\mbox{}\texttt{392:} \ \ \ \ \ \ \textbf{if}\ (\ printdetails\ )\ \{ \\
\mbox{}\texttt{393:} \ \ \ \ \ \ \ \ cout\ $<$$<$\ \textbf{despeler\ }(speler)\ $<$$<$\ \texttt{"{}\ $|$\ "{}}; \\
\mbox{}\texttt{394:} \ \ \ \ \ \ \ \ \textbf{printkaart\ }(kaart[0]); \\
\mbox{}\texttt{395:} \ \ \ \ \ \ \ \ cout\ $<$$<$\ \texttt{"{}\ $|$\ "{}}; \\
\mbox{}\texttt{396:} \ \ \ \ \ \ \}\textit{//if} \\
\mbox{}\texttt{397:}  \\
\mbox{}\texttt{398:} \ \ \ \ \ \ \textit{/*\ Laat\ de\ rest\ bijspelen\ */} \\
\mbox{}\texttt{399:} \ \ \ \ \ \ \textbf{for}\ (int\ i\ =\ 1;\ i\ $<$=\ 3;\ i++)\ \{ \\
\mbox{}\texttt{400:} \ \ \ \ \ \ \ \ kaart[i]\ =\ \textbf{trekkaart\ }(spelerniveau[i],\ vraagkleur, \\
\mbox{}\texttt{401:} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ dekaarten[(speler+i)\%4],aantalkaarten); \\
\mbox{}\texttt{402:} \ \ \ \ \ \ \ \ \textbf{if}\ (\ printdetails\ )\ \{ \\
\mbox{}\texttt{403:} \ \ \ \ \ \ \ \ \ \ \textbf{printkaart\ }(kaart[i]); \\
\mbox{}\texttt{404:} \ \ \ \ \ \ \ \ \ \ cout\ $<$$<$\ \texttt{"{}\ $|$\ "{}}; \\
\mbox{}\texttt{405:} \ \ \ \ \ \ \ \ \}\textit{//if} \\
\mbox{}\texttt{406:} \ \ \ \ \ \ \} \\
\mbox{}\texttt{407:}  \\
\mbox{}\texttt{408:} \ \ \ \ \ \ aantalkaarten-\/-; \\
\mbox{}\texttt{409:}  \\
\mbox{}\texttt{410:} \ \ \ \ \ \ \textit{/*\ controleer\ troef\ in\ het\ spel\ */} \\
\mbox{}\texttt{411:} \ \ \ \ \ \ \textbf{if}\ (\ \textbf{dekleur}(kaart[0])\ ==\ troef\ $|$$|$\ \textbf{dekleur}(kaart[1])\ ==\ troef\  \\
\mbox{}\texttt{412:} \ \ \ \ \ \ \ \ \ \ \ $|$$|$\ \textbf{dekleur}(kaart[2])\ ==\ troef\ $|$$|$\ \textbf{dekleur}(kaart[3])\ ==\ troef\ ) \\
\mbox{}\texttt{413:} \ \ \ \ \ \ winkleur\ =\ troef; \\
\mbox{}\texttt{414:} \ \ \ \ \ \ \textbf{else} \\
\mbox{}\texttt{415:} \ \ \ \ \ \ \ \ winkleur\ =\ \textbf{dekleur\ }(kaart[0]); \\
\mbox{}\texttt{416:}  \\
\mbox{}\texttt{417:} \ \ \ \ \ \ \textit{/*\ bepaal\ de\ winnende\ spelers\ */} \\
\mbox{}\texttt{418:} \ \ \ \ \ \ hoogste\ =\ -1; \\
\mbox{}\texttt{419:} \ \ \ \ \ \ \textbf{if}\ (\ \textbf{dekleur\ }(kaart[0])\ ==\ winkleur\ \&\&\ kaart[0]\ $>$\ hoogste\ )\ \{ \\
\mbox{}\texttt{420:} \ \ \ \ \ \ \ \ winnaar\ =\ speler; \\
\mbox{}\texttt{421:} \ \ \ \ \ \ \ \ hoogste\ =\ kaart[0]; \\
\mbox{}\texttt{422:} \ \ \ \ \ \ \}\textit{//if} \\
\mbox{}\texttt{423:} \ \ \ \ \ \ \textbf{if}\ (\ \textbf{dekleur\ }(kaart[1])\ ==\ winkleur\ \&\&\ kaart[1]\ $>$\ hoogste\ )\ \{ \\
\mbox{}\texttt{424:} \ \ \ \ \ \ \ \ winnaar\ =\ (speler+1)\ \%\ 4; \\
\mbox{}\texttt{425:} \ \ \ \ \ \ \ \ hoogste\ =\ kaart[1]; \\
\mbox{}\texttt{426:} \ \ \ \ \ \ \}\textit{//if} \\
\mbox{}\texttt{427:} \ \ \ \ \ \ \textbf{if}\ (\ \textbf{dekleur\ }(kaart[2])\ ==\ winkleur\ \&\&\ kaart[2]\ $>$\ hoogste\ )\ \{ \\
\mbox{}\texttt{428:} \ \ \ \ \ \ \ \ winnaar\ =\ (speler+2)\ \%\ 4; \\
\mbox{}\texttt{429:} \ \ \ \ \ \ \ \ hoogste\ =\ kaart[2]; \\
\mbox{}\texttt{430:} \ \ \ \ \ \ \}\textit{//if} \\
\mbox{}\texttt{431:} \ \ \ \ \ \ \textbf{if}\ (\ \textbf{dekleur\ }(kaart[3])\ ==\ winkleur\ \&\&\ kaart[3]\ $>$\ hoogste\ )\ \{ \\
\mbox{}\texttt{432:} \ \ \ \ \ \ \ \ winnaar\ =\ (speler+3)\ \%\ 4; \\
\mbox{}\texttt{433:} \ \ \ \ \ \ \ \ hoogste\ =\ kaart[3]; \\
\mbox{}\texttt{434:} \ \ \ \ \ \ \}\textit{//if} \\
\mbox{}\texttt{435:}  \\
\mbox{}\texttt{436:} \ \ \ \ \ \ \textbf{if}\ (\ printdetails\ )\ \{ \\
\mbox{}\texttt{437:} \ \ \ \ \ \ \ \ cout\ $<$$<$\ \textbf{despeler\ }(winnaar)\ $<$$<$\ \texttt{"{}\ \ \ \ \ \ \ $|$"{}}\ $<$$<$\ endl; \\
\mbox{}\texttt{438:} \ \ \ \ \ \ \}\textit{//if} \\
\mbox{}\texttt{439:} \ \ \ \ \ \ \textbf{if}\ (\ winnaar\ ==\ 0\ $|$$|$\ winnaar\ ==\ 2\ ) \\
\mbox{}\texttt{440:} \ \ \ \ \ \ \ \ slagenNZ++; \\
\mbox{}\texttt{441:} \ \ \ \ \ \ \textbf{else} \\
\mbox{}\texttt{442:} \ \ \ \ \ \ \ \ slagenOW++; \\
\mbox{}\texttt{443:} \ \ \ \ \ \ speler\ =\ winnaar; \\
\mbox{}\texttt{444:}  \\
\mbox{}\texttt{445:} \ \ \ \ \ \ buurt++; \\
\mbox{}\texttt{446:} \ \ \ \ \}\textit{//while} \\
\mbox{}\texttt{447:} \ \ \ \ \textbf{break}; \\
\mbox{}\texttt{448:} \ \ \}\textit{//switch} \\
\mbox{}\texttt{449:} \}\textit{//spel::afspelen} \\
\mbox{}\texttt{450:}  \\
\mbox{}\texttt{451:} \textit{//uitslag\ op\ scherm} \\
\mbox{}\texttt{452:} int\ spel::\textbf{uitslag\ }(bool\ printdetails)\ \{ \\
\mbox{}\texttt{453:} \ \ int\ slagen\ =\ (\ NZ\ ?\ slagenNZ\ :\ slagenOW); \\
\mbox{}\texttt{454:} \ \ \textbf{if}\ (printdetails)\ \{ \\
\mbox{}\texttt{455:} \ \ \ \ cout\ $<$$<$\ \texttt{"{}=Uitslag="{}}\ $<$$<$\ endl; \\
\mbox{}\texttt{456:} \ \ \ \ cout\ $<$$<$\ \texttt{"{}Slagen\ NZ\ \ \ \ \ \ \ :\ "{}}\ $<$$<$\ slagenNZ\ $<$$<$\ endl; \\
\mbox{}\texttt{457:} \ \ \ \ cout\ $<$$<$\ \texttt{"{}Slagen\ OW\ \ \ \ \ \ \ :\ "{}}\ $<$$<$\ slagenOW\ $<$$<$\ endl; \\
\mbox{}\texttt{458:} \ \ \ \ cout\ $<$$<$\ \texttt{"{}Contract\ bod\ \ \ \ :\ "{}}\ $<$$<$\ hoogte\ $<$$<$\ endl; \\
\mbox{}\texttt{459:} \ \ \ \ cout\ $<$$<$\ \texttt{"{}Contract\ paar\ \ \ :\ "{}}\ $<$$<$\ (\ NZ\ ?\ \texttt{"{}NZ\ "{}}\ :\ \texttt{"{}OW\ "{}}\ )\ $<$$<$\ endl; \\
\mbox{}\texttt{460:} \ \ \ \ cout\ $<$$<$\ \texttt{"{}Contact\ gehaald\ :\ "{}}; \\
\mbox{}\texttt{461:} \ \ \} \\
\mbox{}\texttt{462:} \ \ \textbf{if}\ (\ slagen\ $<$\ hoogte\ )\ \{ \\
\mbox{}\texttt{463:} \ \ \ \ \textbf{if}\ (printdetails) \\
\mbox{}\texttt{464:} \ \ \ \ \ \ cout\ $<$$<$\ \texttt{"{}TEKORT"{}}; \\
\mbox{}\texttt{465:} \ \ \}\ \textbf{else}\ \textbf{if}\ (\ slagen\ ==\ hoogte\ )\ \{ \\
\mbox{}\texttt{466:} \ \ \ \ \textbf{if}\ (printdetails) \\
\mbox{}\texttt{467:} \ \ \ \ \ \ cout\ $<$$<$\ \texttt{"{}CORRECT"{}}; \\
\mbox{}\texttt{468:} \ \ \}\ \textbf{else}\ \{ \\
\mbox{}\texttt{469:} \ \ \ \ \textbf{if}\ (printdetails) \\
\mbox{}\texttt{470:} \ \ \ \ \ \ cout\ $<$$<$\ \texttt{"{}TEVEEL"{}}; \\
\mbox{}\texttt{471:} \ \ \} \\
\mbox{}\texttt{472:} \ \ \textbf{if}\ (printdetails) \\
\mbox{}\texttt{473:} \ \ \ \ cout\ $<$$<$\ \texttt{"{}\ ("{}}\ $<$$<$\ slagen\ -\ hoogte\ $<$$<$\ \texttt{"{})"{}}\ $<$$<$\ endl; \\
\mbox{}\texttt{474:}  \\
\mbox{}\texttt{475:} \ \ \textbf{return}\ (slagen\ -\ hoogte); \\
\mbox{}\texttt{476:} \}\textit{//spel::uitslag} \\
\mbox{}\texttt{477:}  \\
\mbox{}\texttt{478:} \textit{//===} \\
\mbox{}\texttt{479:}  \\
\mbox{}\texttt{480:} void\ \textbf{printTotaalWaarde\ }(string\ type,\ double\ waarde,\ double\ totaal)\ \{ \\
\mbox{}\texttt{481:} \ \ \ \ cout\ $<$$<$\ \textbf{setiosflags}(ios::left); \\
\mbox{}\texttt{482:} \ \ \ \ cout\ $<$$<$\ \textbf{setw}(10)\ $<$$<$\ type\ $<$$<$\ \texttt{"{}\ :\ "{}}; \\
\mbox{}\texttt{483:} \ \ \ \ cout\ $<$$<$\ \textbf{resetiosflags}(ios::left); \\
\mbox{}\texttt{484:} \ \ \ \ double\ percent\ =\ (waarde\ /\ totaal)\ *\ 100; \\
\mbox{}\texttt{485:} \ \ \ \ cout.\textbf{precision}(8); \\
\mbox{}\texttt{486:} \ \ \ \ cout\ $<$$<$\ \textbf{setw}(8)\ $<$$<$\ waarde; \\
\mbox{}\texttt{487:} \ \ \ \ cout\ $<$$<$\ \texttt{"{}\ =\ "{}}; \\
\mbox{}\texttt{488:} \ \ \ \ cout.\textbf{precision}(2); \\
\mbox{}\texttt{489:} \ \ \ \ cout\ $<$$<$\ \textbf{setw}(7)\ $<$$<$\ \textbf{setiosflags}(ios::fixed)\ $<$$<$\ percent \\
\mbox{}\texttt{490:} \ \ \ \ $<$$<$\textbf{resetiosflags}(ios::fixed)\ $<$$<$\ \texttt{"{}\%"{}}; \\
\mbox{}\texttt{491:} \ \ \ \ cout\ $<$$<$\ endl; \\
\mbox{}\texttt{492:}  \\
\mbox{}\texttt{493:} \}; \\
\mbox{}\texttt{494:}  \\
\mbox{}\texttt{495:} int\ \textbf{main\ }(\ )\ \{ \\
\mbox{}\texttt{496:} \ \ int\ retcode\ =\ 0; \\
\mbox{}\texttt{497:} \ \ int\ tekort\ =\ 0; \\
\mbox{}\texttt{498:} \ \ int\ correct\ =\ 0; \\
\mbox{}\texttt{499:} \ \ int\ teveel\ =\ 0; \\
\mbox{}\texttt{500:} \ \ double\ eindscore\ =\ 0; \\
\mbox{}\texttt{501:} \ \ int\ fout,\ goed; \\
\mbox{}\texttt{502:}  \\
\mbox{}\texttt{503:} \ \ spel\ S; \\
\mbox{}\texttt{504:} \ \ int\ randInit; \\
\mbox{}\texttt{505:}  \\
\mbox{}\texttt{506:} \ \ \textit{/*\ Variabelen\ */} \\
\mbox{}\texttt{507:} \ \ int\ logNiveau\ =\ SILENT;\ \textit{/*\ print\ niveau\ SILENT$|$VERBOSE\ */} \\
\mbox{}\texttt{508:} \ \ double\ aantalKeer\ =\ 1000;\ \ \textit{/*\ aantal\ rondes\ */} \\
\mbox{}\texttt{509:}  \\
\mbox{}\texttt{510:} \ \ \textit{/*\ initialiseer\ random-generator,\ maar\ print\ seed\ om\ debugging} \\
\mbox{}\texttt{511:} \textit{\ \ \ *\ mogelijk\ te\ maken} \\
\mbox{}\texttt{512:} \textit{\ \ \ */} \\
\mbox{}\texttt{513:} \ \ randInit\ =\ \textbf{time}(0); \\
\mbox{}\texttt{514:} \ \ cout\ $<$$<$\ \texttt{"{}RandInit\ getal:\ "{}}\ $<$$<$\ randInit\ $<$$<$\ endl; \\
\mbox{}\texttt{515:} \ \ \textbf{srand\ }(randInit);\  \\
\mbox{}\texttt{516:}  \\
\mbox{}\texttt{517:} \ \ \textit{/*\ Speel\ de\ potjes\ */} \\
\mbox{}\texttt{518:} \ \ \textbf{for}\ (int\ i\ =\ 0;\ i\ $<$\ aantalKeer;\ i++)\ \{ \\
\mbox{}\texttt{519:} \ \ \ \ S.\textbf{schud\ }(\ ); \\
\mbox{}\texttt{520:} \ \ \ \ \textbf{if}\ (logNiveau) \\
\mbox{}\texttt{521:} \ \ \ \ \ \ S.\textbf{print\ }(\ ); \\
\mbox{}\texttt{522:}  \\
\mbox{}\texttt{523:} \ \ \ \ \textit{/*\ Niveau\ contract\ en\ spelers\ */} \\
\mbox{}\texttt{524:} \ \ \ \ S.\textbf{maakcontract\ }(CONTRACT$\_$RANDOM,\ logNiveau); \\
\mbox{}\texttt{525:} \ \ \ \ S.spelerniveau[0]\ =\ NIVEAU$\_$SLIM; \\
\mbox{}\texttt{526:} \ \ \ \ S.spelerniveau[1]\ =\ NIVEAU$\_$RANDOM; \\
\mbox{}\texttt{527:} \ \ \ \ S.spelerniveau[2]\ =\ NIVEAU$\_$RANDOM; \\
\mbox{}\texttt{528:} \ \ \ \ S.spelerniveau[3]\ =\ NIVEAU$\_$RANDOM; \\
\mbox{}\texttt{529:} \ \ \ \ \textbf{if}\ (logNiveau) \\
\mbox{}\texttt{530:} \ \ \ \ \ \ \ \ \textbf{for}\ (int\ i\ =\ 0;\ i\ $<$=\ 3;\ i++) \\
\mbox{}\texttt{531:} \ \ \ \ \ \ \ \ \ \ \ \ cout\ $<$$<$\ \texttt{"{}Niveau\ speler\ "{}}\ $<$$<$\ i\ $<$$<$\ \texttt{"{}:"{}}\ $<$$<$\ S.spelerniveau[i]\ $<$$<$\ endl; \\
\mbox{}\texttt{532:}  \\
\mbox{}\texttt{533:} \ \ \ \ \textit{/*\ Afspelen\ bepaal\ type\ spel\ */} \\
\mbox{}\texttt{534:} \ \ \ \ S.\textbf{afspelen\ }(SPEEL$\_$KOSTER$\_$BRIDGE,\ logNiveau); \\
\mbox{}\texttt{535:}  \\
\mbox{}\texttt{536:} \ \ \ \ \textbf{if}\ (logNiveau) \\
\mbox{}\texttt{537:} \ \ \ \ \ \ cout\ $<$$<$\ endl; \\
\mbox{}\texttt{538:} \ \ \ \ retcode\ =\ S.\textbf{uitslag\ }(logNiveau); \\
\mbox{}\texttt{539:}  \\
\mbox{}\texttt{540:} \ \ \ \ \textit{/*\ Boekhouding,\ voor\ de\ eindscore\ berekening\ */} \\
\mbox{}\texttt{541:} \ \ \ \ \textbf{if}\ (retcode\ $>$\ 0)\ \{ \\
\mbox{}\texttt{542:} \ \ \ \ \ \ \ \ teveel++; \\
\mbox{}\texttt{543:} \ \ \ \ \ \ \ \ \textit{/*\ elk\ punt\ teveel\ score:\ -10\ */} \\
\mbox{}\texttt{544:} \ \ \ \ \ \ \ \ eindscore\ =\ eindscore\ +\ retcode\ *\ -10; \\
\mbox{}\texttt{545:} \ \ \ \ \}\ \textbf{else}\ \textbf{if}\ (retcode\ ==\ 0)\ \{ \\
\mbox{}\texttt{546:} \ \ \ \ \ \ \ \ correct++; \\
\mbox{}\texttt{547:} \ \ \ \ \ \ \ \ \textit{/*\ elk\ goede\ score\ +20\ */} \\
\mbox{}\texttt{548:} \ \ \ \ \ \ \ \ eindscore\ =\ eindscore\ +\ 20; \\
\mbox{}\texttt{549:} \ \ \ \ \}\ \textbf{else}\ \{ \\
\mbox{}\texttt{550:} \ \ \ \ \ \ \ \ tekort++; \\
\mbox{}\texttt{551:} \ \ \ \ \ \ \ \ \textit{/*\ elk\ punt\ tekort\ score:\ -20\ } \\
\mbox{}\texttt{552:} \textit{\ \ \ \ \ \ \ \ \ *\ retcode\ is\ al\ negatief} \\
\mbox{}\texttt{553:} \textit{\ \ \ \ \ \ \ \ \ */} \\
\mbox{}\texttt{554:} \ \ \ \ \ \ \ \ eindscore\ =\ eindscore\ +\ (retcode\ *\ 20); \\
\mbox{}\texttt{555:} \ \ \ \ \} \\
\mbox{}\texttt{556:} \ \ \} \\
\mbox{}\texttt{557:}  \\
\mbox{}\texttt{558:} \ \ \textit{/*\ Bereken\ eindresultaat\ */} \\
\mbox{}\texttt{559:} \ \ fout\ =\ tekort\ +\ teveel; \\
\mbox{}\texttt{560:} \ \ goed\ =\ correct; \\
\mbox{}\texttt{561:} \ \ \textbf{printTotaalWaarde}(\texttt{"{}Tekort"{}},\ tekort,\ \ aantalKeer); \\
\mbox{}\texttt{562:} \ \ \textbf{printTotaalWaarde}(\texttt{"{}Correct"{}},\ correct,\ \ aantalKeer); \\
\mbox{}\texttt{563:} \ \ \textbf{printTotaalWaarde}(\texttt{"{}Teveel"{}},\ teveel,\ \ aantalKeer); \\
\mbox{}\texttt{564:} \ \ cout\ $<$$<$\ endl; \\
\mbox{}\texttt{565:} \ \ \textbf{printTotaalWaarde}(\texttt{"{}Goed"{}},\ goed,\ \ aantalKeer); \\
\mbox{}\texttt{566:} \ \ \textbf{printTotaalWaarde\ }(\texttt{"{}Fout"{}},\ fout,\ aantalKeer); \\
\mbox{}\texttt{567:} \ \ \textbf{printTotaalWaarde\ }(\texttt{"{}EindScore"{}},\ eindscore,\ aantalKeer\ *\ 20); \\
\mbox{}\texttt{568:} \}\textit{//main} \\
\mbox{}\texttt{569:}  \\

