Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Natural Wasp
#9
OK, I made wasp turns using "motor" - not "turn", so it flies faster and more fluently, so it's harder to shoot it down.
I rewritted whole program to make it simpler. It works much better but I'm still working on few issues (and learning CBOT :D)

Maybe you can help me - i don't have any idea what to do:
When wasps have stolen all resources, they make a big crowd near "dustbin" point - they all want to grab resources which are laying there just ti drop it again. I don't know what to do with that. I tried to make object "Cleaner" (it's in code) which will destroy resources in dustbin, but it doesn't help much.
I know the solution is to throw resources to lava, but it would work only on maps with it...

For now It works best on Tropica map.
Code:
void object::goto2(point dest)
{
float rand1 = rand(), rand2 = rand();
float dir;

errmode(0);
turn(direction(dest));
while (distance(position, dest) > 30)
{
dir = direction(dest);
if ( dir < 0 )  // on the right ?
{
motor(1, 1+dir/90);
}
else  // on the left ?
{
motor(1-dir/90, 1);
}
jet(1);
 wait(0.8);
motor(1, 0.5+rand1);
jet(0.8);
 wait(0.8);
motor(0.5+rand2, 1);
 jet(1);
 wait(1.6);
motor(1, 0.5+rand2);
 jet(0.7);
 wait(0.8);
motor(1,1);    
if (rand1 > 0.9) // make a spin sometimes. looks natural and it helps when wasp is stuck :)
{
jet(1);
motor(1,0);
wait(2);
}
if (rand2 > 0.9)
{
jet(1);
motor(0,1);
wait(2);
}
}
while (distance(position, dest) < 30)
{
while (distance(position, dest) > 7)
{
jet(1);
turn(direction(dest));
motor(1,1);
wait(0.1);
break;
}
if (distance(position, dest) <= 7)
{
motor (0,1);
wait(0.1);
}
break;
}
}

void object::Fight()
{
int danger[], i = 0;
danger[i++] = Shielder;
danger[i++] = WingedShooter;
danger[i++] = TrackedShooter;
danger[i++] = WheeledShooter;
danger[i++] = LeggedShooter;
danger[i++] = WingedOrgaShooter;
danger[i++] = TrackedOrgaShooter;
danger[i++] = WheeledOrgaShooter;
danger[i++] = LeggedOrgaShooter;
danger[i++] = PhazerShooter;
danger[i++] = DefenseTower;
danger[i++] = NuclearPlant;
danger[i++] = RadarStation;

int alien[], j = 0;
//alien[j++] = Me;
alien[j++] = WingedGrabber;
alien[j++] = TrackedGrabber;
alien[j++] = WheeledGrabber;
alien[j++] = LeggedGrabber;
alien[j++] = WingedShooter;
alien[j++] = TrackedShooter;
alien[j++] = WheeledShooter;
alien[j++] = LeggedShooter;
alien[j++] = WingedOrgaShooter;
alien[j++] = TrackedOrgaShooter;
alien[j++] = WheeledOrgaShooter;
alien[j++] = LeggedOrgaShooter;
alien[j++] = WingedSniffer;
alien[j++] = TrackedSniffer;
alien[j++] = WheeledSniffer;
alien[j++] = LeggedSniffer;
alien[j++] = Thumper;
alien[j++] = PhazerShooter;
alien[j++] = Recycler;
alien[j++] = Shielder;
alien[j++] = Subber;
alien[j++] = Houston;
alien[j++] = ExchangePost;
alien[j++] = RadarStation;
alien[j++] = Derrick;
alien[j++] = Converter;
alien[j++] = PowerPlant;
alien[j++] = NuclearPlant;
alien[j++] = BotFactory;
alien[j++] = RepairCenter;
alien[j++] = PowerStation;
alien[j++] = DefenseTower;
alien[j++] = PowerCaptor;
alien[j++] = AutoLab;
alien[j++] = ResearchCenter;

object item;

errmode(0);
if (this.load != null) {drop();}
item = radar(danger);
while (item != null)
{
Produceammo();
item = radar(alien, 0, 360, 0, 10000, FilterOnlyLanding);
goto2(item.position);
if (this.load != null) {drop();}
item = radar(danger);
if (item != null) {GoBack();}
}
}

void object::Steal()
{
int list[], k = 0;
list[k++] = Titanium;
list[k++] = PowerCell;
list[k++] = NuclearCell;
object item;

errmode(0);
if (this.load != null) {drop();}

item = radar(list, 0, 360, 200, 10000, FilterOnlyLanding);
for (;this.load==null;)
{
item = radar(list, 0, 360, 0, 10000, FilterOnlyLanding);
if (item != null)
{
goto2(item.position);
motor(0,0);
jet(-1);
turn(direction(item.position));
move(distance2d(position, item.position));
while (this.altitude > 1)
{
jet(-1);
wait(0.1);
}
wait(0.1);
goto(item.position);
wait(0.1);
if (this.load == null) {grab();}
}
}
}

void object::Randomfly()
{
jet(1);
motor(1,0);
wait(0.5);
turn(rand()*360);
jet(1);
motor(0,1);
wait(0.5);
turn(rand()*360);
}

void object::GoBack()
{
point dustbin(34, 240);

errmode(0);
goto2(dustbin);
if (this.load == null) {drop();}
}

void object::Clear()
{
int list[], k = 0;
list[k++] = Titanium;
list[k++] = PowerCell;
list[k++] = NuclearCell;
object item;

errmode(0);
item = radar(list, 0, 360, 0, 200, FilterOnlyLanding);
if (item != null)
{
Produceammo();
goto(item.position);
drop();
}
}

void object::Produceammo()
{
errmode(0);
while (this.load == null)
{
goto(space(position));
while (this.altitude > 1)
{
jet(-1);
wait(0.1);
continue;
}
wait(1);
produce(OrgaMatter);
wait(0.5);
grab();
}
}

extern void object::NaturalWasp()
{
while(true)
{
Clear();
Fight();
Steal();
GoBack();
Randomfly();
continue;    
}
}


Messages In This Thread
Natural Wasp - by krakers - 12-08-2015, 11:42 PM
RE: Natural Wasp - by RaptorParkowsky - 12-09-2015, 12:47 PM
RE: Natural Wasp - by krakers - 12-09-2015, 02:34 PM
RE: Natural Wasp - by True Destroyer - 12-10-2015, 01:26 AM
RE: Natural Wasp - by krakers - 12-15-2015, 02:43 AM
RE: Natural Wasp - by krakers - 08-01-2016, 06:48 PM
RE: Natural Wasp - by tomangelo - 08-01-2016, 08:21 PM
RE: Natural Wasp - by krakers - 08-02-2016, 09:00 AM
RE: Natural Wasp - by krakers - 08-09-2016, 11:53 AM
RE: Natural Wasp - by Smok - 08-10-2016, 10:34 PM
RE: Natural Wasp - by krakers - 08-11-2016, 09:51 PM
RE: Natural Wasp - by LRV - 10-21-2016, 08:34 AM
RE: Natural Wasp - by krakers - 12-26-2016, 01:17 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)