Skip to content

Commit

Permalink
Merge branch 'PokemonAutomation:main' into flyingtrailfarmer
Browse files Browse the repository at this point in the history
  • Loading branch information
NympheaR authored Dec 28, 2023
2 parents 1f1744e + c15a919 commit e293f27
Show file tree
Hide file tree
Showing 33 changed files with 1,126 additions and 46 deletions.
16 changes: 12 additions & 4 deletions SerialPrograms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1378,6 +1378,10 @@ file(GLOB MAIN_SOURCES
Source/PokemonSV/Options/PokemonSV_SandwichIngredientsTable.h
Source/PokemonSV/Options/PokemonSV_SandwichMakerOption.cpp
Source/PokemonSV/Options/PokemonSV_SandwichMakerOption.h
Source/PokemonSV/Options/PokemonSV_SinglesAIOption.cpp
Source/PokemonSV/Options/PokemonSV_SinglesAIOption.h
Source/PokemonSV/Options/PokemonSV_SinglesMoveTable.cpp
Source/PokemonSV/Options/PokemonSV_SinglesMoveTable.h
Source/PokemonSV/Options/PokemonSV_TeraAIOption.cpp
Source/PokemonSV/Options/PokemonSV_TeraAIOption.h
Source/PokemonSV/Options/PokemonSV_TeraCatchOnWinOption.cpp
Expand All @@ -1394,6 +1398,12 @@ file(GLOB MAIN_SOURCES
Source/PokemonSV/PokemonSV_Panels.h
Source/PokemonSV/PokemonSV_Settings.cpp
Source/PokemonSV/PokemonSV_Settings.h
Source/PokemonSV/Programs/Battles/PokemonSV_BasicCatcher.cpp
Source/PokemonSV/Programs/Battles/PokemonSV_BasicCatcher.h
Source/PokemonSV/Programs/Battles/PokemonSV_Battles.cpp
Source/PokemonSV/Programs/Battles/PokemonSV_Battles.h
Source/PokemonSV/Programs/Battles/PokemonSV_SinglesBattler.cpp
Source/PokemonSV/Programs/Battles/PokemonSV_SinglesBattler.h
Source/PokemonSV/Programs/Boxes/PokemonSV_BoxAttach.cpp
Source/PokemonSV/Programs/Boxes/PokemonSV_BoxAttach.h
Source/PokemonSV/Programs/Boxes/PokemonSV_BoxRelease.cpp
Expand Down Expand Up @@ -1426,6 +1436,8 @@ file(GLOB MAIN_SOURCES
Source/PokemonSV/Programs/Farming/PokemonSV_LPFarmer.h
Source/PokemonSV/Programs/Farming/PokemonSV_TournamentFarmer.cpp
Source/PokemonSV/Programs/Farming/PokemonSV_TournamentFarmer.h
Source/PokemonSV/Programs/Farming/PokemonSV_TournamentFarmer2.cpp
Source/PokemonSV/Programs/Farming/PokemonSV_TournamentFarmer2.h
Source/PokemonSV/Programs/FastCodeEntry/PokemonSV_ClipboardFastCodeEntry.cpp
Source/PokemonSV/Programs/FastCodeEntry/PokemonSV_ClipboardFastCodeEntry.h
Source/PokemonSV/Programs/FastCodeEntry/PokemonSV_CodeEntry.cpp
Expand Down Expand Up @@ -1454,10 +1466,6 @@ file(GLOB MAIN_SOURCES
Source/PokemonSV/Programs/Glitches/PokemonSV_RideCloner-1.0.1.h
Source/PokemonSV/Programs/PokemonSV_AreaZero.cpp
Source/PokemonSV/Programs/PokemonSV_AreaZero.h
Source/PokemonSV/Programs/PokemonSV_BasicCatcher.cpp
Source/PokemonSV/Programs/PokemonSV_BasicCatcher.h
Source/PokemonSV/Programs/PokemonSV_Battles.cpp
Source/PokemonSV/Programs/PokemonSV_Battles.h
Source/PokemonSV/Programs/PokemonSV_ConnectToInternet.cpp
Source/PokemonSV/Programs/PokemonSV_ConnectToInternet.h
Source/PokemonSV/Programs/PokemonSV_GameEntry.cpp
Expand Down
16 changes: 12 additions & 4 deletions SerialPrograms/SerialPrograms.pro
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,8 @@ SOURCES += \
Source/PokemonSV/Options/PokemonSV_SandwichIngredientsOption.cpp \
Source/PokemonSV/Options/PokemonSV_SandwichIngredientsTable.cpp \
Source/PokemonSV/Options/PokemonSV_SandwichMakerOption.cpp \
Source/PokemonSV/Options/PokemonSV_SinglesAIOption.cpp \
Source/PokemonSV/Options/PokemonSV_SinglesMoveTable.cpp \
Source/PokemonSV/Options/PokemonSV_TeraAIOption.cpp \
Source/PokemonSV/Options/PokemonSV_TeraCatchOnWinOption.cpp \
Source/PokemonSV/Options/PokemonSV_TeraMoveTable.cpp \
Expand All @@ -696,6 +698,9 @@ SOURCES += \
Source/PokemonSV/Options/PokemonSV_TournamentPrizeTable.cpp \
Source/PokemonSV/PokemonSV_Panels.cpp \
Source/PokemonSV/PokemonSV_Settings.cpp \
Source/PokemonSV/Programs/Battles/PokemonSV_BasicCatcher.cpp \
Source/PokemonSV/Programs/Battles/PokemonSV_Battles.cpp \
Source/PokemonSV/Programs/Battles/PokemonSV_SinglesBattler.cpp \
Source/PokemonSV/Programs/Boxes/PokemonSV_BoxAttach.cpp \
Source/PokemonSV/Programs/Boxes/PokemonSV_BoxRelease.cpp \
Source/PokemonSV/Programs/Boxes/PokemonSV_BoxRoutines.cpp \
Expand All @@ -712,6 +717,7 @@ SOURCES += \
Source/PokemonSV/Programs/Farming/PokemonSV_GimmighoulRoamingFarmer.cpp \
Source/PokemonSV/Programs/Farming/PokemonSV_LPFarmer.cpp \
Source/PokemonSV/Programs/Farming/PokemonSV_TournamentFarmer.cpp \
Source/PokemonSV/Programs/Farming/PokemonSV_TournamentFarmer2.cpp \
Source/PokemonSV/Programs/FastCodeEntry/PokemonSV_ClipboardFastCodeEntry.cpp \
Source/PokemonSV/Programs/FastCodeEntry/PokemonSV_CodeEntry.cpp \
Source/PokemonSV/Programs/FastCodeEntry/PokemonSV_FastCodeEntry.cpp \
Expand All @@ -726,8 +732,6 @@ SOURCES += \
Source/PokemonSV/Programs/Glitches/PokemonSV_CloneItems-1.0.1.cpp \
Source/PokemonSV/Programs/Glitches/PokemonSV_RideCloner-1.0.1.cpp \
Source/PokemonSV/Programs/PokemonSV_AreaZero.cpp \
Source/PokemonSV/Programs/PokemonSV_BasicCatcher.cpp \
Source/PokemonSV/Programs/PokemonSV_Battles.cpp \
Source/PokemonSV/Programs/PokemonSV_ConnectToInternet.cpp \
Source/PokemonSV/Programs/PokemonSV_GameEntry.cpp \
Source/PokemonSV/Programs/PokemonSV_Navigation.cpp \
Expand Down Expand Up @@ -1741,6 +1745,8 @@ HEADERS += \
Source/PokemonSV/Options/PokemonSV_SandwichIngredientsOption.h \
Source/PokemonSV/Options/PokemonSV_SandwichIngredientsTable.h \
Source/PokemonSV/Options/PokemonSV_SandwichMakerOption.h \
Source/PokemonSV/Options/PokemonSV_SinglesAIOption.h \
Source/PokemonSV/Options/PokemonSV_SinglesMoveTable.h \
Source/PokemonSV/Options/PokemonSV_TeraAIOption.h \
Source/PokemonSV/Options/PokemonSV_TeraCatchOnWinOption.h \
Source/PokemonSV/Options/PokemonSV_TeraMoveTable.h \
Expand All @@ -1749,6 +1755,9 @@ HEADERS += \
Source/PokemonSV/Options/PokemonSV_TournamentPrizeTable.h \
Source/PokemonSV/PokemonSV_Panels.h \
Source/PokemonSV/PokemonSV_Settings.h \
Source/PokemonSV/Programs/Battles/PokemonSV_BasicCatcher.h \
Source/PokemonSV/Programs/Battles/PokemonSV_Battles.h \
Source/PokemonSV/Programs/Battles/PokemonSV_SinglesBattler.h \
Source/PokemonSV/Programs/Boxes/PokemonSV_BoxAttach.h \
Source/PokemonSV/Programs/Boxes/PokemonSV_BoxRelease.h \
Source/PokemonSV/Programs/Boxes/PokemonSV_BoxRoutines.h \
Expand All @@ -1765,6 +1774,7 @@ HEADERS += \
Source/PokemonSV/Programs/Farming/PokemonSV_GimmighoulRoamingFarmer.h \
Source/PokemonSV/Programs/Farming/PokemonSV_LPFarmer.h \
Source/PokemonSV/Programs/Farming/PokemonSV_TournamentFarmer.h \
Source/PokemonSV/Programs/Farming/PokemonSV_TournamentFarmer2.h \
Source/PokemonSV/Programs/FastCodeEntry/PokemonSV_ClipboardFastCodeEntry.h \
Source/PokemonSV/Programs/FastCodeEntry/PokemonSV_CodeEntry.h \
Source/PokemonSV/Programs/FastCodeEntry/PokemonSV_FastCodeEntry.h \
Expand All @@ -1779,8 +1789,6 @@ HEADERS += \
Source/PokemonSV/Programs/Glitches/PokemonSV_CloneItems-1.0.1.h \
Source/PokemonSV/Programs/Glitches/PokemonSV_RideCloner-1.0.1.h \
Source/PokemonSV/Programs/PokemonSV_AreaZero.h \
Source/PokemonSV/Programs/PokemonSV_BasicCatcher.h \
Source/PokemonSV/Programs/PokemonSV_Battles.h \
Source/PokemonSV/Programs/PokemonSV_ConnectToInternet.h \
Source/PokemonSV/Programs/PokemonSV_GameEntry.h \
Source/PokemonSV/Programs/PokemonSV_Navigation.h \
Expand Down
4 changes: 2 additions & 2 deletions SerialPrograms/Source/CommonFramework/Globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ namespace PokemonAutomation{

const bool IS_BETA_VERSION = true;
const int PROGRAM_VERSION_MAJOR = 0;
const int PROGRAM_VERSION_MINOR = 44;
const int PROGRAM_VERSION_PATCH = 2;
const int PROGRAM_VERSION_MINOR = 45;
const int PROGRAM_VERSION_PATCH = 1;

const std::string PROGRAM_VERSION_BASE =
"v" + std::to_string(PROGRAM_VERSION_MAJOR) +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
#include "PokemonLA/Programs/PokemonLA_GameEntry.h"
#include "PokemonSV/Programs/PokemonSV_GameEntry.h"
#include "PokemonSV/Programs/PokemonSV_Navigation.h"
#include "PokemonSV/Programs/PokemonSV_BasicCatcher.h"
#include "PokemonSV/Programs/Battles/PokemonSV_BasicCatcher.h"
#include "PokemonSwSh/Inference/PokemonSwSh_YCommDetector.h"
#include "PokemonSV/Inference/Tera/PokemonSV_TeraCardDetector.h"
#include "PokemonSV/Inference/PokemonSV_PokemonSummaryReader.h"
Expand Down Expand Up @@ -92,7 +92,7 @@
#include "PokemonSV/Programs/ShinyHunting/PokemonSV_AreaZeroPlatform.h"
#include "PokemonSV/Inference/PokemonSV_SweatBubbleDetector.h"
#include "PokemonSV/Programs/PokemonSV_AreaZero.h"
#include "PokemonSV/Programs/PokemonSV_Battles.h"
#include "PokemonSV/Programs/Battles/PokemonSV_Battles.h"
#include "PokemonSV/Programs/PokemonSV_SaveGame.h"
#include "PokemonSV/Inference/Battles/PokemonSV_NormalBattleMenus.h"
#include "PokemonSV/Inference/Battles/PokemonSV_TeraBattleMenus.h"
Expand All @@ -113,6 +113,7 @@
#include "NintendoSwitch/Programs/NintendoSwitch_GameEntry.h"
#include "PokemonSwSh/Inference/PokemonSwSh_ReceivePokemonDetector.h"
#include "PokemonSV/Inference/PokemonSV_PokemonSummaryReader.h"
#include "PokemonSV/Programs/Battles/PokemonSV_SinglesBattler.h"



Expand Down Expand Up @@ -195,6 +196,7 @@ TestProgram::TestProgram()
PA_ADD_OPTION(STATIC_TEXT);
PA_ADD_OPTION(SELECT);
PA_ADD_OPTION(PLAYER_LIST);
PA_ADD_OPTION(battle_AI);
PA_ADD_OPTION(NOTIFICATIONS);
BUTTON0.add_listener(*this);
BUTTON1.add_listener(*this);
Expand Down Expand Up @@ -228,8 +230,8 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
using namespace Pokemon;
// using namespace PokemonSwSh;
// using namespace PokemonBDSP;
using namespace PokemonLA;
// using namespace PokemonSV;
// using namespace PokemonLA;
using namespace PokemonSV;

[[maybe_unused]] Logger& logger = env.logger();
[[maybe_unused]] ConsoleHandle& console = env.consoles[0];
Expand All @@ -240,12 +242,31 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
VideoOverlaySet overlays(overlay);


// SinglesAIOption battle_AI;
run_singles_battle(env, console, context, battle_AI, false);


#if 0
run_pokemon(
console, context,
{
{SinglesMoveType::Move1, false},
{SinglesMoveType::Move2, false},
{SinglesMoveType::Move4, true},
{SinglesMoveType::Run, false},
}
);
#endif



#if 0
auto snapshot = console.video().snapshot();

PokemonSummaryDetector detector;
detector.make_overlays(overlays);
cout << detector.detect(snapshot) << endl;

#endif


#if 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "PokemonSwSh/Options/EncounterFilter/PokemonSwSh_EncounterFilterOption.h"
#include "PokemonSV/Options/PokemonSV_PlayerList.h"
#include "CommonFramework/Tools/StatsTracking.h"
#include "PokemonSV/Options/PokemonSV_SinglesAIOption.h"

namespace PokemonAutomation{
namespace NintendoSwitch{
Expand Down Expand Up @@ -70,6 +71,8 @@ class TestProgram : public MultiSwitchProgramInstance, public ButtonListener{

PokemonSV::PlayerListTable PLAYER_LIST;

PokemonSV::SinglesAIOption battle_AI;

EventNotificationOption NOTIFICATION_TEST;
EventNotificationsOption NOTIFICATIONS;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ bool NormalBattleMenuDetector::move_to_slot(ConsoleHandle& console, BotBaseConte
int8_t current_slot = detect_slot(screen);
if (current_slot < 0 || current_slot > 3){
console.log("NormalBattleMenuDetector::move_to_slot(): Unable to detect slot.", COLOR_RED);
return false;
context.wait_for(std::chrono::milliseconds(500));
continue;
// static int c = 0;
// screen->save("bad-" + std::to_string(c++) + ".png"); // REMOVE
// return false;
}
if (attempts > 10){
console.log("NormalBattleMenuDetector::move_to_slot(): Failed to move slot after 10 attempts.", COLOR_RED);
Expand All @@ -75,8 +79,11 @@ bool NormalBattleMenuDetector::move_to_slot(ConsoleHandle& console, BotBaseConte

uint8_t diff = (4 + slot - (uint8_t)current_slot) % 4;
switch (diff){
case 0:
case 0:{
// static int c = 0;
// screen->save("good-" + std::to_string(c++) + ".png"); // REMOVE
return true;
}
case 1:
pbf_press_dpad(context, DPAD_DOWN, 20, 30);
continue;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/* Singles AI Option
*
* From: https://github.com/PokemonAutomation/Arduino-Source
*
*/

#include "Common/Cpp/Containers/FixedLimitVector.tpp"
#include "Pokemon/Pokemon_Strings.h"
#include "PokemonSV_SinglesAIOption.h"

namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonSV{

using namespace Pokemon;



SinglesAIOption::SinglesAIOption()
: GroupOption(
"Battle AI",
LockMode::UNLOCK_WHILE_RUNNING,
false, true
)
, description(
"Move Tables: Run these sequence of moves for the corresponding " + STRING_POKEMON + " in your party. "
"When the end of the table is reached, the last entry will be repeated "
"until the battle is won or the " + STRING_POKEMON +" faints. "
"If your " + STRING_POKEMON + " faints, the program will switch to the "
"next available " + STRING_POKEMON + " and run its table. "
"Changes to these tables take effect the next the " + STRING_POKEMON + " is sent out."
)
, MOVE_TABLES(6)
{
MOVE_TABLES.emplace_back("<b>1st " + STRING_POKEMON + " Move Table:</b>");
MOVE_TABLES.emplace_back("<b>2nd " + STRING_POKEMON + " Move Table:</b>");
MOVE_TABLES.emplace_back("<b>3rd " + STRING_POKEMON + " Move Table:</b>");
MOVE_TABLES.emplace_back("<b>4th " + STRING_POKEMON + " Move Table:</b>");
MOVE_TABLES.emplace_back("<b>5th " + STRING_POKEMON + " Move Table:</b>");
MOVE_TABLES.emplace_back("<b>6th " + STRING_POKEMON + " Move Table:</b>");

PA_ADD_STATIC(description);
size_t c = 0;
for (SinglesMoveTable& table : MOVE_TABLES){
add_option(table, "MOVE_TABLE" + std::to_string(++c));
}
}





}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* Singles AI Option
*
* From: https://github.com/PokemonAutomation/Arduino-Source
*
*/

#ifndef PokemonAutomation_PokemonSV_SinglesAIOption_H
#define PokemonAutomation_PokemonSV_SinglesAIOption_H

#include "Common/Cpp/Containers/FixedLimitVector.h"
#include "Common/Cpp/Options/StaticTextOption.h"
//#include "Common/Cpp/Options/BooleanCheckBoxOption.h"
#include "Common/Cpp/Options/GroupOption.h"
#include "PokemonSV_SinglesMoveTable.h"

namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonSV{



class SinglesAIOption : public GroupOption{
public:
SinglesAIOption();

public:
StaticTextOption description;
FixedLimitVector<SinglesMoveTable> MOVE_TABLES;

};




}
}
}
#endif
Loading

0 comments on commit e293f27

Please sign in to comment.