File indexing completed on 2024-04-28 04:01:57

0001 /***************************************************************************
0002 *   KBlocks, a falling blocks game by KDE                                 *
0003 *   SPDX-FileCopyrightText: 2010 University Freiburg <squall.leonhart.cai@gmail.com> *
0004 *                                                                          *
0005 *   SPDX-License-Identifier: GPL-2.0-or-later
0006 ***************************************************************************/
0007 #ifndef KBLOCKSAIPLAYER_H
0008 #define KBLOCKSAIPLAYER_H
0009 
0010 #include <string>
0011 using namespace std;
0012 
0013 #include "KBlocksAITypeDefine.h"
0014 
0015 #include "../GamePlayerInterface.h"
0016 
0017 #include "../SingleGameInterface.h"
0018 #include "../KBlocksField.h"
0019 #include "../KBlocksPiece.h"
0020 
0021 #include "EvaluationInterface.h"
0022 #include "PlannerInterface.h"
0023 
0024 class KBlocksAIPlayer : public GamePlayerInterface
0025 {
0026 public:
0027     explicit KBlocksAIPlayer(const string &name = "");
0028     ~KBlocksAIPlayer() override;
0029 
0030 public:
0031     void startGame(SingleGameInterface *p) override;
0032     void stopGame() override;
0033 
0034     void pauseGame(bool flag) override;
0035 
0036     void think(GamePlayer_ActionList *actionList) override;
0037 
0038     string getName() override;
0039 
0040 private:
0041     string mAIName;
0042 
0043     // Private Control Data
0044     bool mAIStarted;
0045     bool mAIPaused;
0046 
0047     // Phase I   - State Update
0048     KBlocksField *mpAIField;
0049     KBlocksPiece *mpCurPiece;
0050     KBlocksPiece *mpNextPiece;
0051     void update();
0052 
0053     // Phase II  - Planning
0054     PlannerInterface *mpPlanner;
0055     int mNextCount;
0056     void planning();
0057 
0058     // Phase III - Situation Analysis
0059     EvaluationInterface *mpEvaluatorFinal;
0060     EvaluationInterface *mpEvaluatorFirst;
0061     EvaluationInterface *mpEvaluatorPre;
0062     void situationAdaption();
0063 
0064     // Phase IV  - States Evaluation
0065     int mBestPosition;
0066     int mBestRotation;
0067     void generateGoalAction();
0068 };
0069 
0070 #endif