aboutsummaryrefslogtreecommitdiff
path: root/engines/groovie/cell.h
blob: d6f1ac97dc73b3ce22f3d7e324f91fcc603b903e (plain)
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
85
86
87
88
89
90
91
92
93
94
95
96
97
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * 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.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */

#ifndef GROOVIE_CELL_H
#define GROOVIE_CELL_H

#include "common/textconsole.h"

#define BOARDSIZE 7
#define CELL_CLEAR 0
#define CELL_BLUE 1
#define CELL_GREEN 2

namespace Groovie {

class GroovieEngine;
class Script;

class CellGame {
public:
	CellGame();
	~CellGame();
	byte getStartX();
	byte getStartY();
	byte getEndX();
	byte getEndY();
	int playStauf(byte color, uint16 depth, byte *scriptBoard);

private:
	void copyToTempBoard();
	void copyFromTempBoard();
	void copyToShadowBoard();
	void pushBoard();
	void popBoard();
	void pushShadowBoard();
	void popShadowBoard();
	void clearMoves();
	void pushMove();
	void resetMove();
	bool canMoveFunc1(int8 color);
	bool canMoveFunc2(int8 color);
	bool canMoveFunc3(int8 color);
	void takeCells(uint16 whereTo, int8 color);
	void countAllCells();
	int countCellsOnTempBoard(int8 color);
	void makeMove(int8 color);
	int getBoardWeight(int8 color1, int8 color2);
	void chooseBestMove(int8 color);
	int8 calcBestWeight(int8 color1, int8 color2, uint16 depth, int bestWeight);
	int16 doGame(int8 color, int depth);
	int16 calcMove(int8 color, uint16 depth);

	byte _startX;
	byte _startY;
	byte _endX;
	byte _endY;

	int8 _board[57];
	int8 _tempBoard[58];
	int8 _shadowBoard[64];
	int8 _boardStack[570];
	int _boardStackPtr;

	int8 _boardSum[58];

	int8 _stack_startXY[128];
	int8 _stack_endXY[128];
	int8 _stack_pass[128];
	int _stack_index;

	int _coeff3;
	bool _flag1, _flag2, _flag4;
	int _moveCount;
};

} // End of Groovie namespace

#endif // GROOVIE_CELL_H