.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Cyborg Factory > POD-Bot mm > Releases, Installers, Docs & Coding
Releases, Installers, Docs & Coding Where the official development happens

Closed Thread
 
Thread Tools
Re: POD-bot back into shape.
Old
  (#331)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: POD-bot back into shape. - 02-04-2004

Quote:
Originally Posted by Whistler
...it's this:
if (angle >= 180)
angle -= 360 * (int)(angle / 360 + 0.5); // 0.5 is INSIDE the (int)(...)
If you do this then your code will behave wrong for large values of angle, do you know that ? 9_9

The function will exit and the angle will still be overflown.



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Re: POD-bot back into shape.
Old
  (#332)
Whistler
Summoner
 
Whistler's Avatar
 
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
Default Re: POD-bot back into shape. - 02-04-2004

Anyway I have tested it with this little program and it's all ok:
Code:
  #include <stdio.h>
  
  float AngleNormalize(float angle)
  {
     if (angle >= 180)
  	  angle -= 360 * (int)(angle / 360 + 0.5);
     if (angle < -180)
  	  angle += 360 * (int)(-angle / 360 + 0.5);
     return angle;
  }
  
  
  main()
  {
     float a;
     float b;
     for (a = -2532.3; a < 3602.3; a += 0.1235)
     {
  	  b = AngleNormalize(a);
  	  if (b >= 180 || b < -180)
  	  {
  	 printf("your code is wrong !\n");
  	 return;
  	  }
     }
     printf("your code is right !\n");
  }
Also the asserts are never failed in YaPB. You can try playing YaPB for a few round and I'm pretty sure you'll find no angles are mess up.

Last edited by Whistler; 03-04-2004 at 02:21..
  
Re: POD-bot back into shape.
Old
  (#333)
SoUlFaThEr
Moderator
 
SoUlFaThEr's Avatar
 
Status: Offline
Posts: 860
Join Date: Mar 2004
Default Re: POD-bot back into shape. - 02-04-2004

i got a thing here.....with a new waypoint done within these last 2 updates.....that does not show up on waypoints from before........

i cant even show you a demo cuz you dont have the map...........(PMB) (its cs_1337_assault)

the ct gets the hostages and then appears a message:
waypoint problem: no path found

and the bot cannot get out of this room......with his hostages........when he accidentaly does.....hes walking straight through a no hostage flag......

thinking it was a no hostage flag placement mistake of mine......i went through the routes he should take and did a wp delete flag on every single waypoint from the goal to the rescue waypoint.......and the error still occurs. 2 errors in one shot.......

i went into cs_assault..to see if it happens here and it runs perfectly......no clue man......and the PODERROR.txt...(now much smaller!) shows no error of any kind.



Last edited by SoUlFaThEr; 02-04-2004 at 16:37..
  
Re: POD-bot back into shape.
Old
  (#334)
sPlOrYgOn
<-- He did it.
 
sPlOrYgOn's Avatar
 
Status: Offline
Posts: 1,558
Join Date: Jan 2004
Location: Los Angeles, California, USA, North America, Earth, Solar System, Milky Way.
Default Re: POD-bot back into shape. - 02-04-2004

both ways work just fine...
[edit]
of course this is about the angles..
[/edit]
[edit2]
Code:
#include <stdio.h>

float AngleNormalize(float angle)
{
	if (angle >= 180)
		angle -= 360 * (int)(angle / 360 + 0.5);
	if (angle < -180)
		angle += 360 * (int)(-angle / 360 + 0.5);
	return angle;
}

float angleNormalize(float angle)
{
	if (angle >= 180)
		angle -= 360 * ((int)(angle / 360) + 1);
	if (angle < -180)
		angle += 360 * ((int)(-angle / 360) + 1);
	return angle;
}

int main()
{
	float a = 180.0, b, c;
	int notsame = 0;
	for (a = -9999.9; a < 9999.9; a += 0.001)
	{
		b = AngleNormalize(a);
		c = angleNormalize(a);
		if (b != c)
			notsame++;
	}
	if(notsame <= 0)
		printf("Some are not the same...\n");
	else
		printf("they all the same WOOT!\n");
	return(0);
}
[/edit2]

Last edited by sPlOrYgOn; 02-04-2004 at 16:46..
  
Re: POD-bot back into shape.
Old
  (#335)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: POD-bot back into shape. - 02-04-2004

@Whistler:

Nope ! it's NOT okay, because even if your resulting angles are in bounds, they are NOT ANYMORE modulo 360 versions of the original one !


it's as if you were doing
Code:
if ((angle < -180) || (angle >= 180))
   angle = RANDOM_FLOAT (-180, 180);
... with a bit of exxageration, I concede

Nevertheless your code is wrong, and I can prove it.
Instead of running your test program, rather run this one:
Code:
void main (void)
{
   float random_angle;
   float result_angle;
   int count = 0;
 
   while (1)
   {
	  random_angle = RANDOM_FLOAT (-100000000, 100000000);
 
	  result_angle = AngleNormalize (random_angle);
	  if ((result_angle < -180) || (result_angle >= 180))
	  {
		  printf ("ERROR! in=%f out=%f count=%d\n", random_angle, result_angle, count);
		  getchar ();
	  }
 
	  result_angle = AngleNormalize360 (random_angle);
	  if ((result_angle < 0) || (result_angle >= 360))
	  {
		  printf ("ERROR! in=%f out=%f count=%d\n", random_angle, result_angle, count);
		  getchar ();
	  }
 
	  count++;
   }
}
You will see that your code fails for large values of angle.

And NOT only this, but if you add a
Code:
	 printf ("in=%f out=%f\n", random_angle, result_angle);
	 getchar ();
for each angle that is tested, and compare the input and the output, you'll notice that the output is NOT a modulo 360 representative of the input. You have an error that goes increasing with larger values.

Believe me, I've tested it all thoroughly, thanks to you pointing me that bug, and I've found the right code. It goes like this:
Code:
float WrapAngle (float angle)
{
   // this function adds or substracts 360 enough times needed to the angle_to_wrap angle in
   // order to set it into the range -180/+180 and returns the resulting angle. Letting the
   // engine have a hand on angles that are outside these bounds may cause the game to freeze
   // by screwing up the engine math code.
 
   // check for wraparound of angle
   if (angle >= 180)
	  angle -= 360 * abs (((int) angle + 180) / 360);
   if (angle < -180)
	  angle += 360 * abs (((int) angle - 180) / 360);
 
   // needs a 2nd pass to check for floating part truncation (rounded 180)
   if (angle == 180.0)
	  angle = -180;
 
   return (angle);
}
 
float WrapAngle360 (float angle)
{
   // this function adds or substracts 360 enough times needed to the angle_to_wrap angle in
   // order to set it into the range +0/+360 and returns the resulting angle Letting the
   // engine have a hand on angles that are outside these bounds may cause the game to freeze
   // by screwing up the engine math code.
 
   // check for wraparound of angle
   if (angle >= 360)
	  angle -= 360 * abs ((int) angle / 360);
   if (angle < 0)
	  angle += 360 * abs (((int) angle - 360) / 360);
 
   // needs a 2nd pass to check for floating part truncation (rounded 180)
   if (angle == 360.0)
	  angle = 0;
 
   return (angle);
}
And if you think about it it's perfectly logical. The function asks itself, how many times can I add OR substract 360 to the current angle to have it in the bounds ? Then, taking the absolute of this value, it either adds (if value was initially inferior) OR substract (if value was initially superior) - hence the abs(), as many times 360 as needed and the resulting angle is GUARANTEED to be in bounds, and a modulo of 360.

The only check left to do is the floating point truncation (precision error) that would make the final angle land accurately on a rounded 180 (which would be just above the limit).



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."

Last edited by Pierre-Marie Baty; 02-04-2004 at 16:57..
  
Re: POD-bot back into shape.
Old
  (#336)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: POD-bot back into shape. - 02-04-2004

@SoUlFaThEr, your problem IS a waypoint problem. It means that the bot can find a way to get TO the hostages, but it can't find a way BACK, because all the routes it could take are blocked with a FL_NOHOSTAGE flag. Try waypointing your map again, you'll see it works. I understand now why you said the bot was ignoring the FL_NOHOSTAGE flag before on this map, that was because the bot couldn't find ANY other way back. Double-check your waypoints again, and beware of one-way connections



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Re: POD-bot back into shape.
Old
  (#337)
SoUlFaThEr
Moderator
 
SoUlFaThEr's Avatar
 
Status: Offline
Posts: 860
Join Date: Mar 2004
Default Re: POD-bot back into shape. - 02-04-2004

EDIT


MY BAD DUDE......i ran through it without seing one waypoint with a no connect........im sorry!!!!!!!!

ok i suck thats what happens when you dont sleep



Last edited by SoUlFaThEr; 02-04-2004 at 17:08..
  
Re: POD-bot back into shape.
Old
  (#338)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: POD-bot back into shape. - 02-04-2004

tsk tsk tsk, check them again. I *know* how the code works, and I tell you, your waypoints will STILL be saved even if all of them wear a FL_NOHOSTAGE flag. The checking routine doesn't check for this.

Isn't there simply a FL_NOHOSTAGE right at the exit of the room ?

Test them again. Trust me. Waypoint problem.

...

if I'm wrong I pay you a pack of beer and I ship it by air mail.



*edit* then no beer for Tim
hehehehehehehe



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."

Last edited by Pierre-Marie Baty; 02-04-2004 at 17:14..
  
Re: POD-bot back into shape.
Old
  (#339)
SoUlFaThEr
Moderator
 
SoUlFaThEr's Avatar
 
Status: Offline
Posts: 860
Join Date: Mar 2004
Default Re: POD-bot back into shape. - 02-04-2004

damn and i was getting thirsty......i owe you some beer.....what you want?
Guiness?


  
Re: POD-bot back into shape.
Old
  (#340)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: POD-bot back into shape. - 02-04-2004

lol dude, any blonde will do

/me pops off a garette and waits for the beer...



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com