File indexing completed on 2024-11-24 03:43:16

0001 /*******************************************************************
0002  *
0003  * Copyright 2007  Aron Boström <c02ab@efd.lth.se>
0004  *
0005  * Bovo is free software; you can redistribute it and/or modify
0006  * it under the terms of the GNU General Public License as published by
0007  * the Free Software Foundation; either version 2, or (at your option)
0008  * any later version.
0009  *
0010  * Bovo is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013  * GNU General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU General Public License
0016  * along with Bovo; see the file COPYING.  If not, write to
0017  * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
0018  * Boston, MA 02110-1301, USA.
0019  *
0020  ********************************************************************/
0021 
0022 /**
0023  * @file Declares the Square class used by the AI internally (AiSquare)
0024  */
0025 
0026 #ifndef BOVO_AISQUARE_H
0027 #define BOVO_AISQUARE_H
0028 
0029 #include "square.h"
0030 
0031 #include "common.h"
0032 
0033 using namespace bovo;
0034 
0035 /** namespace for AI stuff */
0036 namespace ai
0037 {
0038 
0039 /**
0040  * AiSquare is used by the AI to represent a square in a playing board.
0041  *
0042  * This class is used internally by the AI to represent a square in a
0043  * playing board. It extends the normal @c Square class with possibilities
0044  * to keep a point attached to the square, as well as a bool marker that
0045  * tells whether this square needs a recalculation of its points.
0046  *
0047  * Examples construction: (create a playing board)
0048  * @code
0049  * AiSquare** board = new AiSquare*[width];
0050  * for (int x = 0; x < width; ++x) {
0051  *     board[x] = new AiSquare[height];
0052  * }
0053  * @endcode
0054  *
0055  * Example status use:
0056  * @code
0057  * if (board[x][y].status()) {
0058  *     unsigned long points = score(board, x, y );
0059  *     board[x][y].setPoints(points);
0060  *     board[x][y].setStatus(false);
0061  * }
0062  * @endcode
0063  *
0064  * Example mark needs to be repainted:
0065  * @code
0066  * // a neighbour of (x, y) has been marked as belonging to a player,
0067  * // so (x, y) needs to be recalculated.
0068  * board[x][y].setPoints(0);
0069  * board[x][y].setStatus(true);
0070  * @endcode
0071  *
0072  * @author bostrom (Aron Boström) <aron bostrom gmail com>
0073  */
0074 class AiSquare : public Square
0075 {
0076 public:
0077     /**
0078      * @brief constructor of this AiSquare
0079      * @description this constructor creates an AiSquare
0080      */
0081     AiSquare();
0082 
0083     /**
0084      * @brief square points
0085      * @description AI points of this square
0086      * @return points of this square
0087      * @see setPoints
0088      */
0089     uli points() const;
0090 
0091     /**
0092      * @brief sets points
0093      * @description sets the AI points of this square
0094      * @param points the points to set
0095      * @see points
0096      */
0097     void setPoints(unsigned long int points);
0098 
0099     /**
0100      * @brief square status
0101      * @description status represents whether this square is in neef of a
0102      * recalculation of its points or not.
0103      * @return @c true if this square needs a recalculation, @c false otherwise
0104      * @see @c setStatus
0105      */
0106     bool status() const;
0107 
0108     /**
0109      * @brief set status of this square
0110      * @description sets this square's need to get its score recalculated.
0111      * @param status the status to set. $c true means square is in need of a
0112      * recalculation, $c false means it doesn't need to be recalculated.
0113      * @see @c status
0114      */
0115     void setStatus(bool status);
0116 
0117 private:
0118     uli m_points; /* unsigned long int points property */
0119     bool m_status; /* bool status property */
0120 };
0121 
0122 } /* namespace ai */
0123 
0124 #endif // BOVO_AISQUARE_H