Beispiel #1
0
Datei: main.c Projekt: ifbe/42
void* beforedawn()
{
	//allocate
	void* addr = birth();

	//libboot
	initstdin( addr+0x000000);
	initstdout(addr+0x100000);
	initstdev( addr+0x200000);
	initstdrel(addr+0x300000);

	//libsoft
	initdevice(addr+0x400000);
	initdriver(addr+0x400000);

	//libsoft
	initsystem(addr+0x800000);
	initartery(addr+0x800000);

	//libuser
	initarena(addr+0xc00000);
	initactor(addr+0xc00000);

	return addr;
}
ReinforceSoldier2* ReinforceSoldier2::createReinforceSoldier(Point point)
{
    auto reinforceSoldier = new ReinforceSoldier2();
    if (reinforceSoldier && reinforceSoldier->init())
    {
        reinforceSoldier->setLocation(point);
		reinforceSoldier->setMaxHp(80);
		reinforceSoldier->setCurrHp(80); 
		reinforceSoldier->setForce(10);
		reinforceSoldier->setState(SoldierStateNone);
		reinforceSoldier->birth(point);
        reinforceSoldier->autorelease();
        return reinforceSoldier;
    }
	CC_SAFE_DELETE(reinforceSoldier);
    return NULL;
}
Beispiel #3
0
            void outputPerson(Person* person) {

                if (person == NULL) {
                    cout << "Given person is null" << endl;
                    return;
                }

                string birth("");
                birth.append(to_string(person->birth.day));
                birth.append("-");
                birth.append(to_string(person->birth.month));
                birth.append("-");
                birth.append(to_string(person->birth.year));

                string sex = mapSexToString(person->sex);

                string department = mapDepartmentToString(person->dept);

                cout << setw(10) << person->name << setw(5) << "|" << setw(10) << person->firstname << setw(5) << "|" << setw(15) << department;
                cout << setw(5) << "|" << setw(10) << birth << setw(5) << "|" << setw(10) << sex << endl;
            }
Beispiel #4
0
void
centerlife(void)
{
	int i, j, di, dj, iinc, jinc, t;

	window();
	di = NLIFE / 2 - (i0 + i1) / 2;
	if (i0 + di < 1)
		di = 1 - i0;
	else if (i1 + di >= NLIFE - 1)
		di = NLIFE - 2 - i1;
	dj = NLIFE / 2 - (j0 + j1) / 2;
	if (j0 + dj < 1)
		dj = 1 - j0;
	else if (j1 + dj >= NLIFE - 1)
		dj = NLIFE - 2 - j1;
	if (di != 0 || dj != 0) {
		if (di > 0) {
			iinc = -1;
			t = i0;
			i0 = i1;
			i1 = t;
		} else
			iinc = 1;
		if (dj > 0) {
			jinc = -1;
			t = j0;
			j0 = j1;
			j1 = t;
		} else
			jinc = 1;
		for (i = i0; i * iinc <= i1 * iinc; i += iinc)
			for (j = j0; j * jinc <= j1 * jinc; j += jinc)
				if (life[i][j] & 1) {
					birth(i + di, j + dj);
					death(i, j);
				}
	}
}
void copulate(int * childPid, int * toChildID, int * fromChildID)
{
  //Send receive info
  int toChildWrite, fromChildRead, toParentWrite,fromParentRead;
  
  //Init the sending and receiving
  initSendReceive(&toChildWrite,&fromChildRead, &toParentWrite, &fromParentRead);
  
  //Perform the forking!
  int pid = fork();
  
  if(pid == 0) 
  { 
    //A new child is born!
    //Supply child with information to
    //Communicate with parent
    //And begin life
    isParent = 0;
    //(int readFromParent,int writeToParent)
    birth(fromParentRead,toParentWrite);
    //Should never return from birth
    //But just in case, die
    //Poetic right?
    printf("Error: child returned from birth function\n");
    exit(-1);
  }
  else
  {
    //Parent
    isParent = 1;
    //Record the info for the child
    *childPid = pid;
    *toChildID = toChildWrite;
    *fromChildID = fromChildRead;
    //Then just return as normal
  }
}
Beispiel #6
0
void
readlife(char *filename)
{
	int c, i, j;
	char name[256];
	Biobuf *bp;

	if ((bp = Bopen(filename, OREAD)) == nil) {
		snprint(name, sizeof name, "/sys/games/lib/life/%s", filename);
		if ((bp = Bopen(name, OREAD)) == nil)
			sysfatal("can't read %s: %r", name);
	}
	draw(screen, screen->r, display->white, nil, ZP);
	for (i = 0; i != NLIFE; i++) {
		row[i] = col[i] = 0;
		for (j = 0; j != NLIFE; j++)
			life[i][j] = 0;
	}
	c = 0;
	for (i = 1; i != NLIFE - 1 && c >= 0; i++) {
		j = 1;
		while ((c = Bgetc(bp)) >= 0 && c != '\n')
			if (j != NLIFE - 1)
				switch (c) {
				case '.':
					j++;
					break;
				case 'x':
					birth(i, j);
					j++;
					break;
				}
	}
	Bterm(bp);
	centerlife();
}
//---------------------------------------------
void ParticleGroups::Birth_Death(SpacingMap* m_spacing)
{
	bool continueLoop = true;
	Particle *index_par = &particle[head_par];// start from the first particle
	Particle *endpointA = index_par;	// mark the endpoint A as the first par
	do
	{
		Particle *endpointB = endpointA->next;	// mark the endpoint B as the next par
		int tempA_ID = endpointA->id;
		int tempBeacon = endpointA->beacon_id;
		//----------------------------------------------------------
		// Compute the threshold and spacing viables for this pixel
		//----------------------------------------------------------
		// the average threshold of A and B's local thresholds
		float aver_threshold = 0.5 * (endpointA->last_spacing_threshold+ endpointB->last_spacing_threshold);
		float Apixel_threshold = endpointA->last_spacing_threshold;	// the threshold stored in pixels
		float Bpixel_threshold = endpointB->last_spacing_threshold;	
		if(endpointA->Is_released && endpointB->Is_released)
		{	// get the threshold of pixels at points A and B's positions; update the last_spacing stored in particles later
			Apixel_threshold = m_spacing->GetBaseThreshold(endpointA->pos.x,endpointA->pos.y); // the threshold at pixel A
			Bpixel_threshold = m_spacing->GetBaseThreshold(endpointB->pos.x,endpointB->pos.y); // the threshold at pixel B
		}

		// update the pars' info about Is_newborn before checking birth and death
		SetAsRegular(endpointA, endpointB, BRH_OFFSET*aver_threshold);	// use the average threshold computing with the OLD, NOT-UPDATED spacing_threshold
		FixDyingFlags(endpointA);	// fix dying flag if A is not longer dying with any par
		//----------------------------------------------------------
		//	start checking the Birth and Death
		//----------------------------------------------------------
		if(!endpointA->Is_newborn && !endpointB->Is_newborn)
		{
			endpointA->UpdateSpacingTd(Apixel_threshold);// update its last_spacing_threshold
			endpointB->UpdateSpacingTd(Bpixel_threshold);
			aver_threshold = 0.5 * (endpointA->last_spacing_threshold + endpointB->last_spacing_threshold);	// update the average threshold
			float AB = distAB(endpointA->pos,endpointB->pos);
			if(endpointA->Is_released && endpointB->Is_released && ((AB<DTH_OFFSET*aver_threshold && !endpointA->Is_dying && !endpointB->Is_dying) || (endpointA->dyingwith == endpointB->beacon_id && endpointB->dyingwith == endpointA->beacon_id)))
			{	// death
				if(!endpointA->Is_dying)	// mark them as dying...
				{
					endpointA->Is_dying = true;
					endpointA->dyingwith = endpointB->beacon_id;
					//endpointA->musthavepoint = true;
				}
				if(!endpointB->Is_dying)
				{
					endpointB->Is_dying = true;
					endpointB->dyingwith = endpointA->beacon_id;
					//endpointB->musthavepoint = true;
					//cout<<endpointA->beacon_id<<" and "<<endpointB->beacon_id<<" are dying..."<<endl;
				}
				if(tempA_ID == numpt-1)	// if A is the last one (A will be deleted)
				{
					Particle tempA = *endpointB;
					death(endpointA, endpointB);
					endpointA = &tempA;
				}
				else
					death(endpointA, endpointB);
			}
			// if the distance goes beyond a limit, then release a new particle
			else if(AB>BRH_OFFSET*aver_threshold && !endpointA->Is_dying && !endpointB->Is_dying && endpointA->Is_released && endpointB->Is_released)
			{	// if A moves out of the zone that it just died with the neighbour, then it can give birth
				if(!grid.StepsOnAGivenPar(endpointA,endpointA->diedwith) && distAB(endpointA->pos,endpointA->crushAt)>DTH_OFFSET*aver_threshold)
					birth(endpointA, endpointB, m_spacing);	
			}
		}
		if(tempBeacon == endpointA->beacon_id)	// make sure that endpointA has not being killed
			endpointA = endpointA->next;// move the Apointer to the next par
		//if(!Is_Foreground && !(endpointA->id==head_par && endpointA->prev->id==rear_par))
		//	continueLoop = true;	// for the contour area case
		//else 
		if(/*Is_Foreground &&*/endpointA->id!=rear_par)
			continueLoop = true;
		else
			continueLoop = false;
	} 
	while(continueLoop); // run until the continueLoop marked as false
}
Beispiel #8
0
void cell::toggle() {
    life ? die() : birth();
}
Beispiel #9
0
Sorcerer::Sorcerer(Sorcerer const & sorcerer)
{
	this->_Name = sorcerer.getName();
	this->_Title = sorcerer.getTitle();
	birth();
}
Beispiel #10
0
Sorcerer::Sorcerer(string name, string title) : _Name(name), _Title(title)
{
	birth();
}
double alpha2(double phi, void * mypars)
{
	pars * my_pars = (pars *) mypars;
	my_pars->n = (int) round(phi);
	return birth(mypars) + death(mypars); 
}