Exemplo n.º 1
0
Mod::Mod(const Position pos)
{
	Position northWestPos = Position(pos.x - 1, pos.y + 1);
	northWest = CellData(northWestPos, World::getInstance().getTerrain(northWestPos));

	Position northPos = Position(pos.x, pos.y + 1);
	north = CellData(northPos, World::getInstance().getTerrain(northPos));

	Position northEastPos = Position(pos.x + 1, pos.y + 1);
	northEast = CellData(northEastPos, World::getInstance().getTerrain(northEastPos));

	Position westPos = Position(pos.x - 1, pos.y);
	west = CellData(westPos, World::getInstance().getTerrain(westPos));

	Position eastPos = Position(pos.x + 1, pos.y);
	east = CellData(eastPos, World::getInstance().getTerrain(eastPos));

	Position southWestPos = Position(pos.x - 1, pos.y - 1);
	southWest = CellData(southWestPos, World::getInstance().getTerrain(southWestPos));

	Position southPos = Position(pos.x, pos.y - 1);
	south = CellData(southPos, World::getInstance().getTerrain(southPos));

	Position southEastPos = Position(pos.x + 1, pos.y - 1);
	southEast = CellData(southEastPos, World::getInstance().getTerrain(southEastPos));

	destroyWorld();
}
Exemplo n.º 2
0
    iPhysics::~iPhysics()
    {
        stop();

        if (!_bodys.empty())
        {
            con_err("possible mem leak! not all physic bodys released");

            auto iter = _bodys.begin();
            while (iter != _bodys.end())
            {
                destroyBody((*iter).second);
                iter++;
            }
            _bodys.clear();
        }

        if (!_collisions.empty())
        {
            con_err("possible mem leak! not all physic collisions released");

            auto iter = _collisions.begin();
            while (iter != _collisions.end())
            {
                destroyCollision((*iter).second);
                iter++;
            }
            _collisions.clear();
        }

        // todo clear joints

        vector<uint64> worldsToDelete;
        for (auto world : _worlds)
        {
            worldsToDelete.push_back(world.first);
        }

        for (auto worldID : worldsToDelete)
        {
            destroyWorld(worldID);
        }
    }
Exemplo n.º 3
0
int main(int argc, void * argv) {
	printf ("Hello world");
	// First of all : create a new world
	
	// Populate the world with animals : everything is quiet
	populateWorldWithAnimals();
	
	// Populate the world with humans
	populateWorldWithHumans();
	// Humans begin to build some things

	// Humans of different tribes begin to fight 
	
	// Some tribes begin to disappear
	
	// Make some stuff to destroy the world
	destroyWorld();
	// Here the world is completely destroyed. Program ends, due to the lack of a computer to run on
	printf ("Good bye cruel world");
}
//---------------------------------------------------------------------
void PageManager::destroyWorld(PagedWorld* world)
{
    destroyWorld(world->getName());
}
Exemplo n.º 5
0
void close(){
    destroyWorld();
}
	// 销毁一个碰撞世界
	void OpcodeCollisionSystem::destroyWorld(ICollisionWorld *world)
	{
		destroyWorld(world->getName());
	}
 virtual ~RigidBodyEnvironment(void)
 {
     destroyWorld();
 }
Exemplo n.º 8
0
int main(int argc, char **argv) {
#ifdef USE_MPI
	MPI_Init(&argc, &argv);
#endif

	if (argc != 5) {
		LOG_ERROR("I want width, height, zombies, iterations.\n");
#ifdef USE_MPI
		MPI_Finalize();
#endif
		exit(1);
	}

	int width = atoi(argv[1]);
	int height = atoi(argv[2]);

	int people = (int) (width * height * INITIAL_DENSITY);
	int zombies = atoi(argv[3]);

	int iters = atoi(argv[4]);

	initRandom(0);

	WorldPtr input, output;
	double ratio = divideWorld(&width, &height, &input, &output);

	// there should not be any output prior to this point
#ifdef REDIRECT
	initRedirectToFiles(input);
#endif

	LOG_DEBUG("World size is %d x %d at position [%d, %d] of %d x %d\n",
			input->localWidth, input->localHeight, input->globalX,
			input->globalY, input->globalColumns, input->globalRows);

	if (input->globalX == 0 && input->globalY == 0) {
		randomDistribution(input, people * ratio, zombies, 0);
	} else {
		// no zombies elsewhere
		randomDistribution(input, people * ratio, 0, 0);
	}

#ifndef NIMAGES
	printWorld(input, false);
#endif

	Timer timer = startTimer();

	Stats cumulative = NO_STATS;
	for (int i = 0; i < iters; i++) {
		simulateStep(input, output);

		output->stats.clock = cumulative.clock = output->clock;
		Stats stats = output->stats;
		mergeStats(&cumulative, stats, false);
		printStatistics(output, cumulative);

		WorldPtr temp = input;
		input = output;
		output = temp;
		input->stats = stats;
	}

	double elapsedTime = getElapsedTime(timer);

#ifdef _OPENMP
	int numThreads = omp_get_max_threads();
#else
	int numThreads = 1;
#endif
	LOG_TIME("Simulation took %f milliseconds with %d threads\n", elapsedTime,
			numThreads);

	// this is a clean up
	// we destroy both worlds
	destroyWorld(input);
	destroyWorld(output);

	destroyRandom();

#ifdef REDIRECT
	finishRedirectToFiles();
#endif

#ifdef USE_MPI
	MPI_Finalize();
#endif
}
Exemplo n.º 9
0
 void iPhysics::destroyWorld(uint64 id)
 {
     destroyWorld(getWorld(id));
 }