|
|
|
@ -38,7 +38,7 @@
|
|
|
|
|
#define START_REK 1 // (0) 1:Nur Stellungsbewertung bei Level 1
|
|
|
|
|
// 0:Level 1 schon eine Rekursion
|
|
|
|
|
|
|
|
|
|
KComputer::KComputer() : TQObject(0,0)
|
|
|
|
|
TDEComputer::TDEComputer() : TQObject(0,0)
|
|
|
|
|
{
|
|
|
|
|
InitField();
|
|
|
|
|
|
|
|
|
@ -57,12 +57,12 @@ KComputer::KComputer() : TQObject(0,0)
|
|
|
|
|
this,TQT_SLOT(slotInit(TQDataStream & ,int )));
|
|
|
|
|
connect(&proc,TQT_SIGNAL(signalTurn(TQDataStream &,bool )),
|
|
|
|
|
this,TQT_SLOT(slotTurn(TQDataStream & ,bool )));
|
|
|
|
|
fprintf(stderr, "----------------->\nKComputer::Computer\n");
|
|
|
|
|
fprintf(stderr, "----------------->\nTDEComputer::Computer\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KComputer::slotInit(TQDataStream &in,int id)
|
|
|
|
|
void TDEComputer::slotInit(TQDataStream &in,int id)
|
|
|
|
|
{
|
|
|
|
|
fprintf(stderr,"----------------->\nKComputer::slotInit\nid:%d\n",id);
|
|
|
|
|
fprintf(stderr,"----------------->\nTDEComputer::slotInit\nid:%d\n",id);
|
|
|
|
|
/*
|
|
|
|
|
TQByteArray buffer;
|
|
|
|
|
TQDataStream out(buffer,IO_WriteOnly);
|
|
|
|
@ -72,11 +72,11 @@ void KComputer::slotInit(TQDataStream &in,int id)
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KComputer::slotTurn(TQDataStream &in,bool turn)
|
|
|
|
|
void TDEComputer::slotTurn(TQDataStream &in,bool turn)
|
|
|
|
|
{
|
|
|
|
|
TQByteArray buffer;
|
|
|
|
|
TQDataStream out(buffer,IO_WriteOnly);
|
|
|
|
|
fprintf(stderr,"----------------->\nKComputer::slotTurn\nturn:%d\n",turn);
|
|
|
|
|
fprintf(stderr,"----------------->\nTDEComputer::slotTurn\nturn:%d\n",turn);
|
|
|
|
|
if (turn)
|
|
|
|
|
{
|
|
|
|
|
// Create a move
|
|
|
|
@ -87,7 +87,7 @@ void KComputer::slotTurn(TQDataStream &in,bool turn)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KComputer::sendValue(long value)
|
|
|
|
|
void TDEComputer::sendValue(long value)
|
|
|
|
|
{
|
|
|
|
|
TQ_INT8 cid=1; // notifies our KGameIO that this is a value message
|
|
|
|
|
int id=KGameMessage::IdProcessQuery;
|
|
|
|
@ -97,7 +97,7 @@ void KComputer::sendValue(long value)
|
|
|
|
|
proc.sendSystemMessage(out,id,0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long KComputer::think(TQDataStream &in,TQDataStream &out,bool hint)
|
|
|
|
|
long TDEComputer::think(TQDataStream &in,TQDataStream &out,bool hint)
|
|
|
|
|
{
|
|
|
|
|
TQ_INT32 pl;
|
|
|
|
|
TQ_INT32 move;
|
|
|
|
@ -174,9 +174,9 @@ long KComputer::think(TQDataStream &in,TQDataStream &out,bool hint)
|
|
|
|
|
return aktwert;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KComputer::slotCommand(TQDataStream &in,int msgid,int receiver,int sender)
|
|
|
|
|
void TDEComputer::slotCommand(TQDataStream &in,int msgid,int receiver,int sender)
|
|
|
|
|
{
|
|
|
|
|
fprintf(stderr,"----------------->\nKComputer::slotCommand\nMsgid:%d\n",msgid);
|
|
|
|
|
fprintf(stderr,"----------------->\nTDEComputer::slotCommand\nMsgid:%d\n",msgid);
|
|
|
|
|
TQByteArray buffer;
|
|
|
|
|
TQDataStream out(buffer,IO_WriteOnly);
|
|
|
|
|
switch(msgid)
|
|
|
|
@ -194,14 +194,14 @@ void KComputer::slotCommand(TQDataStream &in,int msgid,int receiver,int sender)
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
fprintf(stderr,"KComputer:: unknown command Msgid:%d\n",msgid);
|
|
|
|
|
fprintf(stderr,"TDEComputer:: unknown command Msgid:%d\n",msgid);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Computer Routinen
|
|
|
|
|
*/
|
|
|
|
|
int KComputer::GetCompMove()
|
|
|
|
|
int TDEComputer::GetCompMove()
|
|
|
|
|
{
|
|
|
|
|
int cmove;
|
|
|
|
|
long cmax,wert;
|
|
|
|
@ -235,7 +235,7 @@ int KComputer::GetCompMove()
|
|
|
|
|
return cmove;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long KComputer::Wertung(Farbe farbe,FARBE feld[][SIZE_X+1],char anzahl[],int reklev,int zug)
|
|
|
|
|
long TDEComputer::Wertung(Farbe farbe,FARBE feld[][SIZE_X+1],char anzahl[],int reklev,int zug)
|
|
|
|
|
{
|
|
|
|
|
static long gaus[]={10,50,300,500,300,50,10};
|
|
|
|
|
FARBE lfeld[SIZE_Y_ALL+1][SIZE_X+1];
|
|
|
|
@ -272,7 +272,7 @@ long KComputer::Wertung(Farbe farbe,FARBE feld[][SIZE_X+1],char anzahl[],int rek
|
|
|
|
|
return(-max);
|
|
|
|
|
}/*end wertung*/
|
|
|
|
|
|
|
|
|
|
long KComputer::Bewertung(Farbe farbe,FARBE feld[][SIZE_X+1])
|
|
|
|
|
long TDEComputer::Bewertung(Farbe farbe,FARBE feld[][SIZE_X+1])
|
|
|
|
|
{
|
|
|
|
|
/* Abstand: 0 1 2 3 4 5 */
|
|
|
|
|
static long myWERT[]={2200,600, 300, 75, 20, 0};
|
|
|
|
@ -332,7 +332,7 @@ static long steinWERT[4][5]=
|
|
|
|
|
return(wert);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Farbe KComputer::GameOver(FARBE feld[][SIZE_X+1],char anzahl[])
|
|
|
|
|
Farbe TDEComputer::GameOver(FARBE feld[][SIZE_X+1],char anzahl[])
|
|
|
|
|
{
|
|
|
|
|
Farbe thiscolor,field;
|
|
|
|
|
int x,y,cnt;
|
|
|
|
@ -353,7 +353,7 @@ Farbe KComputer::GameOver(FARBE feld[][SIZE_X+1],char anzahl[])
|
|
|
|
|
return(Niemand);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Farbe KComputer::SwitchPlayer(Farbe m_amZug)
|
|
|
|
|
Farbe TDEComputer::SwitchPlayer(Farbe m_amZug)
|
|
|
|
|
{
|
|
|
|
|
if (m_amZug==Niemand)
|
|
|
|
|
m_amZug=amZug;
|
|
|
|
@ -365,7 +365,7 @@ Farbe KComputer::SwitchPlayer(Farbe m_amZug)
|
|
|
|
|
return amZug;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KComputer::DoMove(char move,Farbe farbe,FARBE feld[][SIZE_X+1],char anzahl[])
|
|
|
|
|
void TDEComputer::DoMove(char move,Farbe farbe,FARBE feld[][SIZE_X+1],char anzahl[])
|
|
|
|
|
{
|
|
|
|
|
int x,i,y;
|
|
|
|
|
|
|
|
|
@ -392,7 +392,7 @@ void KComputer::DoMove(char move,Farbe farbe,FARBE feld[][SIZE_X+1],char anzahl[
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KComputer::InitField() {
|
|
|
|
|
void TDEComputer::InitField() {
|
|
|
|
|
int x,y;
|
|
|
|
|
for (y=0;y<=SIZE_Y_ALL;y++)
|
|
|
|
|
anzahlmatrix[y]=0;
|
|
|
|
@ -408,7 +408,7 @@ void KComputer::InitField() {
|
|
|
|
|
}/* next y */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long KComputer::random(long max)
|
|
|
|
|
long TDEComputer::random(long max)
|
|
|
|
|
{
|
|
|
|
|
long wert;
|
|
|
|
|
wert=proc.random()->getLong(max);
|
|
|
|
@ -420,9 +420,9 @@ int main(int argc ,char * argv[])
|
|
|
|
|
{
|
|
|
|
|
// This is the computer player...it should do the calulation
|
|
|
|
|
// It doesn't do much here
|
|
|
|
|
fprintf(stderr,"Vor KComputer\n");
|
|
|
|
|
fprintf(stderr,"Vor TDEComputer\n");
|
|
|
|
|
fflush(stderr);
|
|
|
|
|
KComputer comp;
|
|
|
|
|
TDEComputer comp;
|
|
|
|
|
fprintf(stderr,"Vor exec\n");
|
|
|
|
|
// And start the event loop
|
|
|
|
|
comp.proc.exec(argc,argv);
|
|
|
|
|