From 2d050bbc47e57e4361e0625c0c2ee30649252820 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 23 Feb 2007 20:07:35 +0000 Subject: Functional edge probability. git-svn-id: http://svn.drobilla.net/lad/machina@330 a436a847-0d15-0410-975c-d299462d15a1 --- src/engine/Machine.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src') 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 #include "raul/SharedPtr.h" #include "machina/Machine.hpp" #include "machina/Node.hpp" @@ -93,10 +94,15 @@ Machine::exit_node(const SharedPtr 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 dst = (*s)->dst(); + + const double rand_normal = rand() / (double)RAND_MAX; // [0, 1] + + if (rand_normal <= (*s)->probability()) { + SharedPtr dst = (*s)->dst(); - if (!dst->is_active()) - dst->enter(_time); + if (!dst->is_active()) + dst->enter(_time); + } } } -- cgit v1.2.1