Skip to content

Commit

Permalink
When chord cohesion is disabled decrease the number of points a note …
Browse files Browse the repository at this point in the history
…is worth based on the number of notes in the row.
  • Loading branch information
xwidghet committed Mar 16, 2017
1 parent f5d6712 commit 5759c88
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 12 deletions.
45 changes: 42 additions & 3 deletions src/NoteData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ void NoteData::SetNumTracks( int iNewNumTracks )
ASSERT( iNewNumTracks > 0 );

m_TapNotes.resize( iNewNumTracks );
CalcNumTracksLCD();
}

bool NoteData::IsComposite() const
Expand Down Expand Up @@ -181,9 +182,7 @@ int NoteData::WifeTotalScoreCalc(TimingData *td, int iStartIndex, int iEndIndex)
TapNote tn = GetTapNote(t, r);
if (tn.type != TapNoteType_Empty && tn.type != TapNoteType_Mine && tn.type != TapNoteType_Fake && td->IsJudgableAtRow(r)) {
taps++;

if( !GAMESTATE->CountNotesSeparately() )
break;
break;
}
}
}
Expand Down Expand Up @@ -956,6 +955,46 @@ int NoteData::GetNumMinefields( int iStartIndex, int iEndIndex ) const
}
*/

// This is a fast but inaccurate LCD calculator.
// Used for generating accurate DP scores when
// chord cohesion is disabled.
void NoteData::CalcNumTracksLCD()
{
int numTracks = this->GetNumTracks();
vector<int> nums;
int lcd = 1;

for (int i = 1; i < numTracks + 1; i++)
{
lcd *= i;
nums.push_back(i);
}

bool stillValid = true;
while(stillValid)
{
int tmpLCD = lcd / 2;
for (int i = 0; i < numTracks; i++)
{
if (tmpLCD % nums[i])
{
stillValid = false;
break;
}
}

if(stillValid)
lcd = tmpLCD;
}

m_numTracksLCD = lcd;
}

int NoteData::GetNumTracksLCD() const
{
return m_numTracksLCD;
}

// -1 for iOriginalTracksToTakeFrom means no track
void NoteData::LoadTransformed( const NoteData& in, int iNewNumTracks, const int iOriginalTrackToTakeFrom[] )
{
Expand Down
8 changes: 5 additions & 3 deletions src/NoteData.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ class NoteData
// There's no point in inserting empty notes into the map.
// Any blank space in the map is defined to be empty.
vector<TrackMap> m_TapNotes;
int m_numTracksLCD;

void CalcNumTracksLCD();

/**
* @brief Determine whether this note is for Player 1 or Player 2.
* @param track the track/column the note is in.
Expand Down Expand Up @@ -165,14 +168,11 @@ class NoteData
void Init();

// Mina stuf

void LogNonEmptyRows();
int WifeTotalScoreCalc(TimingData *td, int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW);
vector<int>& GetNonEmptyRowVector() { return NonEmptyRowVector; };
vector<NoteInfo> SerializeNoteData(const vector<float>& etaner);



int GetNumTracks() const { return m_TapNotes.size(); }
void SetNumTracks( int iNewNumTracks );
bool IsComposite() const;
Expand Down Expand Up @@ -375,6 +375,8 @@ class NoteData
pair<int, int> GetNumFakesTwoPlayer(int startRow = 0,
int endRow = MAX_NOTE_ROW) const;

int GetNumTracksLCD() const;

// Transformations
void LoadTransformed(const NoteData& original,
int iNewNumTracks,
Expand Down
20 changes: 17 additions & 3 deletions src/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3177,12 +3177,26 @@ void Player::SetJudgment( int iRow, int iTrack, const TapNote &tn, TapNoteScore

if (m_pPlayerStageStats) {
// Ms scoring implementation - Mina
float scoreWeight = 1;
if ( GAMESTATE->CountNotesSeparately() )
{
int notes = 0;

for (int i = 0; i < m_NoteData.GetNumTracks(); i++)
{
if (m_NoteData.GetTapNote(i, iRow).IsNote())
notes++;
}

scoreWeight /= notes;
}

if (tns == TNS_Miss)
curwifescore -= 8;
curwifescore -= 8 * scoreWeight;
else
curwifescore += wife2(tn.result.fTapNoteOffset, m_fTimingWindowScale);
curwifescore += wife2(tn.result.fTapNoteOffset, m_fTimingWindowScale) * scoreWeight;

maxwifescore += 2;
maxwifescore += 2 * scoreWeight;
msg.SetParam("WifePercent", 100 * curwifescore / maxwifescore);
msg.SetParam("WifeDifferential", curwifescore - maxwifescore * m_pPlayerState->playertargetgoal);
msg.SetParam("TotalPercent", 100 * curwifescore / totalwifescore);
Expand Down
17 changes: 14 additions & 3 deletions src/ScoreKeeperNormal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,19 @@ void ScoreKeeperNormal::HandleHoldCheckpointScore( const NoteData &nd, int iRow,
void ScoreKeeperNormal::HandleTapNoteScoreInternal( TapNoteScore tns, TapNoteScore maximum, int row )
{
// Update dance points.
if( !m_pPlayerStageStats->m_bFailed )
m_pPlayerStageStats->m_iActualDancePoints += TapNoteScoreToDancePoints( tns );
if ( !m_pPlayerStageStats->m_bFailed )
{
const NoteData* noteData = GAMESTATE->m_pCurSteps[m_pPlayerState->m_PlayerNumber]->GetNoteDataPointer();
int notes = 0;

for (int i = 0; i < noteData->GetNumTracks(); i++)
{
if (noteData->GetTapNote(i, row).IsNote())
notes++;
}

m_pPlayerStageStats->m_iActualDancePoints += (TapNoteScoreToDancePoints(tns)*noteData->GetNumTracksLCD())/notes;
}

// update judged row totals. Respect Combo segments here.
TimingData &td = *GAMESTATE->m_pCurSteps[m_pPlayerState->m_PlayerNumber]->GetTimingData();
Expand Down Expand Up @@ -657,7 +668,7 @@ int ScoreKeeperNormal::GetPossibleDancePoints( NoteData* nd, const TimingData* t
int ret = 0;

if ( GAMESTATE->CountNotesSeparately() )
ret += int(radars[RadarCategory_Notes]) * TapNoteScoreToDancePoints(TNS_W1, false);
ret += int(radars[RadarCategory_TapsAndHolds]) * TapNoteScoreToDancePoints(TNS_W1, false) * nd->GetNumTracksLCD();
else
ret += int(radars[RadarCategory_TapsAndHolds]) * TapNoteScoreToDancePoints(TNS_W1, false);

Expand Down
7 changes: 7 additions & 0 deletions src/Steps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,13 @@ NoteData Steps::GetNoteData() const
return tmp;
}

const NoteData* Steps::GetNoteDataPointer() const
{
Decompress(false);

return &*m_pNoteData;
}

void Steps::SetSMNoteData( const RString &notes_comp_ )
{
m_pNoteData->Init();
Expand Down
1 change: 1 addition & 0 deletions src/Steps.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class Steps

unsigned GetHash() const;
void GetNoteData( NoteData& noteDataOut, bool isGameplay ) const;
const NoteData* GetNoteDataPointer() const;
NoteData GetNoteData() const;
void SetNoteData( const NoteData& noteDataNew );
void SetSMNoteData( const RString &notes_comp );
Expand Down

0 comments on commit 5759c88

Please sign in to comment.