Skip to content

Commit

Permalink
fist normal distribuyion
Browse files Browse the repository at this point in the history
  • Loading branch information
nietup committed Jun 13, 2015
1 parent 8db42af commit 83b2100
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 1 deletion.
Binary file modified Bamboo.sdf
Binary file not shown.
11 changes: 10 additions & 1 deletion BambooStick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,16 @@ void BambooStick::render() {
}

void BambooStick::generate() {
int segmentsNo = rand() % 5 + 3;
int segmentsNo;
std::default_random_engine generator;
std::normal_distribution<float> distribution(2.0, 0.75);

float number = distribution(generator);
if ((number >= 0.0) && (number < 4.0))
segmentsNo = (int)number + 3;
else
segmentsNo = 5;

for (int i = 0; i < segmentsNo; i++)
segments->push_back(generateSegment());
}
Expand Down
Binary file modified Debug/Bamboo.tlog/CL.read.1.tlog
Binary file not shown.
Binary file modified Debug/Bamboo.tlog/cl.write.1.tlog
Binary file not shown.
Binary file modified Debug/Bamboo.tlog/link.read.1.tlog
Binary file not shown.
Binary file modified Debug/vc120.idb
Binary file not shown.
1 change: 1 addition & 0 deletions Entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <stdlib.h> /* srand, rand */
#include <time.h> /* time */
#include <vector>
#include <random>

class Entity {
protected:
Expand Down
22 changes: 22 additions & 0 deletions gkom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "Floor.h"
#include "Camera.h"
#include "Map.h"
#include <string>

int width;
int height;
Expand Down Expand Up @@ -132,6 +133,27 @@ int main(int argc, char** argv) {
init();

glutMainLoop();
//const int nrolls = 10000; // number of experiments
//const int nstars = 100; // maximum number of stars to distribute

//std::default_random_engine generator;
//std::normal_distribution<double> distribution(2.0, 0.7);

//int p[10] = {};

//for (int i = 0; i<nrolls; ++i) {
// double number = 2*distribution(generator);
// if ((number >= 0.0) && (number<10.0)) ++p[int(number)];
//}

//std::cout << "normal_distribution (5.0,2.0):" << std::endl;

//for (int i = 0; i<10; ++i) {
// std::cout << i << "-" << (i + 1) << ": ";
// std::cout << std::string(p[i] * nstars / nrolls, '*') << std::endl;
//}
//
//std::cin.get();

return 0;
}

0 comments on commit 83b2100

Please sign in to comment.