Browse Source

chaipu

master
DemiSel 3 years ago
parent
commit
d2651da08a
2 changed files with 7 additions and 6 deletions
  1. 4
    3
      src/Agents/Agent.cpp
  2. 3
    3
      src/Main.cpp

+ 4
- 3
src/Agents/Agent.cpp View File

24
 
24
 
25
 void Agent::loop()
25
 void Agent::loop()
26
 {
26
 {
27
-	fEnvironment->getPerception(&fCurrentPerception, fXPos, fYPos);
28
 	move();
27
 	move();
29
 	this->paint();
28
 	this->paint();
30
 }
29
 }
33
 
32
 
34
 void Agent::move()
33
 void Agent::move()
35
 {
34
 {
36
-	fXPos += ((double)rand() / RAND_MAX) * MOVESIZE - ((double)MOVESIZE / 2);
37
-	fYPos += ((double)rand() / RAND_MAX) * MOVESIZE - ((double)MOVESIZE / 2);
35
+	double vRand = rand() % (MOVESIZE + 1);
36
+	fXPos += vRand - MOVESIZE / 2;
37
+	vRand = rand() % (MOVESIZE + 1);
38
+	fYPos += vRand - MOVESIZE / 2;
38
 }
39
 }
39
 
40
 
40
 void Agent::paint()
41
 void Agent::paint()

+ 3
- 3
src/Main.cpp View File

23
 
23
 
24
 	PictureEnvironment vEnvironment(filepath, &window, &platform);
24
 	PictureEnvironment vEnvironment(filepath, &window, &platform);
25
 
25
 
26
-	//vEnvironment.makeAgents(100);
27
-	vEnvironment.makeRepaintAgents(50);
26
+	//vEnvironment.makeAgents(10000);
27
+	vEnvironment.makeRepaintAgents(500);
28
 	//int i = 0;
28
 	//int i = 0;
29
 	while (vEnvironment.loop())
29
 	while (vEnvironment.loop())
30
 	{
30
 	{
31
 		;
31
 		;
32
-		usleep(10);
32
+		//usleep(10);
33
 	}
33
 	}
34
 
34
 
35
 	//vEnvironment.displayLockInput();
35
 	//vEnvironment.displayLockInput();

Loading…
Cancel
Save