1/* ****************************************************************************
2 This file is part of the game 'KJumpingCube'
3
4 Copyright (C) 1998-2000 by Matthias Kiefer
5 <matthias.kiefer@gmx.de>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
21**************************************************************************** */
22
23#include "ai_kepler.h"
24
25AI_Kepler::AI_Kepler()
26{
27}
28
29int AI_Kepler::assessCube (const int index, const Player player,
30 const int neighbors [4], const Player owners[],
31 const int values[], const int maxValues[]
32 ) const
33{
34 int diff = VeryHighValue;
35 int temp = VeryHighValue;
36 int pos = 0;
37
38 // Check the neighbors.
39 for (int i = 0; i < 4; i++) {
40 if ((pos = neighbors [i]) >= 0) {
41 temp = (owners [pos] != player) ? maxValues[index] - values[index]
42 : maxValues[index] - values[index] + 1;
43 if (temp < diff) {
44 diff = temp;
45 }
46 }
47 // Else, do nothing: no neighbor on this side.
48 }
49
50 int val;
51 temp = maxValues[index] - values[index];
52 val = diff - temp + 1;
53 val = val * (temp + 1);
54 if (val <= 0) {
55 val = HighValue - val; // Always return values > 0.
56 }
57
58 return val;
59}
60