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 Ben Asselstine
5
// Copyright (C) 2007, 2008 Ole Laursen
1
7
// This program is free software; you can redistribute it and/or modify
2
8
// it under the terms of the GNU General Public License as published by
3
9
// the Free Software Foundation; either version 2 of the License, or
11
17
// You should have received a copy of the GNU General Public License
12
18
// along with this program; if not, write to the Free Software
13
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
30
* This AI has two modes. In normal modes it basically assembles stacks of
31
* 8 units each and sends them to the next city, reinforcing them in own cities
32
* if neccessary. In maniac mode, however (meant for wandering monsters etc.),
33
* this AI will attack everything that is close up or take the nearest city if
34
* no enemies are close. When it takes over an enemy city, it razes it.
36
* See the Player class for the derivation scheme
35
//! A simple artificial intelligence Player.
37
* This AI has two modes. In normal modes it basically assembles stacks of
38
* 8 units each and sends them to the next city, reinforcing them in own cities
39
* if neccessary. In maniac mode, however (meant for wandering monsters etc.),
40
* this AI will attack everything that is close up or take the nearest city if
41
* no enemies are close. When it takes over an enemy city, it razes it.
39
45
class AI_Fast : public RealPlayer
42
/** Default constructor
44
* @param name the name of the player
45
* @param armyset the armyset of the player
46
* @param color the player's color
48
AI_Fast(std::string name, Uint32 armyset, SDL_Color color, int width, int height, int player_no = -1);
49
* Make a new AI_Fast player.
51
* @param name The name of the player.
52
* @param armyset The Id of the player's Armyset.
53
* @param color The player's colour.
54
* @param width The width of the player's FogMap.
55
* @param height The height of the player's FogMap.
56
* @param player_no The Id of the player. If this value is -1,
57
* the next free Id it used.
59
//! Default constructor.
60
AI_Fast(std::string name, Uint32 armyset, SDL_Color color,
61
int width, int height, int player_no = -1);
51
64
AI_Fast(const Player&);
53
66
//! Loading constructor. See XML_Helper for an explanation.
54
67
AI_Fast(XML_Helper* helper);
57
//! Saves data, the function is for saving additional data
72
//! Saves data, the method is for saving additional data.
58
73
bool save(XML_Helper* helper) const;
61
75
//! Sets whether the ai joins close armies to make them stronger
62
76
void setJoin(bool join) {d_join = join;}
71
85
bool getManiac() const {return d_maniac;}
74
/** This function is called whenever the player's turn starts. As soon
75
* as it returns, the player's turn ends.
79
//! Callback when the player invades a city
80
bool invadeCity(City* c);
82
//! Callback when a hero offers his services
83
bool recruitHero(Hero* hero, City *city, int cost);
85
//! Callback when an army of the player advances a level
86
bool levelArmy(Army* a);
88
//! Callback when we decide to perform treachery on another player
89
bool treachery (Stack *stack, Player *player, Vector <int> pos, DiplomaticState state);
88
virtual bool startTurn();
89
virtual void invadeCity(City* c);
90
virtual void levelArmy(Army* a);
91
virtual bool treachery (Stack *stack, Player *player, Vector <int> pos,
92
DiplomaticState state);
91
95
//! The actual core function of the ai's logic.
92
96
void computerTurn();
96
bool d_join; //!< determines whether to join units or move them separately
97
bool d_maniac; //!< maniac mode: kill and raze everything you encounter
98
//! Determines whether to join units or move them separately.
101
//! Maniac mode: kill and raze everything you encounter.
98
104
AI_Analysis* d_analysis;
99
105
AI_Diplomacy* d_diplomacy;