【開催】囚人のジレンマ大会
■ このスレッドは過去ログ倉庫に格納されています
0049デフォルトの名無しさん
NGNG> for ( round = 1; round <= 1000; round ++ ) {
> result_a[round] = a;
> result_b[round] = b;
こんなことやってるし、
自分が a なのか b なのかわかってないとコード書けないし、
>>1のコードのままだと総当たりやるの大変そうなので
適当に書き直してみました。
こんな感じに書き直して実行してください。
int prisoner_a(int round, int *result_a, int *result_b) /* 最強しっぺ返し君 */
{
if ( round == 0 ) return 0;
if ( result_b[ round - 1 ] == 0 ) return 1; else return 0;
}
int prisoner_b(int round, int *result_a, int *result_b) /* 人間不信裏切り君 */
{
return 1;
}
int hoge(int round, int *own, int *opposite)
{
if ( round == 0 ) return 0;
return (own[round-1] != opposite[round-1]) ? Cooperate : Defect;
}
int random(int round, int *own, int *opposite)
{
return rand()%2;
}
const prisoner_t prisoners[] = {prisoner_a, prisoner_b, hoge, random};
■ このスレッドは過去ログ倉庫に格納されています