Skip to content

Commit 618c205

Browse files
author
Gin
committed
add context files for coding agents
1 parent 5181a10 commit 618c205

File tree

2 files changed

+149
-0
lines changed

2 files changed

+149
-0
lines changed
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# Automation Program Patterns
2+
3+
## Basic Program Structure (for Single-Switch Programs)
4+
5+
### Required Files
6+
```
7+
GameName_ProgramName.h // Header with class declarations
8+
GameName_ProgramName.cpp // Implementation
9+
```
10+
Example game names: `PokemonLA`, `PokemonSwSh`, `PokemonSV`, `PokemonBDSP`
11+
12+
### Core Classes
13+
```cpp
14+
class ProgramName_Descriptor : public SingleSwitchProgramDescriptor
15+
class ProgramName : public SingleSwitchProgramInstance
16+
```
17+
18+
## Essential Includes
19+
20+
### Header (.h)
21+
```cpp
22+
#include "CommonFramework/Notifications/EventNotificationsTable.h"
23+
#include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h"
24+
```
25+
26+
### Implementation (.cpp)
27+
```cpp
28+
#include "CommonFramework/Exceptions/ProgramFinishedException.h"
29+
#include "CommonFramework/Notifications/ProgramNotifications.h"
30+
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
31+
```
32+
33+
## Example Program Options
34+
35+
### Common Option Types
36+
```cpp
37+
SimpleIntegerOption<uint16_t> NUM_BOXES(
38+
"<b>Number of Boxes:</b>",
39+
LockMode::LOCK_WHILE_RUNNING,
40+
5, 1, 30 // default, min, max
41+
);
42+
43+
BooleanCheckBoxOption ENABLE_FEATURE(
44+
"<b>Enable Feature:</b>",
45+
LockMode::LOCK_WHILE_RUNNING,
46+
true
47+
);
48+
```
49+
50+
### Register Options
51+
```cpp
52+
PA_ADD_OPTION(NUM_BOXES);
53+
PA_ADD_OPTION(ENABLE_FEATURE);
54+
```
55+
56+
## Notifications
57+
58+
### Declaration (in .h)
59+
```cpp
60+
EventNotificationOption NOTIFICATION_STATUS_UPDATE;
61+
EventNotificationsOption NOTIFICATIONS;
62+
```
63+
64+
### Initialization (in constructor)
65+
```cpp
66+
NOTIFICATION_STATUS_UPDATE("Status Update", true, false, std::chrono::seconds(3600))
67+
, NOTIFICATIONS({
68+
&NOTIFICATION_STATUS_UPDATE,
69+
&NOTIFICATION_PROGRAM_FINISH,
70+
&NOTIFICATION_ERROR_FATAL,
71+
})
72+
```
73+
74+
### Sending Notifications
75+
```cpp
76+
send_program_status_notification(env, NOTIFICATION_STATUS_UPDATE);
77+
send_program_finished_notification(env, NOTIFICATION_PROGRAM_FINISH);
78+
send_program_fatal_error_notification(env, NOTIFICATION_ERROR_FATAL, "Error message");
79+
```
80+
81+
## Error Handling
82+
83+
### Standard Pattern
84+
```cpp
85+
try{
86+
// Main program logic
87+
send_program_finished_notification(env, NOTIFICATION_PROGRAM_FINISH);
88+
}catch(ProgramFinishedException&){
89+
send_program_finished_notification(env, NOTIFICATION_PROGRAM_FINISH);
90+
throw;
91+
}catch(std::exception& e){
92+
send_program_fatal_error_notification(env, NOTIFICATION_ERROR_FATAL, e.what());
93+
throw;
94+
}
95+
```
96+
97+
## Controller Input
98+
99+
### Button Presses
100+
```cpp
101+
pbf_press_button(context, BUTTON_A, 10, 100); // button, hold_time, release_time
102+
pbf_press_dpad(context, DPAD_DOWN, 20, 50);
103+
context.wait_for_all_requests(); // wait for button to finish execution
104+
```
105+
106+
### Delays
107+
```cpp
108+
context.wait_for(std::chrono::milliseconds(1000));
109+
```
110+
111+
## Program Registration
112+
113+
### In GameName_Panels.cpp
114+
```cpp
115+
// Add include
116+
#include "Programs/Category/GameName_ProgramName.h"
117+
118+
// Add to make_panels()
119+
ret.emplace_back(make_single_switch_program<ProgramName_Descriptor, ProgramName>());
120+
```
121+
Examples: `PokemonLA_Panels.cpp`, `PokemonSwSh_Panels.cpp`, `PokemonSV_Panels.cpp`
122+
123+
## Descriptor Configuration
124+
125+
```cpp
126+
ProgramName_Descriptor::ProgramName_Descriptor()
127+
: SingleSwitchProgramDescriptor(
128+
"GameName:ProgramName", // Unique ID
129+
STRING_POKEMON + " [GameName]", "Display Name", // Category, Name
130+
"ComputerControl/blob/master/Wiki/...", // Wiki URL
131+
"Brief description.", // Description
132+
ProgramControllerClass::StandardController_NoRestrictions,
133+
FeedbackType::REQUIRED, // or NONE
134+
AllowCommandsWhenRunning::DISABLE_COMMANDS
135+
)
136+
{}
137+
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Pokémon Automation - an open-source project for automating Pokémon (and other) games on Nintendo Switch and Switch 2 using Arduino and other micro-controllers.
2+
3+
Key aspects:
4+
5+
- Games supported: Multiple Pokémon titles plus Zelda: Tears of the Kingdom
6+
- Tech stack: C++23, Qt6, Tesseract OCR, OpenCV, ONNX Runtime
7+
- Functionality: Uses computer vision, OCR, and predefined controller sequences to automate gameplay
8+
- Values brought to users:
9+
- Automate tedious or grinding tasks in Pokémon games.
10+
- Automate hunting rare or shiny Pokémon and Pokémon with specified stats for competitive PvP.
11+
- Automate glitch execution to e.g. dupe items.
12+
- Automate multiplayer Pokémon raid hosting and joining.

0 commit comments

Comments
 (0)