-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect quantity of Happiny Dust, to trigger Material farming from Item printer #453
Conversation
jw098
commented
Jun 25, 2024
- add the option for users to specify a minimum Happiny Dust threshold, below which Material farming will be triggered from the Item printer
- This also helps ensure that other materials don't drop below this number as well, since the Item printer prioritizes using up materials with the highest quantity.
pbf_press_dpad(context, DPAD_RIGHT, 20, 30); | ||
pbf_press_dpad(context, DPAD_RIGHT, 20, 30); | ||
pbf_press_dpad(context, DPAD_RIGHT, 20, 30); | ||
pbf_press_dpad(context, DPAD_RIGHT, 20, 30); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if Happiny dust is not visible after 6 scrolls? Say you're missing most of the earlier ones so that 6 scrolls past it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. I forgot about this.
Number recognition is faster and more reliable than string recognition, right?
I'm thinking we use number recognition to find materials with 68% value, of which there are only 4 materials according to Serebii (Ditto Goo, Happiny Dust, Magby hair, Beldum Claw). Then use string recognition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Number is worse because there's no error correction. Strings have error correction since we can compare against all the possible string values. And there's more characters to work with.
private: | ||
Color m_color; | ||
Language m_language; | ||
ImageFloatBox m_box_1_mat_value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to do this. Just do an array. The items are also evenly spaced out vertically. So you don't need to hard-code the coordinates. Given the first one and the space between them, you can use a simple loop to compute the rest.
…rt material farming
"If a material starts below this threshold, it remains there.<br>" | ||
"Changes to this number only take place after returning to " | ||
"the item printer, after material farming.", | ||
LockMode::UNLOCK_WHILE_RUNNING, 100, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dunno if setting it as low as 100 is necessarily the # since the auto-select always uses the ones with the most quantity first. So if you have larger quantities of non-Happiny dust that are harder to collect, it will consume those as well.
But I'm not sure how much material is used for making TMs. Maybe 100 is enough for most purposes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TMs usually use 3 for a given material. Occasionally up to 8.
https://bulbapedia.bulbagarden.net/wiki/TM_Material
I can change the default to 400.
If you run the material farmer for 30 minutes, you'll get around 450 Happiny Dust. So a threshold of around 400 is reasonable. If you run the material for 60 minutes, you'll get around 900 Happiny Dust, so a threshold of around 100 would be better in that case.
ConsoleHandle& console, BotBaseContext& context | ||
) const{ | ||
int8_t value_68_row_index; | ||
for (size_t c = 0; c < 10; c++){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10 is the max # of times to fully page down?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. There are around 260 materials. So should take 26 times to fully page down.
But Happiny Dust is approximately number 73, so should take 8 times to page down. As far as I know, the items are always in the same order.
I'm fine with increasing the max number of times to scroll, just to account for button drops, or in case the material is in a different order than expected.
) const{ | ||
context.wait_for_all_requests(); | ||
VideoSnapshot snapshot = console.video().snapshot(); | ||
for (int8_t i = 0; i < 10; i++){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it's worth parallelizing this since you're running 10 of them sequentially. Not sure how long this takes on a slower computer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also not sure if it's worth it. But I guess it couldn't hurt.
for (int8_t i = 0; i < 10; i++){ | ||
int16_t value = read_number(console, dispatcher, snapshot, m_box_mat_value[i]); | ||
if (value == material_value){ | ||
return i; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if there are multiple 68% materials on the same screen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad. I keep forgetting that there can be missing materials from the list. I'll make the function return a vector instead.