aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-02-23 20:07:35 +0000
committerDavid Robillard <d@drobilla.net>2007-02-23 20:07:35 +0000
commit2d050bbc47e57e4361e0625c0c2ee30649252820 (patch)
tree9d9fb14fb45a8573a4624282ed7f0db6029efd40
parent8cc603cd24294c0d917b37ea0568d89962b5a74f (diff)
downloadmachina-2d050bbc47e57e4361e0625c0c2ee30649252820.tar.gz
machina-2d050bbc47e57e4361e0625c0c2ee30649252820.tar.bz2
machina-2d050bbc47e57e4361e0625c0c2ee30649252820.zip
Functional edge probability.
git-svn-id: http://svn.drobilla.net/lad/machina@330 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/engine/Machine.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/engine/Machine.cpp b/src/engine/Machine.cpp
index 7c522dd..e7247c8 100644
--- a/src/engine/Machine.cpp
+++ b/src/engine/Machine.cpp
@@ -15,6 +15,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include <cstdlib>
#include "raul/SharedPtr.h"
#include "machina/Machine.hpp"
#include "machina/Node.hpp"
@@ -93,10 +94,15 @@ Machine::exit_node(const SharedPtr<Node> node)
// (that aren't aready active right now)
for (Node::EdgeList::const_iterator s = node->outgoing_edges().begin();
s != node->outgoing_edges().end(); ++s) {
- SharedPtr<Node> dst = (*s)->dst();
+
+ const double rand_normal = rand() / (double)RAND_MAX; // [0, 1]
+
+ if (rand_normal <= (*s)->probability()) {
+ SharedPtr<Node> dst = (*s)->dst();
- if (!dst->is_active())
- dst->enter(_time);
+ if (!dst->is_active())
+ dst->enter(_time);
+ }
}
}