瀏覽代碼

chaipu

master
DemiSel 3 年之前
父節點
當前提交
d2651da08a
共有 2 個文件被更改,包括 7 次插入6 次删除
  1. 4
    3
      src/Agents/Agent.cpp
  2. 3
    3
      src/Main.cpp

+ 4
- 3
src/Agents/Agent.cpp 查看文件

@@ -24,7 +24,6 @@ Agent::Agent(PictureEnvironment* iEnvironment)
24 24
 
25 25
 void Agent::loop()
26 26
 {
27
-	fEnvironment->getPerception(&fCurrentPerception, fXPos, fYPos);
28 27
 	move();
29 28
 	this->paint();
30 29
 }
@@ -33,8 +32,10 @@ int MOVESIZE = 10;
33 32
 
34 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 41
 void Agent::paint()

+ 3
- 3
src/Main.cpp 查看文件

@@ -23,13 +23,13 @@ int main()
23 23
 
24 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 28
 	//int i = 0;
29 29
 	while (vEnvironment.loop())
30 30
 	{
31 31
 		;
32
-		usleep(10);
32
+		//usleep(10);
33 33
 	}
34 34
 
35 35
 	//vEnvironment.displayLockInput();

Loading…
取消
儲存