Skip to content

Commit

Permalink
add concommand to display league player stats
Browse files Browse the repository at this point in the history
  • Loading branch information
fallahn committed Sep 26, 2023
1 parent 52dfe13 commit 9509d09
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 50 deletions.
4 changes: 2 additions & 2 deletions samples/golf/buildnumber.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#ifndef BUILD_NUMBER_H_
#define BUILD_NUMBER_H_

#define BUILDNUMBER 1899
#define BUILDNUMBER_STR "1899"
#define BUILDNUMBER 1901
#define BUILDNUMBER_STR "1901"

#endif /* BUILD_NUMBER_H_ */
107 changes: 59 additions & 48 deletions samples/golf/src/golf/LeagueState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ namespace
std::vector<ScoreSet> scoreSet;
#endif
std::size_t courseIndex = 0;

bool showStats = false;
}

LeagueState::LeagueState(cro::StateStack& ss, cro::State::Context ctx, SharedStateData& sd)
Expand All @@ -96,55 +98,64 @@ LeagueState::LeagueState(cro::StateStack& ss, cro::State::Context ctx, SharedSta
{
ctx.mainWindow.setMouseCaptured(false);
#ifdef USE_GNS
scoreSet = readGameScores();

//registerWindow([&]()
// {
// if (ImGui::Begin("League"))
// {
// static League league;

// const auto& entries = league.getTable();
// for (const auto& e : entries)
// {
// ImGui::Text("Skill: %d - Curve: %d - Score: %d - Name: %d - Mistake Probability: %d - Quality: %3.3f",
// e.skill, e.curve, e.currentScore, e.nameIndex, e.outlier, e.quality * 100.f);
// }
// ImGui::Text("Iteration: %d", league.getCurrentIteration());
// ImGui::SameLine();
// ImGui::Text("Season: %d", league.getCurrentSeason());
// ImGui::SameLine();
// ImGui::Text("Score: %d", league.getCurrentScore());

// /*if (!scoreSet.empty())
// {
// if (ImGui::Button("Iterate"))
// {
// league.iterate(scoreSet[courseIndex].par, scoreSet[courseIndex].scores, scoreSet[courseIndex].scores.size());
// courseIndex = (courseIndex + 1) % scoreSet.size();
// }
// ImGui::SameLine();
// if (ImGui::Button("Reset"))
// {
// league.reset();
// }

// if (ImGui::Button("Run 10 Seasons"))
// {
// for (auto i = 0; i < 10; ++i)
// {
// for (auto j = 0; j < League::MaxIterations; ++j)
// {
// league.iterate(scoreSet[courseIndex].par, scoreSet[courseIndex].scores, scoreSet[courseIndex].scores.size());
// courseIndex = (courseIndex + 1) % scoreSet.size();
// }
// }
// }
// }*/
// }
// ImGui::End();
// });
//scoreSet = readGameScores();
#endif

registerCommand("show_league_stats", [](const std::string&)
{
showStats = !showStats;
});

registerWindow([&]()
{
if (showStats)
{
if (ImGui::Begin("League", &showStats))
{
static League league;

const auto& entries = league.getTable();
for (const auto& e : entries)
{
ImGui::Text("Skill: %d - Curve: %d - Score: %d - Name: %d - Mistake Probability: %d - Quality: %3.3f",
e.skill, e.curve, e.currentScore, e.nameIndex, e.outlier, e.quality * 100.f);
}
ImGui::Text("Iteration: %d", league.getCurrentIteration());
ImGui::SameLine();
ImGui::Text("Season: %d", league.getCurrentSeason());
ImGui::SameLine();
ImGui::Text("Score: %d", league.getCurrentScore());

/*if (!scoreSet.empty())
{
if (ImGui::Button("Iterate"))
{
league.iterate(scoreSet[courseIndex].par, scoreSet[courseIndex].scores, scoreSet[courseIndex].scores.size());
courseIndex = (courseIndex + 1) % scoreSet.size();
}
ImGui::SameLine();
if (ImGui::Button("Reset"))
{
league.reset();
}
if (ImGui::Button("Run 10 Seasons"))
{
for (auto i = 0; i < 10; ++i)
{
for (auto j = 0; j < League::MaxIterations; ++j)
{
league.iterate(scoreSet[courseIndex].par, scoreSet[courseIndex].scores, scoreSet[courseIndex].scores.size());
courseIndex = (courseIndex + 1) % scoreSet.size();
}
}
}
}*/
}
ImGui::End();
}
});

buildScene();
}

Expand Down

0 comments on commit 9509d09

Please sign in to comment.