1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
/***************************************************************************
Twin4 - Four in a Row for TDE
-------------------
begin : March 2000
copyright : (C) 1995-2001 by Martin Heni
email : martin@heni-online.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef _TWIN4PROC_H_
#define _TWIN4PROC_H_
#include <kgameprocess.h>
// TODO match up with what is in twin4doc.h
typedef enum e_farbe {Niemand=0,Gelb=1,Rot=2,Tip=3,Rand=4} Farbe;
typedef char FARBE;
#define SIZE_Y_ALL 36
#define SIZE_X 6
#define SIZE_Y 5
class KComputer : public TQObject
{
Q_OBJECT
public:
KComputer();
// The KGameProcess is the main program and event loop
KGameProcess proc;
public slots:
void slotCommand(TQDataStream &, int msgid,int receiver,int sender);
void slotInit(TQDataStream &, int id);
void slotTurn(TQDataStream &, bool turn);
protected:
void sendValue(long value);
long random(long max);
long think(TQDataStream &in,TQDataStream &out,bool hint);
// Old computer stuff
Farbe SwitchPlayer(Farbe amZug=Niemand);
Farbe GameOver(FARBE feld[][SIZE_X+1],char anzahl[]);
void DoMove(char move,Farbe farbe,FARBE feld[][SIZE_X+1],char anzahl[]);
int GetCompMove();
long Wertung(Farbe farbe,FARBE feld[][SIZE_X+1],char anzahl[],int reklev,int zug);
long Bewertung(Farbe farbe,FARBE feld[][SIZE_X+1]);
void InitField();
private:
/* rows: 0-5 =6 : horiz(i:0-6) */
/* 6-12 =7 : vert(i:0-5) */
/* 13-24 =12: diag-45(i:...) */
/* 25-36 =12: diag45(i:...) */
char lenofrow[38];
char startofrow[38];
Farbe beginner,second; // Welche Farbe faengt an und zieht nach
Farbe amZug; // wer ist am Zug
Farbe winner; // who won thee game
FARBE feldmatrix[SIZE_Y_ALL+1][SIZE_X+1];
char anzahlmatrix[SIZE_Y_ALL+1];
int aktzug; // welcher Zug ist getade gemacht 0..42
int mymaxreklev; // maximale Rekursion
long aktwert; // Stellungsbewertung
};
#endif // _TWIN4PROC_H_
|