Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vehicle collision unit test design #27283

Open
mlangsdorf opened this issue Dec 23, 2018 · 4 comments
Open

vehicle collision unit test design #27283

mlangsdorf opened this issue Dec 23, 2018 · 4 comments
Labels
Code: Tests Measurement, self-control, statistics, balancing. <Question> Answer me please. stale Closed for lack of activity, but still valid. <Suggestion / Discussion> Talk it out before implementing Vehicles Vehicles, parts, mechanics & interactions

Comments

@mlangsdorf
Copy link
Contributor

mlangsdorf commented Dec 23, 2018

Vehicles need a set of collision unit tests

The vehicle collision code is fairly obscure. I don't think anyone really knows how it all works. It needs to get revised and refactored. First, though, it needs some unit tests so developers can tell what changed and make sure that things that aren't supposed to change didn't and things that are did.

Unfortunately, I'm not sure what the unit test case should involve.

Current plan

Take the following vehicles:
unicycle, shopping cart, beetle, electric scooter, motorcycle, car, solar car, SUV, electric SUV, security van, school bus, RV, apc.

Spawn each vehicle at 60,60 on a map of pavement (possibly other terrains?) facing north with a speed of 10, 20, 40, or 80 mph.

Spawn one of the following furnitures, terrains, or vehicles about 2 turn's of movement north of the vehicle:
long grass, wood wall, rock wall, tree, bench, fridge, flower, zombie, zombie brute, zombie hulk, dog, wolf, moose, and each of the vehicles.

Have the vehicle move 4 times, colliding with the object.

Report the final location and speed of both objects and the damage levels.

Vertical crashes

Also drop the vehicles from 2, 4, and 8 z-levels up.

Help

I would appreciate some help in getting useful data about vehicle crashes.

@mlangsdorf mlangsdorf added <Question> Answer me please. <Suggestion / Discussion> Talk it out before implementing Code: Tests Measurement, self-control, statistics, balancing. labels Dec 23, 2018
@Lorith
Copy link
Contributor

Lorith commented Dec 24, 2018

May also want to test things like individual frames and shopping carts or office chairs/wheelchairs as collision targets - they may not be driving around but should be significantly different than hitting full vehicles.

As for collecting data, maybe % of tiles damaged plus % of total hp of all parts?

@LetterShapedGlyphs
Copy link
Contributor

LetterShapedGlyphs commented Dec 24, 2018

I think the main things that would be important to test for their effects on the collision would be:
Vehicle tile width and depth at impact point, mass, and velocity.
Obstacle width and depth at impact point, mass, and resistance to being moved.

As for the data being gathered, it seems to me that the things which would need to be checked are the distribution of the damage (Both to the vehicle and the obstacle), the end location/velocity of the vehicle, and the end location of the obstacle.

To expand upon the first: I think we would want to make sure that the damage isn't JUST to the tile being hit, but follows some kind of Gaussian distribution.

Also, I think we'd want to ensure that the momentum is treated sensibly? I'm imagining something like a quick and dirty inelastic collision calculation, and then damaging both based on the kinetic energy lost.
E.g. - A stationary 100 kg zombie and a moving 1000 kg vehicle produce a combined mass of 1100 kg (I'm going to pretend the friction between the zombie and the road is negligible). Approximately 9.09% of the kinetic energy of the vehicle is lost. A quick 1/2 * m * v_i^2 gives us the amount of energy which went to damaging both objects. Then just some quick math to convert that energy into damage based on material.

Edit: A thousand apologies if this is in any way how collisions are currently handled, or planning on being handled.

@mlangsdorf
Copy link
Contributor Author

Collisions are very arcane, I don't blame anyone for not understanding how they currently work.

vehicle::part_collision() is the code that determines the amount of collision damage. Collision elasticity starts at 0.3, with 1 being a completely inelastic collision. Impassable furniture has elasticity 0.1; other terrain has varying values of e determined by terrain_collision_data(). vehicle on vehicle collisions are handled somewhat differently but not relevant.

post collision velocity is sum of initial momentum of both objects + elasticity * other object mass * difference in velocity / sum of object masses. damage is 1/400th the change in kinetic energy of the two objects. object materials factor in there somehow on the distribution of damage.

@mlangsdorf mlangsdorf added the Vehicles Vehicles, parts, mechanics & interactions label Jan 6, 2019
@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Please do not bump or comment on this issue unless you are actively working on it. Stale issues, and stale issues that are closed are still considered.

@github-actions github-actions bot added the stale Closed for lack of activity, but still valid. label Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code: Tests Measurement, self-control, statistics, balancing. <Question> Answer me please. stale Closed for lack of activity, but still valid. <Suggestion / Discussion> Talk it out before implementing Vehicles Vehicles, parts, mechanics & interactions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants