Flash Website Builder- Trendy Site Builder is a Flash Site Building tool that helps users build stunning websites. Check Out Custom Custom Logo Design by LogoBee. Website Design and Free Logo Templates available.
 CodingForums.com Robocode Difficulty Understanding

Before you post, read our: Rules & Posting Guidelines

Enjoy an ad free experience by logging in. Not a member yet? Register.
 05-29-2012, 05:19 PM PM User | #1 Sammy12 Registered User   Join Date: Jun 2011 Posts: 1,063 Thanks: 12 Thanked 241 Times in 240 Posts Robocode Difficulty Understanding Hello cf, I urgently need to know what these lines of code do? 1. Code: gravityX = gravityX * 0.85D - Math.sin(bearing) / enemyDist; gravityY = gravityY * 0.85D - Math.cos(bearing) / enemyDist; 2. Code: setTurnRightRadians(Utils.normalRelativeAngle(Math.atan2(gravity + 1.0D / getX() - 1.0D / (fieldX - getX()), gravityY + 1.0D / getY() - 1.0D / (fieldY - getY())) - getHeadingRadians())); This is a code snippet from the DustBunny nano bot, in which uses anti-gravity. I read through the anti-gravity articles, but this doesn't seem like them. Even picking them slightly apart would help me a lot. I understand the force acting, but was is D? - Sammy12 Last edited by Sammy12; 05-29-2012 at 05:24 PM..
 05-29-2012, 06:08 PM PM User | #2 Fou-Lu God Emperor     Join Date: Sep 2002 Location: Saskatoon, Saskatchewan Posts: 16,599 Thanks: 4 Thanked 2,597 Times in 2,566 Posts "D" suffix simply indicates that the number in use is a double, not a float. Although best I know Java goes the other way; fractional numbers are double by default and floats must be affixed with F, unlike whole numbers which are integers unless specified as long (ie: 13L;). You can check this against the Number: PHP Code: Number n = 0.85;System.out.println(n.getClass().getSimpleName());  Returns Double, while: PHP Code: Number n = 85;System.out.println(n.getClass().getSimpleName());  Returns Integer. So in Java, 1.0 = 1.0D. As for the rest of the equations, there's simply no way to describe them aside from what they do. Its clearly calculating rotation movements, but I can't tell you why or for what.
 Users who have thanked Fou-Lu for this post: Sammy12 (05-29-2012)
 05-29-2012, 08:32 PM PM User | #3 Sammy12 Registered User   Join Date: Jun 2011 Posts: 1,063 Thanks: 12 Thanked 241 Times in 240 Posts Thanks Fou-Lu, I think gravityX and gravityY are for the X and Y are the forces at a 90 degree angle when head to head with a bot. The Math.atan2 is the angle of the quotient of the two coordinates (maybe field - coordinate), so basically the perfect angle between X and Y, which is the best angle for the robot to move in. Thank you for your incite on the "D" that helps make things a lot easier. Did you not want to tell me what the answer was or was there not enough information provided?
 05-29-2012, 08:53 PM PM User | #4 Fou-Lu God Emperor     Join Date: Sep 2002 Location: Saskatoon, Saskatchewan Posts: 16,599 Thanks: 4 Thanked 2,597 Times in 2,566 Posts Not enough information to use. But on top of that I'd have to dust off the old geotrig books to solve the equations to see what its actually doing :P
 05-30-2012, 05:12 AM PM User | #5 Sammy12 Registered User   Join Date: Jun 2011 Posts: 1,063 Thanks: 12 Thanked 241 Times in 240 Posts haha thanks for all the help it actually really helped me understand what was going on

 Bookmarks

 Thread Tools Rate This Thread Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home :: Client side development     JavaScript programming         DOM and JSON scripting         Ajax and Design         JavaScript frameworks         Post a JavaScript     HTML & CSS     XML     Flash & ActionScript         Adobe Flex     Graphics and Multimedia discussions     General web building         Site reviews         Building for mobile devices :: Server side development     Apache configuration     Perl/ CGI     PHP         Post a PHP snippet     MySQL         Other Databases     Ruby & Ruby On Rails     ASP     ASP.NET     Java and JSP     Other server side languages/ issues         ColdFusion         Python :: Computing & Sciences     Computer Programming     Computer/PC discussions     Geek News and Humour Web Projects and Services Marketplace     Web Projects         Small projects (quick fixes and changes)         Medium projects (new script, new features, etc)         Large Projects (new web application, complex features etc)         Unknown sized projects (request quote)         Vacant job positions         Looking for work/ for hire         Project collaboration/ partnership         Paid work offers and requests (Now CLOSED)     Career, job, and business ideas or advice     Domains, Sites, and Designs for sale         Domains for sale         Websites for sale         Design templates and graphics for sale :: Other forums     Member Offers     Forum feedback and announcements

All times are GMT +1. The time now is 10:21 PM.