MCPcopy Create free account
hub / github.com/OpenNFS/OpenNFS / simulate

Method simulate

src/Physics/Car.cpp:477–521  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

475}
476
477void Car::simulate() {
478 std::vector<double> raycastInputs;
479 raycastInputs = {leftDistance, rightDistance, forwardDistance};
480
481 std::vector<double> networkOutputs = carNet.Infer(raycastInputs);
482
483 applySteeringLeft(networkOutputs[0] > 0.5f ? true : false);
484 applySteeringRight(networkOutputs[1] > 0.5f ? true : false);
485 applyAccelerationForce(false, networkOutputs[2] > 0.5f ? true : false);
486
487 /*if(leftDistance < 1.0f){
488 applySteeringRight(true);
489 } else {
490 applySteeringRight(false);
491 }
492Tu
493 if(rightDistance < 1.0f) {
494 applySteeringLeft(true);
495 } else {
496 applySteeringLeft(false);
497 }
498
499 if(forwardDistance >= 1.0f){
500 applyAccelerationForce(false, true);
501 } else {
502 applyAccelerationForce(true, false);
503
504 if(leftDistance < 1.0f){
505 applySteeringLeft(true);
506 } else {
507 applySteeringLeft(false);
508 }
509
510 if(rightDistance < 1.0f) {
511 applySteeringRight(true);
512 } else {
513 applySteeringRight(false);
514
515 }
516 }
517
518 if(upDistance <= 0.5f || upDistance > 90.0f){
519 resetCar(car_body_model.position);
520 }*/
521}
522
523

Callers 2

RenderMethod · 0.80
TrainAgentsMethod · 0.80

Calls 1

InferMethod · 0.80

Tested by

no test coverage detected