1 /* 2 SPDX-FileCopyrightText: 2007 Paolo Capriotti <p.capriotti@gmail.com> 3 4 SPDX-License-Identifier: GPL-2.0-or-later 5 */ 6 7 #ifndef SMARTAI_H 8 #define SMARTAI_H 9 10 #include <memory> 11 #include <QHash> 12 13 #include "ai.h" 14 #include "sea.h" 15 16 class Strategy; 17 18 class SmartAI : public AI 19 { 20 public: 21 class State 22 { 23 QHash<int,int> m_ships; 24 bool m_random; 25 const BattleShipsConfiguration* m_config; 26 public: 27 explicit State(bool random, const BattleShipsConfiguration* config); 28 Strategy* defaultStrategy(Sea::Player player, Sea*); 29 void destroyed(int size); 30 }; 31 private: 32 std::unique_ptr<Strategy> m_strategy; 33 State m_state; 34 public: 35 SmartAI(Sea::Player player, Sea* sea, bool random, const BattleShipsConfiguration* config); 36 37 Coord getMove() override; 38 void notify(Sea::Player player, const Coord& c, const HitInfo& hit) override; 39 }; 40 41 #endif // SMARTAI_H 42