File indexing completed on 2024-04-28 04:03:02

0001 /*
0002     SPDX-FileCopyrightText: 2007 Paolo Capriotti <p.capriotti@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef SMARTAI_H
0008 #define SMARTAI_H
0009 
0010 #include <memory>
0011 #include <QHash>
0012 
0013 #include "ai.h"
0014 #include "sea.h"
0015 
0016 class Strategy;
0017 
0018 class SmartAI : public AI
0019 {
0020 public:
0021     class State
0022     {
0023         QHash<int,int> m_ships;
0024         bool m_random;
0025         const BattleShipsConfiguration* m_config;
0026     public:
0027         explicit State(bool random, const BattleShipsConfiguration* config);
0028         Strategy* defaultStrategy(Sea::Player player, Sea*);
0029         void destroyed(int size);
0030     };
0031 private:
0032     std::unique_ptr<Strategy> m_strategy;
0033     State m_state;
0034 public:
0035     SmartAI(Sea::Player player, Sea* sea, bool random, const BattleShipsConfiguration* config);
0036 
0037     Coord getMove() override;
0038     void notify(Sea::Player player, const Coord& c, const HitInfo& hit) override;
0039 };
0040 
0041 #endif // SMARTAI_H