-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
we can draw state of the system as a png now.
- Loading branch information
Tri Vo
committed
Dec 7, 2015
1 parent
0c30d55
commit b9cd47b
Showing
8 changed files
with
7,971 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,29 @@ | ||
#include "SchellingActor.hxx" | ||
#include <cstdio> | ||
|
||
__device__ __host__ SchellingActor::SchellingActor(unsigned char type){ | ||
m_type = type; | ||
} | ||
__device__ __host__ SchellingActor::SchellingActor(unsigned char type) | ||
: m_type(type), m_numberAdjacent(0) {}; | ||
|
||
__device__ __host__ SchellingActor::~SchellingActor(){ | ||
printf("SchellingActor constructor\n"); | ||
} | ||
|
||
__device__ void SchellingActor::react() { | ||
printf("SchellingActor react()\n"); | ||
//printf("SchellingActor react()\n"); | ||
for (int i = 1; i < 257; i <<= 1) { | ||
if (atomicXor((int*)&m_type, i) >> i - 1 == 0) | ||
if (atomicXor((int*)&m_type, i) >> i - 1 == 0) { | ||
increaseNumberAdjacent(); | ||
} | ||
} | ||
} | ||
|
||
__device__ void SchellingActor::send(Actor* receiver, char message) { | ||
printf("SchellingActor send()\n"); | ||
if (message != 'f' && message != static_cast<SchellingActor*>(receiver)->type()) | ||
//static_cast<SchellingActor*>(receiver)->increaseNumberAdjacent(); | ||
this->increaseNumberAdjacent(); | ||
} | ||
//printf("SchellingActor send()\n"); | ||
if (receiver == NULL) { | ||
return; | ||
} | ||
|
||
message = this->type(); | ||
if (message != 'f' && message != static_cast<SchellingActor*>(receiver)->type()) { | ||
this->increaseNumberAdjacent(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
#include "actor.h" | ||
|
||
Actor::Actor(){ | ||
m_id = -1; | ||
m_id = 0; | ||
} | ||
|
||
Actor::Actor(unsigned int id){ | ||
|
Oops, something went wrong.