Skip to content

Commit

Permalink
account for higher/lower judge values in SSR calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed Jan 30, 2017
1 parent 449a413 commit 770dd77
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 18 deletions.
35 changes: 27 additions & 8 deletions src/HighScore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ struct HighScoreImpl
unsigned int iScore;
float fPercentDP;
float fWifeScore;
float fSSRNormPercent;
float fSurviveSeconds;
float fMusicRate;
float fJudgeScale;
Expand Down Expand Up @@ -179,6 +180,7 @@ HighScoreImpl::HighScoreImpl()
iScore = 0;
fPercentDP = 0.f;
fWifeScore = 0.f;
fSSRNormPercent = 11111.f;
fMusicRate = 0.f;
fJudgeScale = 0.f;
bEtternaValid = true;
Expand Down Expand Up @@ -216,6 +218,7 @@ XNode *HighScoreImpl::CreateNode() const
pNode->AppendChild( "Score", iScore );
pNode->AppendChild( "PercentDP", fPercentDP );
pNode->AppendChild( "WifeScore", fWifeScore);
pNode->AppendChild( "SSRNormPercent", fSSRNormPercent);
pNode->AppendChild( "Rate", fMusicRate);
pNode->AppendChild( "JudgeScale", fJudgeScale);
pNode->AppendChild( "EtternaValid", bEtternaValid);
Expand Down Expand Up @@ -255,7 +258,6 @@ XNode *HighScoreImpl::CreateNode() const
pNode->AppendChild( radarValues.CreateNode(bWriteSimpleValues, bWriteComplexValues) );
pNode->AppendChild( "LifeRemainingSeconds", fLifeRemainingSeconds );
pNode->AppendChild( "Disqualified", bDisqualified);

return pNode;
}

Expand All @@ -273,6 +275,7 @@ void HighScoreImpl::LoadFromNode(const XNode *pNode)
pNode->GetChildValue("Score", iScore);
pNode->GetChildValue("PercentDP", fPercentDP);
pNode->GetChildValue("WifeScore", fWifeScore);
pNode->GetChildValue("SSRNormPercent", fSSRNormPercent);
pNode->GetChildValue("Rate", fMusicRate);
pNode->GetChildValue("JudgeScale", fJudgeScale);
pNode->GetChildValue("EtternaValid", bEtternaValid);
Expand Down Expand Up @@ -373,11 +376,14 @@ bool HighScoreImpl::WriteReplayData() {


bool HighScore::LoadReplayData() {
// already exists
if (m_Impl->vNoteRowVector.size() > 4 && m_Impl->vOffsetVector.size() > 4)
return true;

vector<int> vNoteRowVector;
vector<float> vOffsetVector;
RString profiledir = PROFILEMAN->currentlyloadingprofile;
std::ifstream fileStream(profiledir + "ReplayData/" + m_Impl->ScoreKey, ios::binary);
LOG->Trace(profiledir + "ReplayData/" + m_Impl->ScoreKey);
string line;
string buffer;
vector<string> tokens;
Expand Down Expand Up @@ -451,6 +457,7 @@ StageAward HighScore::GetStageAward() const { return m_Impl->stageAward; }
PeakComboAward HighScore::GetPeakComboAward() const { return m_Impl->peakComboAward; }
float HighScore::GetPercentDP() const { return m_Impl->fPercentDP; }
float HighScore::GetWifeScore() const { return m_Impl->fWifeScore; }
float HighScore::GetSSRNormPercent() const { return m_Impl->fSSRNormPercent; }
float HighScore::GetMusicRate() const { return m_Impl->fMusicRate; }
float HighScore::GetJudgeScale() const { return m_Impl->fJudgeScale; }
bool HighScore::GetEtternaValid() const { return m_Impl->bEtternaValid; }
Expand Down Expand Up @@ -478,6 +485,7 @@ void HighScore::SetStageAward( StageAward a ) { m_Impl->stageAward = a; }
void HighScore::SetPeakComboAward( PeakComboAward a ) { m_Impl->peakComboAward = a; }
void HighScore::SetPercentDP( float f ) { m_Impl->fPercentDP = f; }
void HighScore::SetWifeScore(float f) {m_Impl->fWifeScore = f;}
void HighScore::SetSSRNormPercent(float f) { m_Impl->fSSRNormPercent = f; }
void HighScore::SetMusicRate(float f) { m_Impl->fMusicRate = f; }
void HighScore::SetJudgeScale(float f) { m_Impl->fJudgeScale = f; }
void HighScore::SetEtternaValid(bool b) { m_Impl->bEtternaValid = b; }
Expand Down Expand Up @@ -564,9 +572,15 @@ void HighScore::LoadFromNode( const XNode* pNode )
m_Impl->bEtternaValid = false;
}

LOG->Trace("%i", m_Impl->vOffsetVector.size());
LoadReplayData();
LOG->Trace("%i", m_Impl->vOffsetVector.size());
if (m_Impl->fSSRNormPercent == 11111.f) {
if (m_Impl->grade != Grade_Failed)
m_Impl->fSSRNormPercent = RescoreToWifeJudge(4);
else
m_Impl->fSSRNormPercent = m_Impl->fWifeScore;

m_Impl->vNoteRowVector.clear();
m_Impl->vOffsetVector.clear();
}
}

RString HighScore::GetDisplayName() const
Expand Down Expand Up @@ -750,22 +764,27 @@ void Screenshot::LoadFromNode( const XNode* pNode )
}

float HighScore::RescoreToWifeJudge(int x) {
if (!LoadReplayData())
return m_Impl->fWifeScore;

const float tso[] = { 1.50f,1.33f,1.16f,1.00f,0.84f,0.66f,0.50f,0.33f,0.20f };
float ts = tso[x-1];
float p = 0;
FOREACH_CONST(float, m_Impl->vOffsetVector, f)
p += wife2(*f, ts);

return p / (m_Impl->vOffsetVector.size() * 2);
p += (m_Impl->iHoldNoteScores[HNS_LetGo] + m_Impl->iHoldNoteScores[HNS_Missed]) * -6.f;
return p / static_cast<float>(m_Impl->vOffsetVector.size() * 2);
}

// do not use for now- mina
float HighScoreImpl::RescoreToWifeTS(float ts) {
float p = 0;
FOREACH_CONST(float, vOffsetVector, f)
p += wife2(*f, ts);

p += (iHoldNoteScores[HNS_LetGo] + iHoldNoteScores[HNS_Missed]) * -6;
return p / (vOffsetVector.size() * 2);
p += (iHoldNoteScores[HNS_LetGo] + iHoldNoteScores[HNS_Missed]) * -6.f;
return p / static_cast<float>(vOffsetVector.size() * 2);
}

float HighScore::RescoreToDPJudge(int x) {
Expand Down
2 changes: 2 additions & 0 deletions src/HighScore.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ struct HighScore
float ConvertDpToWife();
float GetPercentDP() const;
float GetWifeScore() const;
float GetSSRNormPercent() const;
float GetMusicRate() const;
float GetJudgeScale() const;
bool GetEtternaValid() const;
Expand Down Expand Up @@ -80,6 +81,7 @@ struct HighScore
void SetScore( unsigned int iScore );
void SetPercentDP( float f );
void SetWifeScore(float f);
void SetSSRNormPercent(float f);
void SetMusicRate(float f);
void SetJudgeScale(float f);
void SetEtternaValid(bool b);
Expand Down
4 changes: 2 additions & 2 deletions src/PlayerStageStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ float PlayerStageStats::GetPercentDancePoints() const {
float PlayerStageStats::GetWifeScore() const {
return m_fWifeScore;
}
vector<float> PlayerStageStats::CalcSSR() const {
vector<float> PlayerStageStats::CalcSSR(float ssrpercent ) const {
auto nd = GAMESTATE->m_pCurSteps[m_player_number]->GetNoteData();
TimingData* td = GAMESTATE->m_pCurSteps[m_player_number]->GetTimingData();
float musicrate = GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate;
Expand All @@ -323,7 +323,7 @@ vector<float> PlayerStageStats::CalcSSR() const {
for (size_t i = 0; i < nerv.size(); ++i)
etaner[i] = etar[nerv[i]];

return MinaSDCalc(nd, etaner, musicrate, m_fWifeScore, 1.f, td->HasWarps());
return MinaSDCalc(nd, etaner, musicrate, ssrpercent, 1.f, td->HasWarps());
}
float PlayerStageStats::GetTimingScale() const {
return m_fTimingScale;
Expand Down
2 changes: 1 addition & 1 deletion src/PlayerStageStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class PlayerStageStats
static RString FormatPercentScore( float fPercentScore );
// Calculate the difficulty rating for a specific score obtained by a player - Mina
Grade GetWifeGrade();
vector<float> CalcSSR() const;
vector<float> CalcSSR(float ssrpercent) const;
float GetPercentDancePoints() const;
float GetWifeScore() const;
float GetTimingScale() const;
Expand Down
6 changes: 3 additions & 3 deletions src/Profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2216,9 +2216,9 @@ void Profile::RecalculateSSRs(bool OnlyOld) {

vector<float> etaner;
for (size_t i = 0; i < hsv.size(); i++) {
float wifescore = hsv[i].GetWifeScore();
float ssrpercent = hsv[i].GetSSRNormPercent();
float musicrate = hsv[i].GetMusicRate();
if (wifescore <= 0.f || hsv[i].GetGrade() == Grade_Failed)
if (ssrpercent <= 0.f || hsv[i].GetGrade() == Grade_Failed)
FOREACH_ENUM(Skillset, ss)
hsv[i].SetSkillsetSSR(ss, 0.f);
else {
Expand All @@ -2236,7 +2236,7 @@ void Profile::RecalculateSSRs(bool OnlyOld) {
etaner.emplace_back(td->GetElapsedTimeFromBeatNoOffset(NoteRowToBeat(nerv[i])));
}

vector<float> recalcSSR = MinaSDCalc(nd, etaner, musicrate, wifescore, 1.f, false);
vector<float> recalcSSR = MinaSDCalc(nd, etaner, musicrate, ssrpercent, 1.f, false);
FOREACH_ENUM(Skillset, ss)
hsv[i].SetSkillsetSSR(ss, recalcSSR[ss]);
hsv[i].SetSSRCalcVersion(GetCalcVersion());
Expand Down
14 changes: 10 additions & 4 deletions src/StageStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,21 @@ static HighScore FillInHighScore( const PlayerStageStats &pss, const PlayerState
HighScore hs;
hs.SetName( sRankingToFillInMarker );

hs.SetOffsetVector(pss.GetOffsetVector());
hs.SetNoteRowVector(pss.GetNoteRowVector());

auto chartKey = GAMESTATE->m_pCurSteps[ps.m_PlayerNumber]->GetChartKey();
hs.SetHistoricChartKey(chartKey);
hs.SetGrade( pss.GetGrade() );
hs.SetScore( pss.m_iScore );
hs.SetPercentDP( pss.GetPercentDancePoints() );
hs.SetWifeScore( pss.GetWifeScore());


if(pss.GetGrade() == Grade_Failed)
hs.SetSSRNormPercent(0.f);
else
hs.SetSSRNormPercent( hs.RescoreToWifeJudge(4));

// should prolly be its own fun - mina
hs.SetEtternaValid(true);
if (pss.GetGrade() == Grade_Failed || pss.m_fWifeScore < 0.1f || GAMESTATE->m_pCurSteps[ps.m_PlayerNumber]->m_StepsType != StepsType_dance_single)
Expand All @@ -154,7 +162,7 @@ static HighScore FillInHighScore( const PlayerStageStats &pss, const PlayerState
hs.SetEtternaValid(false);

if (hs.GetEtternaValid()) {
vector<float> dakine = pss.CalcSSR();
vector<float> dakine = pss.CalcSSR(hs.GetSSRNormPercent());
FOREACH_ENUM(Skillset, ss)
hs.SetSkillsetSSR(ss, dakine[ss]);
} else {
Expand All @@ -164,8 +172,6 @@ static HighScore FillInHighScore( const PlayerStageStats &pss, const PlayerState

hs.SetMusicRate( GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate);
hs.SetJudgeScale( pss.GetTimingScale());
hs.SetOffsetVector( pss.GetOffsetVector());
hs.SetNoteRowVector( pss.GetNoteRowVector());
hs.SetAliveSeconds( pss.m_fAliveSeconds );
hs.SetMaxCombo( pss.GetMaxCombo().m_cnt );
hs.SetStageAward( pss.m_StageAward );
Expand Down

0 comments on commit 770dd77

Please sign in to comment.