Thanks for the answers. I'm just searching for code that implements monteCarlo in an example of how to find the optimal path for nodes that search for a goal, and there are different sort of goals with different weights.
true! I read about it too. Maybe I should open other discussion for (ACO).
Here a little example of Monte Carlo PI. But far away of what I'm searching here in the forum:
// Monte Carlo
// David Dalmazzo
// 20/06/2014
int counter = 100;
void setup() {
size(800, 800);
}
void draw() {
background(50);
println(getPi(counter));
counter *= 10;
}
float getPi(int n) {
int inCircle = 0;
for (int i = 0; i < n; i++) {
float randX = random(0, 2) -1;
float randY = random(0, 2) -1;
stroke(255);
point((randX+1) * width, (randY+1) * width);
float distance = sqrt(randX * randX + randY * randY);
if (distance < 1) {
inCircle++;
stroke(0, 0, 255);
point((randX+1) * width, (randY+1) * width);
}
}
return 4.0 * inCircle / n;
}
Answers
Sure, here you go: Monte Carlo optimization example
I suppose the request was in the context of Processing, but nearly any generic algorithm, and Java examples, can be adapted to Processing.
it's a very broad question
one of the easiest might be to calculate PI
http://en.wikipedia.org/wiki/Monte_Carlo_method#Simulation_and_optimization
Thanks for the answers. I'm just searching for code that implements monteCarlo in an example of how to find the optimal path for nodes that search for a goal, and there are different sort of goals with different weights.
You might consider ant colony optimal path strategy. See:
http://en.wikipedia.org/wiki/Ant_colony_optimization_algorithms
true! I read about it too. Maybe I should open other discussion for (ACO). Here a little example of Monte Carlo PI. But far away of what I'm searching here in the forum:
Hey Jas, Have you seen any example in processing that use something like ant colony optimal path strategy? Maybe in Nature Of Code