BerryBots forums

It is currently Mon Mar 25, 2019 5:49 am

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Wall game physics
PostPosted: Wed Sep 23, 2015 1:42 pm 
Offline

Joined: Wed Sep 23, 2015 12:17 pm
Posts: 6
In the specs it is given that ships loose energy when colliding wit walls depending on impact angle:

Quote:
If it just grazes the wall, this is only a small percentage of its speed; if it slams directly into a wall, it will lose half of its speed. It doesn't take any damage.


How is the actual calculation formula? Does it loose just the normal (reflected) component of the velocity or the magnitude of the velocity (speed)?


Top
 Profile  
 
 Post subject: Re: Wall game physics
PostPosted: Wed Sep 23, 2015 6:12 pm 
Offline
Site Admin
User avatar

Joined: Sat Nov 17, 2012 5:03 am
Posts: 88
It's based on the normal of the velocity against the wall - it loses 50% of that component of its velocity (and it's reversed, since you bounce off). Here's the actual code, which applies a force of 1.5x the normal in the opposite direction (WALL_BOUNCE = 0.5): stage.cpp#L879


Top
 Profile  
 
 Post subject: Re: Wall game physics
PostPosted: Wed Sep 23, 2015 7:35 pm 
Offline

Joined: Wed Sep 23, 2015 12:17 pm
Posts: 6
That's what I thought. But my targeting system including wall bounces predictor is still somewhat off... I guess the error lies elsewhere :). Thank you.


Top
 Profile  
 
 Post subject: Re: Wall game physics
PostPosted: Mon Nov 16, 2015 6:44 am 
Offline
User avatar

Joined: Mon Nov 16, 2015 6:04 am
Posts: 6
If this is to defeat sanic, if I remember correctly I had it add a decent component of perpendicular force to its path between wall bounces so as to throw of linear leads somewhat (even though at the speed it is travelling, such a tiny adjustment shouldn't effect much). I'd recommend testing against an even simpler bot which bounces off of walls without any other actions.


Top
 Profile  
 
 Post subject: Re: Wall game physics
PostPosted: Tue Nov 17, 2015 1:17 pm 
Offline
User avatar

Joined: Mon Nov 16, 2015 6:04 am
Posts: 6
Not sure if I've got to edit posts, or if they're merged automagically, but another point of note is that in addition to the partially inelastic collision, you can't treat the ships as infinitesimally small points -- they've got a radius.

Here's a quick test I've been putting together, and this is about as close as I can get it:
https://gfycat.com/WanSmartGorilla

(The ship randomises its velocity, then puffs every 20 ticks in its current heading, to maintain speed)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group