Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
b76d4cb
AutoStory: build the start/end select databases with one shared helper
dayfine Oct 25, 2026
198b207
AutoStory: compute start/end story indices with one shared function, …
dayfine Oct 25, 2026
17d4034
AutoStory: move AutoStoryStats to Pokemon/AutoStory
dayfine Oct 25, 2026
56e6da6
Merge origin/main into autostory/r1-select-db
dayfine Oct 30, 2026
935335a
Merge origin/autostory/r1-select-db into autostory/r2-story-index
dayfine Oct 30, 2026
df60654
Merge origin/autostory/r2-story-index into autostory/r3-shared-stats
dayfine Oct 30, 2026
4834685
Merge origin/main into autostory/r1-select-db
dayfine Oct 31, 2026
b3c3a90
Merge origin/autostory/r1-select-db into autostory/r2-story-index
dayfine Oct 31, 2026
676a03d
Merge origin/autostory/r2-story-index into autostory/r3-shared-stats
dayfine Oct 31, 2026
e3377aa
Merge origin/main into autostory/r1-select-db
dayfine Nov 1, 2026
86b2e84
Merge origin/autostory/r1-select-db into autostory/r2-story-index
dayfine Nov 1, 2026
5718316
Merge origin/autostory/r2-story-index into autostory/r3-shared-stats
dayfine Nov 1, 2026
5d23a56
AutoStory: test the shared select database with the helper that build…
dayfine Nov 1, 2026
883c048
Merge autostory/r1-select-db (5d23a5601: the select-database test) in…
dayfine Nov 1, 2026
7cc66e3
Merge autostory/r2-story-index (r1's select-database test moved) into…
dayfine Nov 1, 2026
1ea884b
AutoStory: shared start/end select database and story index
dayfine Nov 2, 2026
8698f8c
Merge origin/main into autostory/r1-select-db
dayfine Nov 2, 2026
0206e94
Merge origin/autostory/r1-select-db into autostory/r2-story-index
dayfine Nov 2, 2026
37d77f2
Merge origin/autostory/r2-story-index into autostory/r3-shared-stats
dayfine Nov 2, 2026
2b03556
AutoStory: segment descriptions use the shared index getters
dayfine Nov 2, 2026
057306f
AutoStory: note story_index's two-section assumption
dayfine Nov 2, 2026
101f574
AutoStory: describe sections as break points in story_index's NOTE
dayfine Nov 2, 2026
9ca64aa
Merge origin/autostory/story-select into autostory/r2-story-index
dayfine Nov 2, 2026
cee0b13
Merge autostory/r2-story-index into autostory/r3-shared-stats
dayfine Nov 2, 2026
6c447d7
Merge remote-tracking branch 'origin/main' into sync/story-export-r2
dayfine Nov 8, 2026
edc8e51
Merge branch 'sync/story-export-r2' into sync/story-export-r3
dayfine Nov 8, 2026
cc65994
Document shared stats alias and namespace endings
dayfine Nov 8, 2026
8b30e00
AutoStory: shared run report: log lines and story counts
dayfine Nov 10, 2026
08d50fc
AutoStory: one test entry point, output parameter last, std::format
dayfine Nov 10, 2026
1dba587
AutoStory: one test header per suite
dayfine Nov 10, 2026
a7457ef
Merge origin/main into autostory/r3-shared-stats
dayfine Nov 12, 2026
5a0b9d4
Merge origin/main into autostory/r3-shared-stats
dayfine Nov 12, 2026
fbb21f9
Merge origin/main into autostory/r3-shared-stats
dayfine Nov 13, 2026
3bfe35e
Merge remote-tracking branch 'origin/switch/system-keyboard' into aut…
dayfine Nov 13, 2026
1e49c4f
SV AutoStory: write the shared checkpoint log lines
dayfine Nov 13, 2026
1faac37
Merge remote-tracking branch 'origin/switch/system-keyboard' into aut…
dayfine Nov 13, 2026
1b5aaf0
SV AutoStory: keep the legacy file line counts (code health)
dayfine Nov 13, 2026
7cdde2d
AutoStory: review fixes for the shared log lines
dayfine Nov 13, 2026
7b7ef1d
AutoStory: nest the stats test case's Input and Expectation
dayfine Nov 13, 2026
9ad520e
AutoStory: [Checkpoint] lines take an optional display text
dayfine Nov 13, 2026
687023e
AutoStory: checkpoint_head -> checkpoint_prefix
dayfine Nov 13, 2026
2a33aa5
SV AutoStory: checkpoint attempt, reset and pass lines use StoryLog
dayfine Nov 13, 2026
8310a2a
AutoStory: move StoryRunCounts to the segment report, its first user
dayfine Nov 13, 2026
ea12373
AutoStory: story_short_line, the overlay form of a log line
dayfine Nov 14, 2026
752ad35
StoryLog: checkpoint lines only; reset line takes the attempt limit
dayfine Nov 14, 2026
2eca3ab
StoryLog tests: the case name sits outside its input
dayfine Nov 14, 2026
ec6e5e2
StoryLog: add_checkpoint_prefix replaces display_text
dayfine Nov 14, 2026
7ab7d55
Merge switch/system-keyboard into autostory/r3-shared-stats
dayfine Nov 14, 2026
6612f39
Merge switch/system-keyboard into autostory/r3-shared-stats
dayfine Nov 14, 2026
e81d3bb
AutoStory: StoryRunStats for the story engines (Runs, Checkpoints Pas…
dayfine Nov 15, 2026
740530b
AutoStory: SV's AutoStoryStats stays in SV; the shared header keeps S…
dayfine Nov 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "Common/Cpp/TestRunners/UnitTestDatabase.h"
#include "Common/Qt/QtThreadPool_Tests.h"
#include "Kernels/Kernels_Tests.h"
#include "Pokemon/AutoStory/Pokemon_AutoStorySelect_Tests.h"
#include "Pokemon/AutoStory/Pokemon_AutoStory_Tests.h"
#include "CommonFramework/AudioPipeline/AudioInfo_Tests.h"
#include "CommonFramework/AudioPipeline/Tools/ChannelMixer.h"
#include "CommonFramework/AudioPipeline/SinkPipeline_Tests.h"
Expand Down Expand Up @@ -76,7 +76,7 @@ UnitTestDatabase make_UNIT_TESTS_ALL(){
add_tests_LabControl(ret);
OCR::add_tests(ret);
Kernels::add_tests(ret);
Pokemon::add_tests_AutoStorySelect(ret);
Pokemon::add_tests_AutoStory(ret);
NintendoSwitch::add_tests_CheckOnlineDetector(ret);
NintendoSwitch::add_tests_FailedToConnectDetector(ret);
NintendoSwitch::add_tests_SystemKeyboardDetector(ret);
Expand Down
38 changes: 38 additions & 0 deletions SerialPrograms/Source/Pokemon/AutoStory/Pokemon_AutoStoryStats.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* AutoStory Stats
*
* From: https://github.com/PokemonAutomation/
*
*/

#ifndef PokemonAutomation_Pokemon_AutoStoryStats_H
#define PokemonAutomation_Pokemon_AutoStoryStats_H

#include <atomic>
#include <cstdint>
#include "CommonFramework/ProgramStats/StatsTracking.h"

namespace PokemonAutomation{
namespace Pokemon{


// The stats of a story engine's AutoStory: program runs, checkpoints passed
// and game resets to a checkpoint's save.
struct StoryRunStats : public StatsTracker{
StoryRunStats()
: m_runs(m_stats["Runs"])
, m_checkpoints_passed(m_stats["Checkpoints Passed"])
, m_resets(m_stats["Resets"])
{
m_display_order.emplace_back("Runs");
m_display_order.emplace_back("Checkpoints Passed");
m_display_order.emplace_back("Resets");
}
std::atomic<uint64_t>& m_runs;
std::atomic<uint64_t>& m_checkpoints_passed;
std::atomic<uint64_t>& m_resets;
};


} // namespace Pokemon
} // namespace PokemonAutomation
#endif
32 changes: 32 additions & 0 deletions SerialPrograms/Source/Pokemon/AutoStory/Pokemon_AutoStory_Tests.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* AutoStory Tests
*
* From: https://github.com/PokemonAutomation/
*
* The unit tests of the pieces every AutoStory program shares, story
* engine or not. add_tests_AutoStory() is the one entry point the unit
* test runner calls; a new shared AutoStory suite registers there.
*
*/

#ifndef PokemonAutomation_Pokemon_AutoStory_Tests_H
#define PokemonAutomation_Pokemon_AutoStory_Tests_H

#include "Common/Cpp/TestRunners/UnitTestDatabase.h"
#include "Pokemon_AutoStorySelect_Tests.h"
#include "Pokemon_StoryLog_Tests.h"

namespace PokemonAutomation{
namespace Pokemon{


// Registers every shared AutoStory suite, for the unit test runner.
inline void add_tests_AutoStory(UnitTestDatabase& database){
add_tests_AutoStorySelect(database);
add_tests_StoryLog(database);
}



} // namespace Pokemon
} // namespace PokemonAutomation
#endif
85 changes: 85 additions & 0 deletions SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryLog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/* Story Log
*
* From: https://github.com/PokemonAutomation/
*
*/

#include <format>
#include "Pokemon_StoryLog.h"

namespace PokemonAutomation{
namespace Pokemon{


namespace{

std::string resets_text(size_t attempt){
if (attempt <= 1){
return "one-shot";
}
return std::format("{} reset{}", attempt - 1, attempt == 2 ? "" : "s");
}

// "[Checkpoint] 00.04", or the game's own checkpoint text unchanged.
std::string checkpoint_prefix(std::string_view checkpoint, bool add_checkpoint_prefix){
if (!add_checkpoint_prefix){
return std::string(checkpoint);
}
return std::format("[Checkpoint] {}", checkpoint);
}

} // namespace


std::string checkpoint_start_line(
std::string_view checkpoint, std::optional<size_t> events, bool add_checkpoint_prefix
){
const std::string prefix = checkpoint_prefix(checkpoint, add_checkpoint_prefix);
if (!events){
return std::format("{}: start", prefix);
}
return std::format("{}: start, {} events", prefix, *events);
}

std::string checkpoint_attempt_line(
std::string_view checkpoint, size_t attempt, std::optional<size_t> attempts, bool add_checkpoint_prefix
){
const std::string prefix = checkpoint_prefix(checkpoint, add_checkpoint_prefix);
if (!attempts){
return std::format("{}: attempt {}", prefix, attempt);
}
return std::format("{}: attempt {}/{}", prefix, attempt, *attempts);
}

std::string checkpoint_pass_line(std::string_view checkpoint, size_t attempt, bool add_checkpoint_prefix){
return std::format(
"{}: passed on attempt {} ({})",
checkpoint_prefix(checkpoint, add_checkpoint_prefix), attempt, resets_text(attempt)
);
}

std::string checkpoint_reset_line(
std::string_view checkpoint, size_t next_attempt, std::optional<size_t> attempts, bool add_checkpoint_prefix
){
const std::string prefix = checkpoint_prefix(checkpoint, add_checkpoint_prefix);
if (!attempts){
return std::format("{}: failed, resetting for attempt {}", prefix, next_attempt);
}
return std::format("{}: failed, resetting for attempt {}/{}", prefix, next_attempt, *attempts);
}

std::string story_short_line(std::string_view line){
if (!line.starts_with('[')){
return std::string(line);
}
const size_t end = line.find("] ");
if (end == std::string_view::npos){
return std::string(line);
}
return std::string(line.substr(end + 2));
}



} // namespace Pokemon
} // namespace PokemonAutomation
85 changes: 85 additions & 0 deletions SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryLog.h
Comment thread
dayfine marked this conversation as resolved.
Resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/* Story Log
*
* From: https://github.com/PokemonAutomation/
*
* A story is split at three levels: a segment is a chapter of
* checkpoints, a checkpoint is the stretch between two saves and the unit
* a run retries, and an event is one step inside a checkpoint. This file
* writes the checkpoint lines: start, attempt, reset and pass, in one
* format for every game, so the program developer and user find each
* checkpoint's attempts the same way in any game's log. Nothing here runs
* a story.
*
*/

#ifndef PokemonAutomation_Pokemon_StoryLog_H
#define PokemonAutomation_Pokemon_StoryLog_H

#include <cstddef>
#include <optional>
#include <string>
#include <string_view>

namespace PokemonAutomation{
namespace Pokemon{


// The lines below start with "[Checkpoint] " and then `checkpoint`. A game
// whose checkpoint text already says it is a checkpoint (SV's
// "Checkpoint:: 004 - 02 ...") passes that text as `checkpoint` and
// `add_checkpoint_prefix` false, and the line starts with the text alone:
// Checkpoint:: 004 - 02 ...: start

// A checkpoint starts; the story engine also says it has `events` events:
// [Checkpoint] 00.04: start
// [Checkpoint] 00.04: start, 3 events
std::string checkpoint_start_line(

Check failure on line 36 in SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryLog.h

View workflow job for this annotation

GitHub Actions / code-health

Code health

style: checkpoint_start_line: a defaulted bool parameter; use an enum class or an options struct (TotW #94)
std::string_view checkpoint,
std::optional<size_t> events = std::nullopt,
bool add_checkpoint_prefix = true
);

// An attempt at a checkpoint starts, counting from 1, out of the
// program's limit of `attempts` if it has one:
// [Checkpoint] 00.04: attempt 2
// [Checkpoint] 00.04: attempt 2/3
std::string checkpoint_attempt_line(

Check failure on line 46 in SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryLog.h

View workflow job for this annotation

GitHub Actions / code-health

Code health

style: checkpoint_attempt_line: a defaulted bool parameter; use an enum class or an options struct (TotW #94)
std::string_view checkpoint,
size_t attempt,
std::optional<size_t> attempts = std::nullopt,
bool add_checkpoint_prefix = true
);

// A checkpoint passed on attempt `attempt`, counting from 1; every attempt
// before it ended in a reset:
// [Checkpoint] 00.03: passed on attempt 1 (one-shot)
// [Checkpoint] 00.04: passed on attempt 3 (2 resets)
std::string checkpoint_pass_line(

Check failure on line 57 in SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryLog.h

View workflow job for this annotation

GitHub Actions / code-health

Code health

style: checkpoint_pass_line: a defaulted bool parameter; use an enum class or an options struct (TotW #94)
std::string_view checkpoint,
size_t attempt,
bool add_checkpoint_prefix = true
);

// An attempt failed and the game resets to the checkpoint's save for
// attempt `next_attempt`, out of the limit of `attempts` if it has one:
// [Checkpoint] 00.04: failed, resetting for attempt 2
// [Checkpoint] 00.04: failed, resetting for attempt 2/3
std::string checkpoint_reset_line(

Check failure on line 67 in SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryLog.h

View workflow job for this annotation

GitHub Actions / code-health

Code health

style: checkpoint_reset_line: a defaulted bool parameter; use an enum class or an options struct (TotW #94)
std::string_view checkpoint,
size_t next_attempt,
std::optional<size_t> attempts = std::nullopt,
bool add_checkpoint_prefix = true
);

// The full lines above go to the log. The video overlay, which wraps its
// lines, shows each one short, without its leading "[Tag] ":
// [Checkpoint] 12.03: start, 18 events -> 12.03: start, 18 events
// Any line with a leading "[Tag] " is shortened the same way. A line
// without a tag, like SV's checkpoint text, is returned unchanged.
std::string story_short_line(std::string_view line);



} // namespace Pokemon
} // namespace PokemonAutomation
#endif
Loading
Loading