1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
//! # bevy_society
//!
//! Living societies for Bevy: personalities, moods, needs, memories, relationships, opinions,
//! rumors, reputation and factions; utility-AI daily lives; Rhai-scripted triggers; and dialogue
//! and barks through `bevy_speech_bubbles`.
//!
//! Every model is distilled from social-psychology and game-AI literature (see `docs/research/`)
//! and every behaviour is deterministic for a given seed.
//!
//! ## Quick start
//!
//! ```
//! use bevy::prelude::*;
//! use bevy_society::{
//! Autonomous, Home, Person, Place, PlaceTags, SocietyClock, SocietyDefs, SocietyPlugins,
//! SocietySettings,
//! };
//!
//! let defs = SocietyDefs::starter().expect("the starter pack is valid");
//! // A headless app has no frame clock, so `Time<Fixed>` never advances on its own. Without this the
//! // society takes zero ticks however many updates you run.
//! let step = std::time::Duration::from_secs_f64(1.0 / 64.0);
//!
//! let mut app = App::new();
//! app.add_plugins((MinimalPlugins, TransformPlugin))
//! .insert_resource(bevy::time::TimeUpdateStrategy::ManualDuration(step))
//! .insert_resource(SocietySettings::default())
//! .insert_resource(defs);
//! // `DialoguePlugin` needs a speech-bubbles plugin over a camera, which this snippet has not.
//! let plugins = SocietyPlugins.build();
//! #[cfg(feature = "dialogue")]
//! let plugins = plugins.disable::<bevy_society::DialoguePlugin>();
//! app.add_plugins(plugins);
//!
//! let well = app
//! .world_mut()
//! .spawn((Name::new("well"), Place { capacity: 6 }, PlaceTags(vec!["gathering".into()]), Transform::default()))
//! .id();
//! for name in ["Bram", "Alys", "Corin"] {
//! app.world_mut()
//! .spawn((Person, Autonomous, Name::new(name), Home(well), Transform::default()));
//! }
//!
//! for _ in 0..600 {
//! app.update();
//! }
//! // The society advanced: this line is what proves the fixed step was pinned.
//! assert!(app.world().resource::<SocietyClock>().tick > 0);
//! ```
//!
//! The same code is `examples/quickstart.rs`, and `README.md` carries it too — `tests/readme.rs`
//! checks the README's text so the three cannot drift.
//!
//! Spawn people with [`Person`], give them somewhere to go with [`Place`], hand in the definitions
//! and read what happens. The example needs no renderer; with the default `dialogue` feature it
//! also needs `SpeechBubblesPlugin` (see the note at the end of the example):
//!
//! ```no_run
//! use bevy::prelude::*;
//! use bevy_society::{
//! Autonomous, Home, Person, Place, PlaceTags, SocietyDefs, SocietyPlugins, SocietySettings,
//! };
//!
//! fn main() {
//! let defs = SocietyDefs::starter().expect("the starter pack is valid");
//! let mut app = App::new();
//! app.add_plugins(MinimalPlugins)
//! .insert_resource(SocietySettings::default())
//! .insert_resource(defs)
//! .add_plugins(SocietyPlugins);
//!
//! let well = app
//! .world_mut()
//! .spawn((Name::new("well"), Place { capacity: 4 }, PlaceTags(vec!["gathering".into()])))
//! .id();
//! for name in ["Bram", "Alys"] {
//! app.world_mut().spawn((
//! Person,
//! Autonomous,
//! Name::new(name),
//! Home(well),
//! Transform::default(),
//! ));
//! }
//!
//! for _ in 0..600 {
//! app.update();
//! }
//! // With the default `dialogue` feature the host must also add
//! // `bevy_speech_bubbles::SpeechBubblesPlugin::<YourCamera>`, or `finish()` panics.
//! // `no_run`: a headless `App::update` never calls `finish()`, so this only compiles.
//! }
//! ```
//!
//! ## Plugins
//!
//! [`SocietyPlugins`] installs the whole society. Each member also works alone after
//! [`SocietyCorePlugin`]: the mind plugin for emotions, mood, needs and memories, the relationships
//! plugin for ties, [`BeliefsPlugin`] for opinions and rumors, [`GroupsPlugin`] for factions and
//! status, the behaviour plugin for daily life and social exchanges, [`RulesPlugin`] for Rhai
//! triggers, then the feature-gated social-field, steering and dialogue plugins.
//!
//! ## Ticks, snapshots and scripts
//!
//! The society advances on society ticks: one every [`SocietySettings::tick_secs`] of fixed-step
//! time, with every rate expressed per game-day. The systems run in the order of [`SocietySystems`]
//! — `Clock`, `Perceive`, `Mind`, `Decide`, `Interact`, `Propagate`, `Relate`, `Rules` — and only
//! `Clock` runs on every fixed step.
//!
//! Scripts see the society as it stood at the start of the tick, through a snapshot built in
//! `Perceive`; a script's own writes go to a queue. Those writes are applied once per tick, after
//! `Rules`, by one exclusive system, so no script can change what another script in the same tick
//! reads. Game-written input messages ([`PlantRumor`], [`Interact`], [`FireTrigger`]) are drained
//! on every fixed step, not only on society ticks, so a message written between ticks is never
//! dropped.
//!
//! ## Guides
//!
//! `docs/guide/getting-started.md`, `concepts.md`, `authoring.md`, `scripting.md` and `dialogue.md`;
//! `docs/research/` for the papers behind every formula; `docs/DEMOS.md` for the capture and GIF.
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
// The two value types the fields are configured with, re-exported so a host names one crate. Both are
// `bevy_stigmergy` types now: `ChannelDef` because the crate's own mirror type had no reason to exist
// once `bevy_stigmergy` 0.2 added `Reflect`, and `CellFrame` because it is the shared world↔cell
// mapping this crate and Sanctuary both used to carry their own copy of.
pub use ;
pub use ;
pub use ;
pub use ;
pub use SocietyPlugins;
pub use ;
pub use NormViolated;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;