Skip to content

Commit

Permalink
Rating: simplify further, move interpolate function to util.
Browse files Browse the repository at this point in the history
Remove sc_rating.cpp

git-svn-id: https://simulationcraft.googlecode.com/svn/trunk@16393 3b4652a1-8050-0410-ac47-3d40261b0f8b
  • Loading branch information
philoptik committed May 11, 2013
1 parent 0fe9d47 commit 0e857bf
Show file tree
Hide file tree
Showing 16 changed files with 106 additions and 164 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ SET(SIMC_ENGINE_SOURCE
"engine/sc_player.cpp"
"engine/sc_plot.cpp"
"engine/sc_raid_event.cpp"
"engine/sc_rating.cpp"
"engine/sc_reforge_plot.cpp"
"engine/sc_rng.cpp"
"engine/sc_scaling.cpp"
Expand Down
1 change: 0 additions & 1 deletion engine/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ SRC = \
sc_player.cpp \
sc_plot.cpp \
sc_raid_event.cpp \
sc_rating.cpp \
sc_reforge_plot.cpp \
sc_rng.cpp \
sc_scaling.cpp \
Expand Down
8 changes: 4 additions & 4 deletions engine/class_modules/sc_hunter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,13 +645,13 @@ struct hunter_main_pet_t : public hunter_pet_t
{
base_t::init_base_stats();

base.stats.attribute[ ATTR_STRENGTH ] = rating_t::interpolate( level, 0, 162, 331, 476 );
base.stats.attribute[ ATTR_AGILITY ] = rating_t::interpolate( level, 0, 54, 113, 438 );
base.stats.attribute[ ATTR_STAMINA ] = rating_t::interpolate( level, 0, 307, 361 ); // stamina is different for every pet type
base.stats.attribute[ ATTR_STRENGTH ] = util::interpolate( level, 0, 162, 331, 476 );
base.stats.attribute[ ATTR_AGILITY ] = util::interpolate( level, 0, 54, 113, 438 );
base.stats.attribute[ ATTR_STAMINA ] = util::interpolate( level, 0, 307, 361 ); // stamina is different for every pet type
base.stats.attribute[ ATTR_INTELLECT ] = 100; // FIXME: is 61 at lvl 75. Use /script print(UnitStats("pet",x)); 1=str,2=agi,3=stam,4=int,5=spi
base.stats.attribute[ ATTR_SPIRIT ] = 100; // FIXME: is 101 at lvl 75. Values are equal for a cat and a gorilla.

resources.base[ RESOURCE_HEALTH ] = rating_t::interpolate( level, 0, 4253, 6373 );
resources.base[ RESOURCE_HEALTH ] = util::interpolate( level, 0, 4253, 6373 );
resources.base[ RESOURCE_FOCUS ] = 100 + o() -> specs.kindred_spirits -> effectN( 1 ).resource( RESOURCE_FOCUS );

base_gcd = timespan_t::from_seconds( 1.20 );
Expand Down
6 changes: 5 additions & 1 deletion engine/sc_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,11 @@ void player_t::init_base_stats()
}
#endif

base.rating.init( sim, dbc, level, type );
if ( ! is_enemy() )
base.rating.init( dbc, level );

if ( sim -> debug )
sim -> output( "%s: Base Ratings initialized: %s", name(), base.rating.to_string().c_str() );

scale_challenge_mode( *this, base.rating ); // needs initialzied base.rating

Expand Down
103 changes: 0 additions & 103 deletions engine/sc_rating.cpp

This file was deleted.

71 changes: 39 additions & 32 deletions engine/sc_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,44 +204,51 @@ bool util::str_in_str_ci( const std::string& l,
return std::search( l.begin(), l.end(), r.begin(), r.end(), pred_ci ) != l.end();
}

// ability_rank =====================================================
// rating_t::interpolate ====================================================

double util::ability_rank( int player_level,
double ability_value,
int ability_level, ... )
double util::interpolate( int level,
double val_60,
double val_70,
double val_80,
double val_85 )
{
va_list vap;
va_start( vap, ability_level );

while ( player_level < ability_level )
if ( val_85 < 0 ) val_85 = val_80; // TODO
if ( level <= 60 )
{
ability_value = va_arg( vap, double );
ability_level = va_arg( vap, int );
return val_60;
}

va_end( vap );

return ability_value;
}

// ability_rank =====================================================

int util::ability_rank( int player_level,
int ability_value,
int ability_level, ... )
{
va_list vap;
va_start( vap, ability_level );

while ( player_level < ability_level )
else if ( level == 70 )
{
ability_value = va_arg( vap, int );
ability_level = va_arg( vap, int );
return val_70;
}

va_end( vap );

return ability_value;
else if ( level == 80 )
{
return val_80;
}
else if ( level >= 85 )
{
return val_85;
}
else if ( level < 70 )
{
// Assume linear progression for now.
double adjust = ( level - 60 ) / 10.0;
return val_60 + adjust * ( val_70 - val_60 );
}
else if ( level < 80 )
{
// Assume linear progression for now.
double adjust = ( level - 70 ) / 10.0;
return val_70 + adjust * ( val_80 - val_70 );
}
else // ( level < 85 )
{
// Assume linear progression for now.
double adjust = ( level - 80 ) / 5.0;
return val_80 + adjust * ( val_85 - val_80 );
}
assert( 0 );
return 0;
}

// dot_behavior_type_string =========================================
Expand Down
63 changes: 58 additions & 5 deletions engine/simulationcraft.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1180,8 +1180,9 @@ namespace util
double wall_time();
double cpu_time();

double ability_rank( int player_level, double ability_value, int ability_level, ... );
int ability_rank( int player_level, int ability_value, int ability_level, ... );
template <typename T>
T ability_rank( int player_level, T ability_value, int ability_level, ... );
double interpolate( int level, double val_60, double val_70, double val_80, double val_85 = -1 );

const char* attribute_type_string ( attribute_e type );
const char* dmg_type_string ( dmg_e type );
Expand Down Expand Up @@ -2854,6 +2855,7 @@ inline cache_e cache_from_rating( rating_e r )
case RATING_BLOCK: return CACHE_BLOCK;
case RATING_MASTERY: return CACHE_MASTERY;
case RATING_PVP_POWER: return CACHE_NONE;
case RATING_PVP_RESILIENCE: return CACHE_NONE;
default: break;
}
assert( false ); return CACHE_NONE;
Expand All @@ -2867,7 +2869,7 @@ struct rating_t
double expertise;
double dodge, parry, block;
double mastery;
double pvp_power;
double pvp_resilience, pvp_power;

double& get( rating_e r )
{
Expand All @@ -2888,12 +2890,43 @@ struct rating_t
case RATING_BLOCK: return block;
case RATING_MASTERY: return mastery;
case RATING_PVP_POWER: return pvp_power;
case RATING_PVP_RESILIENCE: return pvp_resilience;
default: break;
}
assert( false ); return mastery;
}
void init( sim_t*, dbc_t& pData, int level, player_e type );
static double interpolate( int level, double val_60, double val_70, double val_80, double val_85 = -1 );

rating_t()
{
// Initialize all ratings to a very high number
double max = +1.0E+50;
for( rating_e i = static_cast<rating_e>( 0 ); i < RATING_MAX; ++i )
{
get( i ) = max;
}
}

void init( dbc_t& dbc, int level )
{
// Read ratings from DBC
for( rating_e i = static_cast<rating_e>( 0 ); i < RATING_MAX; ++i )
{
get( i ) = dbc.combat_rating( i, level );
if ( i == RATING_MASTERY )
get( i ) /= 100.0;
}
}

std::string to_string()
{
std::ostringstream s;
for( rating_e i = static_cast<rating_e>( 0 ); i < RATING_MAX; ++i )
{
if ( i > 0 ) s << " ";
s << util::cache_type_string( cache_from_rating( i ) ) << "=" << get( i ); // hacky
}
return s.str();
}
};

// Weapon ===================================================================
Expand Down Expand Up @@ -5901,6 +5934,26 @@ T util::str_to_num ( const std::string& text )
return ss >> result ? result : T();
}

// ability_rank =====================================================
template <typename T>
T util::ability_rank( int player_level,
T ability_value,
int ability_level, ... )
{
va_list vap;
va_start( vap, ability_level );

while ( player_level < ability_level )
{
ability_value = va_arg( vap, T );
ability_level = va_arg( vap, int );
}

va_end( vap );

return ability_value;
}

// NEW ITEM STUFF REMOVED IN r<xxxx>

#endif // SIMULATIONCRAFT_H
4 changes: 0 additions & 4 deletions simc.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,6 @@
RelativePath=".\engine\sc_raid_event.cpp"
>
</File>
<File
RelativePath=".\engine\sc_rating.cpp"
>
</File>
<File
RelativePath=".\engine\interfaces\sc_rawr.cpp"
>
Expand Down
1 change: 0 additions & 1 deletion simc.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@
<ClCompile Include="engine\sc_player.cpp" />
<ClCompile Include="engine\sc_plot.cpp" />
<ClCompile Include="engine\sc_raid_event.cpp" />
<ClCompile Include="engine\sc_rating.cpp" />
<ClCompile Include="engine\interfaces\sc_rawr.cpp" />
<ClCompile Include="engine\sc_reforge_plot.cpp" />
<ClCompile Include="engine\report\sc_report.cpp" />
Expand Down
1 change: 0 additions & 1 deletion simc.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
<ClCompile Include="engine\sc_player.cpp" />
<ClCompile Include="engine\sc_plot.cpp" />
<ClCompile Include="engine\sc_raid_event.cpp" />
<ClCompile Include="engine\sc_rating.cpp" />
<ClCompile Include="engine\interfaces\sc_rawr.cpp" />
<ClCompile Include="engine\sc_reforge_plot.cpp" />
<ClCompile Include="engine\report\sc_report.cpp" />
Expand Down
1 change: 0 additions & 1 deletion simc11.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@
<ClCompile Include="engine\sc_player.cpp" />
<ClCompile Include="engine\sc_plot.cpp" />
<ClCompile Include="engine\sc_raid_event.cpp" />
<ClCompile Include="engine\sc_rating.cpp" />
<ClCompile Include="engine\interfaces\sc_rawr.cpp" />
<ClCompile Include="engine\sc_reforge_plot.cpp" />
<ClCompile Include="engine\report\sc_report.cpp" />
Expand Down
1 change: 0 additions & 1 deletion simc11.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<ClCompile Include="engine\sc_player.cpp" />
<ClCompile Include="engine\sc_plot.cpp" />
<ClCompile Include="engine\sc_raid_event.cpp" />
<ClCompile Include="engine\sc_rating.cpp" />
<ClCompile Include="engine\sc_reforge_plot.cpp" />
<ClCompile Include="engine\sc_rng.cpp" />
<ClCompile Include="engine\sc_scaling.cpp" />
Expand Down
1 change: 0 additions & 1 deletion simcqt.pro
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ SOURCES += engine/sc_pet.cpp
SOURCES += engine/sc_player.cpp
SOURCES += engine/sc_plot.cpp
SOURCES += engine/sc_raid_event.cpp
SOURCES += engine/sc_rating.cpp
SOURCES += engine/sc_reforge_plot.cpp
SOURCES += engine/sc_rng.cpp
SOURCES += engine/sc_scaling.cpp
Expand Down
4 changes: 0 additions & 4 deletions simcqt.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -495,10 +495,6 @@
RelativePath="engine\sc_raid_event.cpp"
>
</File>
<File
RelativePath="engine\sc_rating.cpp"
>
</File>
<File
RelativePath="engine\interfaces\sc_rawr.cpp"
>
Expand Down
Loading

0 comments on commit 0e857bf

Please sign in to comment.