The Battle for Wesnoth 1.21.0-dev
 
Loading...
Searching...
No Matches
ai.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2009 - 2025
3 by Yurii Chernyi <terraninfo@terraninfo.net>
4 Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY.
12
13 See the COPYING file for more details.
14*/
15
16/**
17 * @file
18 * Composite AI with turn sequence which is a vector of stages
19 */
20
21#pragma once
22
25
26//============================================================================
27namespace ai {
28
29class ai_composite : public ai_context, public virtual default_ai_context_proxy, public component {
30public:
31
32 /**
33 * Constructor
34 */
35 ai_composite( default_ai_context &context, const config &cfg );
36
37 /**
38 * Destructor
39 */
40 virtual ~ai_composite();
41
42 /**
43 * Play the turn
44 */
45 void play_turn();
46
47 /**
48 * On new turn
49 */
50 virtual void new_turn();
51
52 std::string describe_self() const;
53
54 /**
55 * serialize
56 */
57 virtual config to_config() const;
58
59 int get_recursion_count() const;
60
61 void switch_side(side_number side);
62
63 virtual bool add_goal(const config &cfg);
64
65 virtual bool add_stage(const config &cfg);
66
67 void create_stage(std::vector<stage_ptr> &stages, const config &cfg);
68
69 void create_goal(std::vector<goal_ptr> &goals, const config &cfg);
70
71 void create_engine(std::vector<engine_ptr> &engines, const config &cfg);
72
73 void replace_aspect(std::map<std::string,aspect_ptr> &aspects, const config &cfg, const std::string& id);
74
75 void on_create();
76
77 /**
78 * unwrap
79 */
80 virtual ai_context& get_ai_context();
81
82 virtual std::string get_id() const;
83 virtual std::string get_name() const;
84 virtual std::string get_engine() const;
85
86 static config preparse_cfg(ai_context& ctx, const config& cfg);
87
88protected:
89
90 /**
91 * Config of the AI
92 */
93 const config &cfg_;
94
95 /**
96 * Stages of the composite AI
97 */
98 std::vector< stage_ptr > stages_;
99
100 /**
101 * Recursion counter
102 */
104};
105
106} //end of namespace ai
virtual void new_turn()
On new turn.
Definition ai.cpp:149
void replace_aspect(std::map< std::string, aspect_ptr > &aspects, const config &cfg, const std::string &id)
Definition ai.cpp:92
void create_goal(std::vector< goal_ptr > &goals, const config &cfg)
Definition ai.cpp:82
virtual bool add_goal(const config &cfg)
Definition ai.cpp:115
int get_recursion_count() const
Get the value of the recursion counter.
Definition ai.cpp:158
void create_stage(std::vector< stage_ptr > &stages, const config &cfg)
Definition ai.cpp:77
void switch_side(side_number side)
Definition ai.cpp:163
virtual std::string get_id() const
Definition ai.cpp:133
std::vector< stage_ptr > stages_
Stages of the composite AI.
Definition ai.hpp:98
static config preparse_cfg(ai_context &ctx, const config &cfg)
Definition ai.cpp:185
virtual std::string get_name() const
Definition ai.cpp:139
virtual ai_context & get_ai_context()
unwrap
Definition ai.cpp:168
recursion_counter recursion_counter_
Recursion counter.
Definition ai.hpp:103
const config & cfg_
Config of the AI.
Definition ai.hpp:93
void on_create()
Definition ai.cpp:54
virtual ~ai_composite()
Destructor.
Definition ai.cpp:99
void create_engine(std::vector< engine_ptr > &engines, const config &cfg)
Definition ai.cpp:87
virtual bool add_stage(const config &cfg)
Definition ai.cpp:103
virtual config to_config() const
serialize
Definition ai.cpp:173
void play_turn()
Play the turn.
Definition ai.cpp:127
std::string describe_self() const
Definition ai.cpp:43
virtual std::string get_engine() const
Definition ai.cpp:144
A config object defines a single node in a WML file, with access to child nodes.
Definition config.hpp:157
A component of the AI framework.
Composite AI contexts.
const config * cfg
A small explanation about what's going on here: Each action has access to two game_info objects First...
Definition actions.cpp:59
int side_number
Definition game_info.hpp:40