2004年06月06日

setvalue.c(2)

void SetCoefficient( short level, short ch )
{
if( level == 0 ) {
if( CmpC == Black ) {
CornerCoefficient = 10;
CornerMoveCoefficient = 2;
MoveCoefficient = 1;
NumberCoefficient = 3;
WallCoefficient = 4;
if( ch > 22 ) {
CornerCoefficient = 9;
CornerMoveCoefficient = 2;
MoveCoefficient = 2;
NumberCoefficient = 2;
WallCoefficient = 3;
}
if( ch > 32 ) {
CornerCoefficient = 8;
CornerMoveCoefficient = 5;
MoveCoefficient = 2;
NumberCoefficient = 2;
WallCoefficient = 3;
}
if( ch > 42 ) {
CornerCoefficient = 12;
CornerMoveCoefficient = 3;
MoveCoefficient = 2;
NumberCoefficient = 1;
WallCoefficient = 2;
}
}
else {
CornerCoefficient = 12;
CornerMoveCoefficient = 2;
MoveCoefficient = 1;
NumberCoefficient = 3;
WallCoefficient = 2;
if( ch > 22 ) {
CornerCoefficient = 12;
CornerMoveCoefficient = 2;
MoveCoefficient = 1;
NumberCoefficient = 3;
WallCoefficient = 2;
}
if( ch > 32 ) {
CornerCoefficient = 12;
CornerMoveCoefficient = 2;
MoveCoefficient = 2;
NumberCoefficient = 2;
WallCoefficient = 2;
}
if( ch > 42 ) {
CornerCoefficient = 14;
CornerMoveCoefficient = 2;
MoveCoefficient = 2;
NumberCoefficient = 1;
WallCoefficient = 1;
}
if( ch > 52 ) {
CornerCoefficient = 12;
CornerMoveCoefficient = 4;
MoveCoefficient = 4;
NumberCoefficient = 0;
WallCoefficient = 0;
}
}
}

if( level == 1 ) {
if( CmpC == Black ) {
CornerCoefficient = 10;
CornerMoveCoefficient = 5;
MoveCoefficient = 1;
NumberCoefficient = 4;
WallCoefficient = 3;
if( ch > 23 ) {
CornerCoefficient = 13;
CornerMoveCoefficient = 2;
MoveCoefficient = 1;
NumberCoefficient = 2;
WallCoefficient = 2;
}
if( ch > 37 ) {
CornerCoefficient = 13;
CornerMoveCoefficient = 2;
MoveCoefficient = 1;
NumberCoefficient = 1;
WallCoefficient = 3;
}
if( ch > 47 ) {
CornerCoefficient = 14;
CornerMoveCoefficient = 2;
MoveCoefficient = 1;
NumberCoefficient = 1;
WallCoefficient = 2;
}
if( ch > 57 ) {
CornerCoefficient = 10;
CornerMoveCoefficient = 0;
MoveCoefficient = 5;
NumberCoefficient = 0;
WallCoefficient = 5;
}
}
else {
CornerCoefficient = 12;
CornerMoveCoefficient = 5;
MoveCoefficient = 1;
NumberCoefficient = 3;
WallCoefficient = 2;
if( ch > 31 ) {
CornerCoefficient = 10;
CornerMoveCoefficient = 2;
MoveCoefficient = 1;
NumberCoefficient = 2;
WallCoefficient = 5;
}
if( ch > 37 ) {
CornerCoefficient = 9;
CornerMoveCoefficient = 3;
MoveCoefficient = 3;
NumberCoefficient = 3;
WallCoefficient = 2;
}
if( ch > 47 ) {
CornerCoefficient = 12;
CornerMoveCoefficient = 2;
MoveCoefficient = 4;
NumberCoefficient = 2;
WallCoefficient = 0;
}
if( ch > 57 ) {
CornerCoefficient = 10;
CornerMoveCoefficient = 0;
MoveCoefficient = 5;
NumberCoefficient = 0;
WallCoefficient = 5;
}
}
}

if( level == 2 ) {
if( CmpC == Black ) {
CornerCoefficient = 6;
CornerMoveCoefficient = 3;
MoveCoefficient = 3;
NumberCoefficient = 4;
WallCoefficient = 5;
if( ch > 18 ) {
CornerCoefficient = 6;
CornerMoveCoefficient = 3;
MoveCoefficient = 3;
NumberCoefficient = 5;
WallCoefficient = 4;
}
if( ch > 26 ) {
CornerCoefficient = 6;
CornerMoveCoefficient = 3;
MoveCoefficient = 5;
NumberCoefficient = 6;
WallCoefficient = 4;
}
if( ch > 36 ) {
CornerCoefficient = 5;
CornerMoveCoefficient = 3;
MoveCoefficient = 4;
NumberCoefficient = 4;
WallCoefficient = 3;
}
if( ch > 46 ) {
CornerCoefficient = 6;
CornerMoveCoefficient = 3;
MoveCoefficient = 5;
NumberCoefficient = 3;
WallCoefficient = 3;
}
}
else {
CornerCoefficient = 6;
CornerMoveCoefficient = 3;
MoveCoefficient = 3;
NumberCoefficient = 3;
WallCoefficient = 5;
if( ch > 18 ) {
CornerCoefficient = 6;
CornerMoveCoefficient = 2;
MoveCoefficient = 3;
NumberCoefficient = 5;
WallCoefficient = 4;
}
if( ch > 26 ) {
CornerCoefficient = 6;
CornerMoveCoefficient = 3;
MoveCoefficient = 3;
NumberCoefficient = 5;
WallCoefficient = 3;
}
if( ch > 36 ) {
CornerCoefficient = 6;
CornerMoveCoefficient = 3;
MoveCoefficient = 4;
NumberCoefficient = 4;
WallCoefficient = 3;
}
if( ch > 46 ) {
CornerCoefficient = 6;
CornerMoveCoefficient = 3;
MoveCoefficient = 5;
NumberCoefficient = 3;
WallCoefficient = 3;
}
}
}


}

short SetValue( Board *b, short n )
{
short value = 0;

value += MoveCoefficient * SetMoveValue(b,n);
value -= NumberCoefficient * SetNumberValue(b);
value -= WallCoefficient * SetWallValue(b);
value += CornerMoveCoefficient * SetConerMoveValue(b);
value += CornerCoefficient * SetCornerValue(b);
if( CmpC == White ) value *= -1;
value += Top->p->value;
return value;
}

at 00:31|PermalinkComments(0)mixiチェック StaBu 

setvalue.c

本当はここのファイルは公開したくないのですが・・・
と言うのも検索スピードと評価値の計算が、ゲームの本質だからです。
それ程秘密ってわけでもないので、
そのまま公開します。
次のバージョン(が出せれ)ば作り直すし・・・

#include "Othello.h"

short Corner[4][2][8] ={
{{ 0, 1, 2, 3, 4, 5, 6, 7},{ 0, 8,16,24,32,40,48,56}},
{{ 7, 6, 5, 4, 3, 2, 1, 0},{ 7,15,23,31,39,47,55,63}},
{{63,55,47,39,31,23,15, 7},{63,62,61,60,59,58,57,56}},
{{56,57,58,59,60,61,62,63},{56,48,40,32,24,16, 8, 0}}
};

extern short CmpC, ManC;
extern char SearchList[1024];
extern Board b[21], temp, *Top;

short TopCoefficient = 10;
short CornerCoefficient = 10;

short CornerMoveCoefficient = 2;
short MoveCoefficient = 1;
short NumberCoefficient = 1;
short WallCoefficient = 2;

static char *p0;
static char ib, iw;

void LineValue( Board *b );
void SetTopValue( Board *b )
{
short i, j;

temp = *Top;
temp.color *= -1;
Search( &temp );

for( i = 0; i < MaxMove; i++ ) b->list[i].value = 0;
for( i = 0; i < MaxMove; i++ ) {
temp.p = temp.list;
if( b->list[i].move == End ) break;
for( j = 0; j < MaxMove; j++ ) {
if( temp.list[j].move == End ) break;
if( b->list[i].move == temp.list[j].move ) {
b->list[i].value = 20;
break;
}
}
}
for( i = 0; i < MaxMove; i++ ) {
if( b->list[i].move == End ) break;
b->p = &(b->list[i]);
LineValue( b );
}
b->p = b->list;
}

void LineValue( Board *b )
{
short i;

if( b->p->move == 49 ) if( b->board[56] == 0 ) b->p->value -= 2 * TopCoefficient;
if( b->p->move == 48 ) {
for( i = 0; i < 8; i++ ) if( b->board[Corner[0][1][i]] ) break;
if( i == 8 ) b->p->value -= TopCoefficient;
}
if( b->p->move == 57 ) {
for( i = 0; i < 8; i++ ) if( b->board[Corner[3][0][i]] ) break;
if( i == 8 ) b->p->value -= TopCoefficient;
}

if( b->p->move == 54 ) if( b->board[63] == 0 ) b->p->value -= 2 * TopCoefficient;
if( b->p->move == 55 ) {
for( i = 0; i < 8; i++ ) if( b->board[Corner[1][1][i]] ) break;
if( i == 8 ) b->p->value -= TopCoefficient;
}
if( b->p->move == 62 ) {
for( i = 0; i < 8; i++ ) if( b->board[Corner[3][0][i]] ) break;
if( i == 8 ) b->p->value -= TopCoefficient;
}

if( b->p->move == 14 ) if( b->board[7] == 0 ) b->p->value -= 2 * TopCoefficient;
if( b->p->move == 6 ) {
for( i = 0; i < 8; i++ ) if( b->board[Corner[0][0][i]] ) break;
if( i == 8 ) b->p->value -= TopCoefficient;
}
if( b->p->move == 15 ) {
for( i = 0; i < 8; i++ ) if( b->board[Corner[1][1][i]] ) break;
if( i == 8 ) b->p->value -= TopCoefficient;
}

if( b->p->move == 9 ) if( b->board[0] == 0 ) b->p->value -= 2 * TopCoefficient;
if( b->p->move == 1 ) {
for( i = 0; i < 8; i++ ) if( b->board[Corner[0][0][i]] ) break;
if( i == 8 ) b->p->value -= TopCoefficient;
}
if( b->p->move == 8 ) {
for( i = 0; i < 8; i++ ) if( b->board[Corner[0][1][i]] ) break;
if( i == 8 ) b->p->value -= TopCoefficient;
}
}

inline short SetWallValue( Board *b )
{
p0 = SearchList;
ib = iw =0;
do {
if( *(b->board+*p0) == 0 ) {
do {
if( *p0 ==Stop) break;
p0++;
} while( *(b->board+*p0) == 0 );
if( *p0 != Stop ) {
if( *(b->board+*p0) > 0 ) ib++;
else iw++;
p0++;
while( *p0 != Stop ) p0++;
}
}
else {
while( *p0 != Stop ) p0++;
}
p0++;
} while( *p0 != End );
if( !(ib+iw) ) return 0;
return ((ib*100)/(ib+iw))-50;
}

inline short SetCornerValue( Board *b )
{
int i,j,k;

ib = iw = 0;
for( i = 0; i < 4; i++ ) {
for( j = 0; j < 2; j++ ) {
for( k = 0; k < 8; k++ ) {
if( b->board[Corner[i][j][k]] == 0 ) break;
}
if( k == 8 ) {
for( k = 0; k < 8; k++ ) {
if( b->board[Corner[i][j][k]] == Black ) ib++;
if( b->board[Corner[i][j][k]] == White ) iw++;
}
}
else {
k = 0;
if( b->board[Corner[i][j][k]] ) {
if( b->board[Corner[i][j][k]] == Black ) {
ib++;
for( k = 1; k < 7; k++ ) {
if( b->board[Corner[i][j][k]] == Black ) ib++;
else break;
}
}
else {
iw++;
for( k = 1; k < 7; k++ ) {
if( b->board[Corner[i][j][k]] == White ) iw++;
else break;
}
}
}
}
}
}
if( !(ib+iw) ) return 0;
return ((ib*100)/(ib+iw))-50;
}

inline short SetConerMoveValue( Board *b )
{
ib = iw = 0;
if( b->color == Black ) {
if( b->dir[0] ) ib+=2;
if( b->dir[7] ) ib+=2;
if( b->dir[56] ) ib+=2;
if( b->dir[63] ) ib+=2;
if( temp.dir[0] ) iw++;
if( temp.dir[7] ) iw++;
if( temp.dir[56] ) iw++;
if( temp.dir[63] ) iw++;
}
else {
if( b->dir[0] ) iw+=2;
if( b->dir[7] ) iw+=2;
if( b->dir[56] ) iw+=2;
if( b->dir[63] ) iw+=2;
if( temp.dir[0] ) ib++;
if( temp.dir[7] ) ib++;
if( temp.dir[56] ) ib++;
if( temp.dir[63] ) ib++;
}
if( !(ib+iw) ) return 0;
return ((ib*100)/(ib+iw))-50;
}

inline short SetNumberValue( Board *b )
{
p0 = b->board;
ib = iw = 0;
do {
if( *p0 == Black ) ib++;
if( *p0 == White ) iw++;
p0++;
} while( *p0 != End );
return ((ib*100)/(ib+iw))-50;
}

inline short SetMoveValue( Board *b, short n )
{
temp = *b;
temp.color *= -1;
if( b->color == Black ) {
ib = 2*n;
if( b->dir[1] ) ib--;
if( b->dir[9] ) ib--;
if( b->dir[8] ) ib--;
if( b->dir[6] ) ib--;
if( b->dir[14] ) ib--;
if( b->dir[15] ) ib--;
if( b->dir[55] ) ib--;
if( b->dir[54] ) ib--;
if( b->dir[62] ) ib--;
if( b->dir[48] ) ib--;
if( b->dir[49] ) ib--;
if( b->dir[57] ) ib--;
iw = 2*Search( &temp );
if( temp.dir[1] ) iw--;
if( temp.dir[9] ) iw--;
if( temp.dir[8] ) iw--;
if( temp.dir[6] ) iw--;
if( temp.dir[14] ) iw--;
if( temp.dir[15] ) iw--;
if( temp.dir[55] ) iw--;
if( temp.dir[54] ) iw--;
if( temp.dir[62] ) iw--;
if( temp.dir[48] ) iw--;
if( temp.dir[49] ) iw--;
if( temp.dir[57] ) iw--;
}
else {
iw = 2*n;
if( b->dir[1] ) iw--;
if( b->dir[9] ) iw--;
if( b->dir[8] ) iw--;
if( b->dir[6] ) iw--;
if( b->dir[14] ) iw--;
if( b->dir[15] ) iw--;
if( b->dir[55] ) iw--;
if( b->dir[54] ) iw--;
if( b->dir[62] ) iw--;
if( b->dir[48] ) iw--;
if( b->dir[49] ) iw--;
if( b->dir[57] ) iw--;
ib = 2*Search( &temp );
if( temp.dir[1] ) ib--;
if( temp.dir[9] ) ib--;
if( temp.dir[8] ) ib--;
if( temp.dir[6] ) ib--;
if( temp.dir[14] ) ib--;
if( temp.dir[15] ) ib--;
if( temp.dir[55] ) ib--;
if( temp.dir[54] ) ib--;
if( temp.dir[62] ) ib--;
if( temp.dir[48] ) ib--;
if( temp.dir[49] ) ib--;
if( temp.dir[57] ) ib--;
}
if( !(ib+iw) ) return 0;
return ((ib*100)/(ib+iw))-50;
}

at 00:29|PermalinkComments(0)mixiチェック StaBu 

2004年06月05日

田植え

b6cb3fc3.JPG

僕の家は農家やってませんが、実家の近くは田んぼが沢山あります。(田舎って事です)
田植えは、GWにするもんだと思っていました。GW明けに出勤すると日焼けした人が結構いましたから・・・
最近は6月にするんですね。
田んぼが沢山ある所で撮影しました。
パラソル立ててハイキング気分で田植えしている人もいます。
このまま行くと二期作二毛作も出来るようになりそうです。

at 01:00|PermalinkComments(0)mixiチェック 日記