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 KBLOCKSAIPLANNEREXTEND_H
0008 #define KBLOCKSAIPLANNEREXTEND_H
0009 
0010 #include "KBlocksAIPlanner.h"
0011 #include <list>
0012 #include <vector>
0013 
0014 /****************************************************************
0015 **  Planning Path  **********************************************
0016 ****************************************************************/
0017 namespace PlanningPath
0018 {
0019 class PathNode
0020 {
0021 public:
0022     explicit PathNode(KBlocksPiece *piece);
0023     ~PathNode();
0024 
0025     KBlocksPiece getContent();
0026     void setContent(KBlocksPiece *piece);
0027     void setParent(PathNode *parent);
0028     PathNode *getParent();
0029 
0030     void setNext(std::vector<PathNode> *&);
0031 
0032 private:
0033     KBlocksPiece content;
0034     PathNode *parent;
0035     std::vector<PathNode> *next;
0036 };
0037 
0038 typedef std::vector<PathNode>  PathTree;
0039 typedef std::vector<PathNode *> LeafList;
0040 }
0041 
0042 /****************************************************************
0043 **  Planner  ****************************************************
0044 ****************************************************************/
0045 class KBlocksAIPlannerExtend : public KBlocksAIPlanner
0046 {
0047 public:
0048     explicit KBlocksAIPlannerExtend(KBlocksField *field);
0049     ~KBlocksAIPlannerExtend() override;
0050 
0051     int process(KBlocks_PieceType_Detail pieceValue) override;
0052     int process(const AIPlanner_PieceValue_Sequence &p);
0053 
0054     bool getNextBoardStatus(int index, KBlocksField *field) override;
0055     bool getNextBoardStatus(int index, KBlocksField *field, bool first);
0056     bool getNextPieceState(int index, KBlocksPiece *piece) override;
0057     bool getPath(int index, AIPlanner_PieceInfo_Sequence *pseq);
0058 
0059     int count() override;
0060 
0061 private:
0062     PlanningPath::PathTree *mPathTree;
0063     PlanningPath::LeafList *mPathList;
0064     void process_nstep_recursive(PlanningPath::PathNode *parent,
0065                                  AIPlanner_PieceValue_Sequence &pseq,
0066                                  PlanningPath::PathTree &tree,
0067                                  PlanningPath::LeafList &leaf);
0068 };
0069 
0070 #endif