Esempio n. 1
0
int main()
{
	New();
	
	LifeState* snakePair = NewState("2ob2o$o3bo$bobo$2ob2o!", -15, -7);
	LifeTarget* target = NewTarget(snakePair);
	
	//For lower part
	LifeState* synth = NewState("obo$b2o$bo13$4bo$4b2o$3bobo$11b3o$11bo$12bo$18bo$17b2o$17bobo!", -20, -20);
	LifeState* gld = NewState("bo$2o$obo!", -6, 13, 1, 0, 0, 1);
	LifeIterator* iter = NewIterator(gld, -30, -30, 60, 60, 4);
	LifeTarget* targetEmpty = NewTarget(Captures[1], NewState("5o2bo2b5o$5ob3ob5o$6obob6o$5o2bo2b5o$15o$15o$15o$15o$15o$15o$15o$15o$15o$15o$15o$15o!", -20, -7));

	//For upper part
	//LifeState* synth = NewState("obo$b2o$bo13$4bo$4b2o$3bobo$11b3o$11bo$12bo$18bo$17b2o$17bobo5$11bo$10b2o$10bobo!", -20, -20);
	//LifeTarget* targetEmpty = NewTarget(Captures[1], NewState("15o$15o$15o$15o$15o$15o$15o$15o$15o$15o$15o$5o2bo2b5o$5ob3ob5o$6obob6o$5o2bo2b5o!", -20, -18));
	//LifeState* gld = NewState("2bo$2o$b2o!", -2, -23, 1, 0, 0, -1);
	//LifeIterator* iter = NewIterator(gld, -30, -10, 60, 60, 4);
	
	do
	{
		New();
		
		PutState(synth);
		PutState(iter);
		
		
		Run(210);
		Capture(0);
		Run(2);
		
		//if(ContainsTarget(targetEmpty) == NO && ContainsTarget(target) == YES && GetPop() != 12 + 5)
		if(ContainsTarget(targetEmpty) == NO && ContainsTarget(target) == YES)// && !AreEqual(0))
		{
			Print();
			
			New();
			
			PutState(synth);
			PutState(iter);
			
			PrintRLE();
			//Print();
			
			printf("\nSUCCESS\n");
			getchar();
			printf("\nSearching\n");
			
		}
	}
	while(Next(iter) == SUCCESS);
	
	printf("\nFinish\n");
	
	getchar();
}
Esempio n. 2
0
//---------------------------------------------------------------------
void BaseTween::KillTarget(ITweenable* _target, TweenType _type)							
{
	if(ContainsTarget(_target, _type))
    {
		Kill();
    }
}
Esempio n. 3
0
//---------------------------------------------------------------------
void BaseTween::KillTarget(ITweenable* _target)							
{
	if(ContainsTarget(_target))
    {
		Kill();
    }
}
Esempio n. 4
0
int main()
{
	printf("\n\n================LifeAPISample with explanation: =============\n\n");
	printf("\n\n           Target with two gliders search example: \n\n");
	
	//Always start with New();
	New();
	
	//Initial pattern
	LifeState* pat =  NewState("obo$b2o$bo9$4bo$4b2o$3bobo$7b3o$7bo$8bo$14bo$13b2o$13bobo!", -20, -20);
	
	//target and inverse target
	LifeState* target =  NewState("$b2ob2o$bo3bo$2bobo$b2ob2o3$3bo$2bobo$3bo!", -18, -10);
	LifeState* inverse = NewState("7o$o2bo2bo$ob3obo$2obob2o$o2bo2bo$7o$7o$3ob3o$2obob2o$3ob3o$7o!", -18, -10);
	
	//Life target object contains the on and the off cells
	LifeTarget * fulltarget = NewTarget(target, inverse);
	
	//glider with (+1, -1) direction at (0,0)
	LifeState* gld =  NewState("b2o$obo$2bo!", 0, 0);
	
	New();
	PutState(pat);
	Print();
	printf("\n\n We have durty snake pair synthesis \n\n");
	Continue();
	Run(21);
	Print();
	Continue();
	printf("\n\n It destoryed after 2 generations \n\n");
	Run(2);
	Print();
	Continue();
	
	printf("\n\n We want to place 2 gliders to reach this configuration \n\n");
	
	New();
	PutState(target);
	Print();
	
	Continue();

	New();
	PutState(inverse);
	Print();
	
	printf("\n\n While all these cells should be off \n\n");
	Continue();

	printf("\n\nSearching... \n\n");
	
	//Gldier iterators always have 4 states
	LifeIterator *iter1 = NewIterator(gld, -27, 2, 15, 15, 4);
	LifeIterator *iter2 = NewIterator(gld, -27, 2, 15, 15, 4);
	
	do
	{
		if(Validate(iter1, iter2) == FAIL)
			continue; 
			
		New();
		
		PutState(pat);
		PutState(iter1);
		PutState(iter2);
		
		//100 should be enough
		Run(100);
		
		//ContainsTarget checks both "on" and "off" cells
		if(ContainsTarget(fulltarget) == YES)
		{
			printf("\nFound!\n\n");
			
			New();
			
			PutState(pat);
			PutState(iter1);
			PutState(iter2);

			PrintRLE();
			printf("\n\n");
			
			Print();
			
			Run(100);
			
			Print();
			
			Continue();
			printf("\Searching...\n\n");
		}
	}while(Next(iter1, iter2, "none") == SUCCESS);
	
	printf("\nFinished");
	getch();
}