1/* ****************************************************************************
2 This file is part of the game 'KJumpingCube'
3
4 Copyright (C) 2012 by Ian Wadham <iandw.au@gmail.com>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
20**************************************************************************** */
21#ifndef AI_BASE_H
22#define AI_BASE_H
23
24#include "ai_globals.h" // Include Player enum.
25
26#include <QString> // IDW test.
27
28/**
29* A pure-virtual class that is a base for alternative KJumpinCube AI algorithms.
30*/
31class AI_Base
32{
33public:
34 virtual QString whoami() = 0; // IDW test.
35
36 AI_Base() {};
37 virtual ~AI_Base() {};
38
39 /**
40 * Assess the priority of playing a cube at a particular position. The
41 * highest priority cubes are used by the AI_Main class for look-ahead moves
42 * and calculating the values of the positions reached. The cube to be
43 * assessed has to be neutral or owned by the player who is to move.
44 *
45 * @param index The index-position of the cube to be assessed
46 * @param player The player who is to move
47 * @param neighbors The index-positions of the cube's neighbors (array),
48 * where a value of -1 means no neighbor on that side
49 * @param owners The current owners of the cubes in the box (array)
50 * @param values The current point values of the cubes in the box (array)
51 * @param maxValues The maximum point values of the cubes in the box (array)
52 *
53 * @return The priority of a move (always > 0): moves with priority
54 * 1 are best and those with priority >= HighValue (999)
55 * are worst but may be forced (e.g. when defeat is near).
56 */
57 virtual int assessCube (const int index, const Player player,
58 const int neighbors [4], const Player owners[],
59 const int values[], const int maxValues[]) const = 0;
60
61 /**
62 * Assess the value of a position reached after trying a move. Moves that
63 * lead to the highest values are chosen by the main AI class.
64 *
65 * @param player The player whose position is to be assessed
66 * @param nCubes The number of cubes in the box
67 * @param owners The current owners of the cubes in the box (array)
68 * @param values The current point values of the cubes in the box (array)
69 *
70 * @return The value of the position
71 */
72 virtual long assessPosition (const Player player, const int nCubes,
73 const Player * owners, const int * values
74 ) const;
75};
76
77#endif // AI_BASE_H
78