Skip to content

Commit

Permalink
training: reset random playback on stop, move random seed
Browse files Browse the repository at this point in the history
  • Loading branch information
blueminder committed Mar 25, 2024
1 parent c3cf311 commit 60eb568
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions core/dojo/DojoSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1794,7 +1794,6 @@ u16 DojoSession::ApplyOfflineInputs(PlainJoystickState* pjs, u16 buttons, u32 po
if (rnd_playback_loop)
{
auto it = recorded_slots.cbegin();
srand(time(0));
int rnd = rand() % recorded_slots.size();
std::advance(it, rnd);
current_record_slot = *it;
Expand Down Expand Up @@ -1931,6 +1930,7 @@ void DojoSession::TogglePlayback(int slot, bool hide_slot = false)
{
if (dojo.trigger_playback)
{
dojo.rnd_playback_loop = false;
dojo.trigger_playback = false;
if (hide_slot)
NoticeStream << "Stop Loop";
Expand Down Expand Up @@ -1966,19 +1966,26 @@ void DojoSession::ToggleRandomPlayback()
gui_display_notification("No Input Slots Recorded", 2000);
return;
}

srand(time(0));
if (rnd_playback_loop)
{
rnd_playback_loop = false;
if (!playing_input)
}
else
{
if (playback_loop)
rnd_playback_loop = true;
}

if (!playing_input && !playback_loop)
{
auto it = recorded_slots.cbegin();
srand(time(0));
int rnd = rand() % recorded_slots.size();
std::advance(it, rnd);
current_record_slot = *it;
}
if (playback_loop)
rnd_playback_loop = true;

dojo.TogglePlayback(current_record_slot, config::HideRandomInputSlot.get());
}

Expand Down

0 comments on commit 60eb568

Please sign in to comment.