Merge branch 'master' of https://github.com/supertuxkart/stk-code
This commit is contained in:
commit
02f77f315e
@ -37,6 +37,7 @@
|
||||
#include "utils/constants.hpp"
|
||||
|
||||
#include <IMeshSceneNode.h>
|
||||
#include <numeric>
|
||||
#include <string>
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Constructor. Sets up the clock mode etc.
|
||||
@ -54,7 +55,6 @@ SoccerWorld::SoccerWorld() : WorldWithRank()
|
||||
}
|
||||
|
||||
m_frame_count = 0;
|
||||
m_start_time = irr_driver->getRealTime();
|
||||
m_use_highscores = false;
|
||||
m_red_ai = 0;
|
||||
m_blue_ai = 0;
|
||||
@ -212,6 +212,13 @@ void SoccerWorld::onCheckGoalTriggered(bool first_goal)
|
||||
m_goal_sound->play();
|
||||
if (m_ball_hitter != -1)
|
||||
{
|
||||
if (UserConfigParams::m_arena_ai_stats)
|
||||
{
|
||||
const int elapsed_frame = m_goal_frame.empty() ? 0 :
|
||||
std::accumulate(m_goal_frame.begin(), m_goal_frame.end(), 0);
|
||||
m_goal_frame.push_back(m_frame_count - elapsed_frame);
|
||||
}
|
||||
|
||||
ScorerData sd;
|
||||
sd.m_id = m_ball_hitter;
|
||||
sd.m_correct_goal = isCorrectGoal(m_ball_hitter, first_goal);
|
||||
@ -601,11 +608,37 @@ void SoccerWorld::enterRaceOverState()
|
||||
|
||||
if (UserConfigParams::m_arena_ai_stats)
|
||||
{
|
||||
float runtime = (irr_driver->getRealTime()-m_start_time)*0.001f;
|
||||
Log::verbose("Soccer AI profiling", "Number of frames: %d, Average FPS: %f",
|
||||
m_frame_count, (float)m_frame_count/runtime);
|
||||
Log::verbose("Soccer AI profiling", "Time for a team to have 30 goals: %f",
|
||||
runtime);
|
||||
Log::verbose("Soccer AI profiling", "Total frames elapsed for a team"
|
||||
" to win with 30 goals: %d", m_frame_count);
|
||||
|
||||
// Goal time statistics
|
||||
std::sort(m_goal_frame.begin(), m_goal_frame.end());
|
||||
|
||||
const int mean = std::accumulate(m_goal_frame.begin(),
|
||||
m_goal_frame.end(), 0) / m_goal_frame.size();
|
||||
|
||||
// Prevent overflow if there is a large frame in vector
|
||||
double squared_sum = 0;
|
||||
for (const int &i : m_goal_frame)
|
||||
squared_sum = squared_sum + (double(i - mean) * double(i - mean));
|
||||
|
||||
// Use sample st. deviation (n−1) as the profiling can't be run forever
|
||||
const int stdev = int(sqrt(squared_sum / (m_goal_frame.size() - 1)));
|
||||
|
||||
int median = 0;
|
||||
if (m_goal_frame.size() % 2 == 0)
|
||||
{
|
||||
median = (m_goal_frame[m_goal_frame.size() / 2 - 1] +
|
||||
m_goal_frame[m_goal_frame.size() / 2]) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
median = m_goal_frame[m_goal_frame.size() / 2];
|
||||
}
|
||||
|
||||
Log::verbose("Soccer AI profiling", "Frames elapsed for each goal:"
|
||||
" min: %d max: %d mean: %d median: %d standard deviation: %d",
|
||||
m_goal_frame.front(), m_goal_frame.back(), mean, median, stdev);
|
||||
|
||||
// Goal calculation
|
||||
int red_own_goal = 0;
|
||||
@ -623,9 +656,9 @@ void SoccerWorld::enterRaceOverState()
|
||||
red_own_goal++;
|
||||
}
|
||||
|
||||
int red_goal = ((m_red_scorers.size() - blue_own_goal) >= 0 ?
|
||||
int red_goal = ((int(m_red_scorers.size()) - blue_own_goal) >= 0 ?
|
||||
m_red_scorers.size() - blue_own_goal : 0);
|
||||
int blue_goal = ((m_blue_scorers.size() - red_own_goal) >= 0 ?
|
||||
int blue_goal = ((int(m_blue_scorers.size()) - red_own_goal) >= 0 ?
|
||||
m_blue_scorers.size() - red_own_goal : 0);
|
||||
|
||||
Log::verbose("Soccer AI profiling", "Red goal: %d, Red own goal: %d,"
|
||||
|
@ -302,7 +302,7 @@ private:
|
||||
|
||||
/** Profiling usage */
|
||||
int m_frame_count;
|
||||
int m_start_time;
|
||||
std::vector<int> m_goal_frame;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -111,7 +111,8 @@ void PhysicalObject::Settings::init()
|
||||
m_linear_factor = Vec3(1.0f, 1.0f, 1.0f);
|
||||
m_angular_factor = Vec3(1.0f, 1.0f, 1.0f);
|
||||
m_linear_damping = 0.0f;
|
||||
m_angular_damping = 0.0f;
|
||||
// Make sure that the cones stop rolling by defining angular friction != 0.
|
||||
m_angular_damping = 0.5f;
|
||||
m_reset_when_too_low = false;
|
||||
m_flatten_kart = false;
|
||||
} // Settings
|
||||
@ -521,8 +522,6 @@ void PhysicalObject::init(const PhysicalObject::Settings& settings)
|
||||
btRigidBody::btRigidBodyConstructionInfo info(m_mass, m_motion_state,
|
||||
m_shape, inertia);
|
||||
|
||||
// Make sure that the cones stop rolling by defining angular friction != 0.
|
||||
info.m_angularDamping = 0.5f;
|
||||
m_body = new btRigidBody(info);
|
||||
m_user_pointer.set(this);
|
||||
m_body->setUserPointer(&m_user_pointer);
|
||||
|
Loading…
Reference in New Issue
Block a user