Difference between revisions of "User talk:Rednaxela/FastTrig"

From Robowiki
Jump to navigation Jump to search
(Nope, won't skip turns. Garuanteed to be at least as fast so long as some rules are followed in it's usage)
(New section: My take)
Line 17: Line 17:
 
</pre>
 
</pre>
 
The initialization code doesn't take long (0.0017 seconds on my computer at 2880 divisions) but just to be sure it doesn't hurt to place the initialization outside of where the bot is timed --[[User:Rednaxela|Rednaxela]] 16:27, 3 March 2009 (UTC)
 
The initialization code doesn't take long (0.0017 seconds on my computer at 2880 divisions) but just to be sure it doesn't hurt to place the initialization outside of where the bot is timed --[[User:Rednaxela|Rednaxela]] 16:27, 3 March 2009 (UTC)
 +
 +
== My take ==
 +
 +
Nice work. From what I remember Simonton did something similar. I'm not sure if he had any luck though. One thing I noticed, I'm not sure if it works properly for negative angles, you will be rounding the wrong way. Also, the most useful trig function would be atan2. --[[User:Skilgannon|Skilgannon]] 20:43, 3 March 2009 (UTC)

Revision as of 21:43, 3 March 2009

Sound good! But, will it skipped turns at first tick of the first round? » Nat | Talk » 10:41, 3 March 2009 (UTC)

It shouldn't. It will always be as fast or faster than standard trig functions at least so long as you do the following:

  • 'inline' the index calculations like was said and used in the example test
  • Run init() BEFORE the battle begins (i.e. in static initialization code of your bot class)

An example of that static initialization code is like this:

public class SomeBot extends AdvancedRobot {
    static {
        FastTrig.init();
    }

    public void run() {
        // Not in here
    }
{

The initialization code doesn't take long (0.0017 seconds on my computer at 2880 divisions) but just to be sure it doesn't hurt to place the initialization outside of where the bot is timed --Rednaxela 16:27, 3 March 2009 (UTC)

My take

Nice work. From what I remember Simonton did something similar. I'm not sure if he had any luck though. One thing I noticed, I'm not sure if it works properly for negative angles, you will be rounding the wrong way. Also, the most useful trig function would be atan2. --Skilgannon 20:43, 3 March 2009 (UTC)