CUGL 1.3
Cornell University Game Library
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
CURandomNode.h
1 //
2 // CURandomNode.h
3 // Cornell University Game Library (CUGL)
4 //
5 // This module provides support for a random composite behavior node. The
6 // random behavior may be uniform or weighted.
7 //
8 // BehaviorNode objects are managed by BehaviorManager, and should never
9 // be allocated directly. Instead, you create a behavior node definition
10 // and pass it to a factor method in BehaviorManager.
11 //
12 // EXPERIMENTAL: This module is experimental. The API may change significantly
13 // in future CUGL releases.
14 //
15 // CUGL MIT License:
16 // This software is provided 'as-is', without any express or implied
17 // warranty. In no event will the authors be held liable for any damages
18 // arising from the use of this software.
19 //
20 // Permission is granted to anyone to use this software for any purpose,
21 // including commercial applications, and to alter it and redistribute it
22 // freely, subject to the following restrictions:
23 //
24 // 1. The origin of this software must not be misrepresented; you must not
25 // claim that you wrote the original software. If you use this software
26 // in a product, an acknowledgment in the product documentation would be
27 // appreciated but is not required.
28 //
29 // 2. Altered source versions must be plainly marked as such, and must not
30 // be misrepresented as being the original software.
31 //
32 // 3. This notice may not be removed or altered from any source distribution.
33 //
34 // Author: Apurv Sethi and Andrew Matsumoto (with Walker White)
35 // Version: 5/21/2018
36 //
37 #ifndef __CU_RANDOM_NODE_H__
38 #define __CU_RANDOM_NODE_H__
39 #include <cugl/ai/behavior/CUCompositeNode.h>
40 #include <random>
41 #include <string>
42 #include <vector>
43 
44 namespace cugl {
45  namespace ai {
46 
63 class RandomNode : public CompositeNode {
64 #pragma mark Values
65 protected:
67  bool _uniform;
68 
70  std::minstd_rand* _generator;
71 
72 #pragma mark Internal Helpers
73 
81  virtual int selectChild() const override;
82 
83 public:
84 #pragma mark -
85 #pragma mark Constructors
86 
92  RandomNode();
93 
98 
111  bool init(const std::string& name, std::minstd_rand* generator);
112 
120  void dispose() override;
121 
122 #pragma mark Attributes
123 
132  bool isUniform() const { return _uniform; }
133 
143  void setUniform(bool uniform) { _uniform = uniform; }
144 
155  std::string toString(bool verbose = false) const override;
156 
171  virtual void query(float dt) override;
172 
173 };
174 
175  }
176 }
177 #endif /* __CU_RANDOM_NODE_H__ */
cugl::ai::RandomNode::dispose
void dispose() override
cugl::ai::RandomNode::selectChild
virtual int selectChild() const override
cugl::ai::RandomNode::setUniform
void setUniform(bool uniform)
Definition: CURandomNode.h:143
cugl::ai::RandomNode
Definition: CURandomNode.h:63
cugl::ai::RandomNode::toString
std::string toString(bool verbose=false) const override
cugl::ai::RandomNode::init
bool init(const std::string &name, std::minstd_rand *generator)
cugl::ai::RandomNode::_generator
std::minstd_rand * _generator
Definition: CURandomNode.h:70
cugl::ai::RandomNode::_uniform
bool _uniform
Definition: CURandomNode.h:67
cugl::ai::RandomNode::query
virtual void query(float dt) override
cugl::ai::RandomNode::RandomNode
RandomNode()
cugl::ai::CompositeNode
Definition: CUCompositeNode.h:64
cugl::ai::RandomNode::~RandomNode
~RandomNode()
Definition: CURandomNode.h:97
cugl::ai::RandomNode::isUniform
bool isUniform() const
Definition: CURandomNode.h:132