1 // Copyright (C) 2002, 2003, 2004, 2005, 2006 Ulf Lorenz
2 // Copyright (C) 2003 Michael Bartl
3 // Copyright (C) 2004 Andrea Paternesi
4 // Copyright (C) 2007, 2008, 2009 Ben Asselstine
5 // Copyright (C) 2007, 2008 Ole Laursen
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 3 of the License, or
10 // (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Library General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
28 #include "real_player.h"
29 #include "AI_Analysis.h"
30 #include "AI_Diplomacy.h"
36 //! A simple artificial intelligence Player.
38 * This AI has two modes. In normal modes it basically assembles stacks of
39 * 8 units each and sends them to the next city, reinforcing them in own cities
40 * if neccessary. In maniac mode, however (meant for wandering monsters etc.),
41 * this AI will attack everything that is close up or take the nearest city if
42 * no enemies are close. When it takes over an enemy city, it razes it.
46 class AI_Fast : public RealPlayer
50 * Make a new AI_Fast player.
52 * @param name The name of the player.
53 * @param armyset The Id of the player's Armyset.
54 * @param color The player's colour.
55 * @param width The width of the player's FogMap.
56 * @param height The height of the player's FogMap.
57 * @param player_no The Id of the player. If this value is -1,
58 * the next free Id it used.
60 //! Default constructor.
61 AI_Fast(std::string name, guint32 armyset, Gdk::Color color,
62 int width, int height, int player_no = -1);
65 AI_Fast(const Player&);
67 //! Loading constructor. See XML_Helper for an explanation.
68 AI_Fast(XML_Helper* helper);
73 virtual bool isComputer() const {return true;};
75 //! Saves data, the method is for saving additional data.
76 bool save(XML_Helper* helper) const;
78 //! Sets whether the ai joins close armies to make them stronger
79 void setJoin(bool join) {d_join = join;};
81 //! Returns the current behaviour regarding joining armies
82 bool getJoin() const {return d_join;};
84 //! Set maniac/normal mode
85 void setManiac(bool maniac) {d_maniac = maniac;};
87 //! Returns the current behaviour
88 bool getManiac() const {return d_maniac;};
90 virtual void abortTurn();
91 virtual bool startTurn();
92 virtual void invadeCity(City* c);
93 virtual bool chooseHero(HeroProto *hero, City* c, int gold);
94 virtual Reward *chooseReward(Ruin *ruin, Sage *sage, Stack *stack);
95 virtual void heroGainsLevel(Hero * a);
96 virtual bool chooseTreachery (Stack *stack, Player *player, Vector <int> pos);
97 virtual Army::Stat chooseStat(Hero *hero);
98 virtual bool chooseQuest(Hero *hero);
101 //! The actual core function of the ai's logic.
104 //! search through our stacklist for a stack we can join
105 Stack *findNearOwnStackToJoin(Stack *s, int max_distance);
107 //! produce the best low-turn high strength army unit.
108 int setBestProduction(City *c);
110 int scoreArmyType(const ArmyProdBase *a);
112 //! Determines whether to join units or move them separately.
115 //! Maniac mode: kill and raze everything you encounter.
118 AI_Analysis* d_analysis;
119 AI_Diplomacy* d_diplomacy;