Skip to content

Commit

Permalink
Rebase ball-template-matching (#118)
Browse files Browse the repository at this point in the history
* Update AutoMaxLair.cs

* Some hot fixes

* Update AutoMaxLair.Designer.cs

* Some code fixes

-Comments will be now copied
- balls will be selected to the one saved
- added "Find Path"
- some minor design changes

* Added an option to change from dark theme to light theme

* Create dotnet.yml

* Revert "Create dotnet.yml"

This reverts commit 9ce739a.

* Create dotnet-core.yml

* Update AutoMaxLair.Designer.cs

* Update AutoMaxLair.Designer.cs

* Update AutoMaxLair.csproj

* Update dotnet-core.yml

* Update dotnet-core.yml

* dotnet only publishes executable

* Added maximum Dynite Ore cost & missing designer parts

* Updated the themes

* Update README.txt

* fixed problem causing .exe to crash on save

- getting max dynite ore value AsInteger
- some minor code cleanup

* Update AutoMaxLair.csproj

* Ball template matching (#112)

* Add framework for detecting ball sprites

- Debug mode will now print the ball sprite it detects while still using OCR for decisions

* Fix typo

* Fix typo

Co-authored-by: DOTTEL Gaël <[email protected]>

* Add foundation for reading ball numbers

- Set up framework for reading and assigning the number of base and legendary balls.
- The previous accounting method is still used and the new method is simply logged for verification.

* Formatting fixes

* Fix error

* Remove alpha channel of ball sprite images

Co-authored-by: DOTTEL Gaël <[email protected]>

* fix the ore count when you're kicked out of the den without catching any pokemon

* Updated the UI

added:
- FIND_PATH_WINS
- NON_LEGEND

fixed:
- missing changes with Light-Theme

* Show ball sprite rectangle

* Fix ball sprite detection rectangle

* Find path like ball saver not strong boss (#116)

* Update auto_max_lair.py

* Update Config.sample.toml

* Update auto_max_lair.py

* Improve the log summary (#115)

* Delete log_summary.py

* Use filename timestamp to order bosses

Bosses will be ordered by filename timestamp (from oldest to newest)

* increase the timer after the scientist

* Allow AutoMaxLair to be used with the PABotBase hex file (#117)

* Initial commit of framework

- Not functional yet

* Fix CRC calculation and implement reset protocol

* Start implementing command translations between protocols

* Update with latest progress

* Initial working version

- To use, enable PABOTBASE_HEX in the configuration file

* Delete CRC_sandbox.py

* Fix linting errors

* Update requirements.txt

* Formatting and documentation fixes

Co-authored-by: PrincessVika <[email protected]>
Co-authored-by: PrincessVika <[email protected]>
Co-authored-by: DOTTEL Gaël <[email protected]>
Co-authored-by: TeachingGame <[email protected]>
  • Loading branch information
5 people authored Apr 4, 2021
1 parent fadf38c commit 4ed45a2
Show file tree
Hide file tree
Showing 12 changed files with 508 additions and 152 deletions.
115 changes: 86 additions & 29 deletions AutoMaxLairUI - Code/AutoMaxLair.Designer.cs

Large diffs are not rendered by default.

36 changes: 33 additions & 3 deletions AutoMaxLairUI - Code/AutoMaxLair.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ private void getConfig()
}
}

List<string> nonLegendList = new List<string>();
using (StreamReader reader = File.OpenText(@"data/rental_pokemon.json"))
{
string json2 = reader.ReadToEnd();
foreach (var item in JObject.Parse(json2).Properties())
{
nonLegendList.Add(item.Name);
}
}

List<string> ballList = new List<string>();
using (StreamReader reader = File.OpenText(@"data/balls.json"))
{
Expand Down Expand Up @@ -126,18 +136,19 @@ private void getConfig()
boxSpeedNeut.Text = String.Join(",", arr4);
boxSpeedNeg.Text = String.Join(",", arr5);

SetConfigValue(boxPokemon, Utils.ConvertBossIdToBossName(t["BOSS"]), t["BOSS"].Comment);
boxPokemon.Items.AddRange(legendaryList.ToArray());
SetConfigValue(boxPokemon, Utils.ConvertBossIdToBossName(t["BOSS"]), t["BOSS"].Comment);

SetConfigValue(boxBaseBall, Utils.ConvertBallIdToBallName(t["BASE_BALL"]), t["BASE_BALL"].Comment);
boxBaseBall.Items.AddRange(ballList.ToArray());
SetConfigValue(boxBaseBall, Utils.ConvertBallIdToBallName(t["BASE_BALL"]), t["BASE_BALL"].Comment);
SetConfigValue(boxBaseBallValue, t["BASE_BALLS"], t["BASE_BALLS"].Comment);

SetConfigValue(boxLegendBall, Utils.ConvertBallIdToBallName(t["LEGENDARY_BALL"]), t["LEGENDARY_BALL"].Comment);
boxLegendBall.Items.AddRange(ballList.ToArray());
SetConfigValue(boxLegendBall, Utils.ConvertBallIdToBallName(t["LEGENDARY_BALL"]), t["LEGENDARY_BALL"].Comment);
SetConfigValue(boxLegendBallValue, t["LEGENDARY_BALLS"], t["LEGENDARY_BALLS"].Comment);

SetConfigValue(boxMode, t["MODE"], t["MODE"].Comment);
SetConfigValue(boxPathWins, t["FIND_PATH_WINS"], t["FIND_PATH_WINS"].Comment);
SetConfigValue(boxComPort, t["COM_PORT"], t["COM_PORT"].Comment);

// Get every Video Capture device and put it into the combobox (with right order)
Expand All @@ -158,7 +169,13 @@ private void getConfig()
SetConfigValue(boxBossIndex, t["advanced"]["BOSS_INDEX"], t["advanced"]["BOSS_INDEX"].Comment);
SetConfigValue(boxDyniteOre, t["advanced"]["DYNITE_ORE"], t["advanced"]["DYNITE_ORE"].Comment);
SetConfigValue(boxConsecutiveResets, t["advanced"]["CONSECUTIVE_RESETS"], t["advanced"]["CONSECUTIVE_RESETS"].Comment);

boxNonLegend.Items.Add("default");
boxNonLegend.Items.AddRange(nonLegendList.ToArray());
SetConfigValue(boxNonLegend, t["advanced"]["NON_LEGEND"], t["advanced"]["NON_LEGEND"].Comment);

SetConfigValue(boxMaxDynite, t["advanced"]["MAXIMUM_ORE_COST"], t["advanced"]["MAXIMUM_ORE_COST"].Comment);
SetConfigValue(boxNonLegend, t["NON_LEGEND"], t["NON_LEGEND"].Comment);

checkBoxDebugLogs.Checked = t["advanced"]["ENABLE_DEBUG_LOGS"];
this.toolTip.SetToolTip(this.checkBoxDebugLogs, t["advanced"]["ENABLE_DEBUG_LOGS"].Comment);
Expand Down Expand Up @@ -313,6 +330,7 @@ private void setConfig()
t["LEGENDARY_BALL"].AsString.Value = Utils.ConvertBallNameToBallId(boxLegendBall.Text);
t["LEGENDARY_BALLS"].AsInteger.Value = int.Parse(boxLegendBallValue.Text);
t["MODE"].AsString.Value = boxMode.Text.ToUpper();
t["FIND_PATH_WINS"].AsInteger.Value =int.Parse(boxPathWins.Text);
t["COM_PORT"].AsString.Value = boxComPort.Text;
t["VIDEO_INDEX"].AsInteger.Value = boxVideoCapture.SelectedIndex;
t["TESSERACT_PATH"].AsString.Value = boxTesseract.Text;
Expand All @@ -323,6 +341,7 @@ private void setConfig()
t["advanced"]["BOSS_INDEX"].AsInteger.Value = boss;
t["advanced"]["DYNITE_ORE"].AsInteger.Value = int.Parse(boxDyniteOre.Text);
t["advanced"]["CONSECUTIVE_RESETS"].AsInteger.Value = int.Parse(boxConsecutiveResets.Text);
t["advanced"]["NON_LEGEND"].AsString.Value = boxNonLegend.Text;
t["advanced"]["MAXIMUM_ORE_COST"].AsInteger.Value = int.Parse(boxMaxDynite.Text);
t["advanced"]["ENABLE_DEBUG_LOGS"].AsBoolean.Value = checkBoxDebugLogs.Checked;

Expand Down Expand Up @@ -532,6 +551,9 @@ void Initialize_Add()
labels.Add(labelMessages);
labels.Add(labelAtk);
labels.Add(labelSpeed);
labels.Add(labelMaxDynite);
labels.Add(labelPathWins);
labels.Add(labelNonLegend);

comboboxes.Add(boxBossIndex);
comboboxes.Add(boxPokemon);
Expand All @@ -541,6 +563,7 @@ void Initialize_Add()
comboboxes.Add(boxVideoCapture);
comboboxes.Add(boxGameLanguage);
comboboxes.Add(boxPingSettings);
comboboxes.Add(boxNonLegend);

textboxes.Add(boxBaseBallValue);
textboxes.Add(boxLegendBallValue);
Expand All @@ -560,6 +583,8 @@ void Initialize_Add()
textboxes.Add(boxWebhookToken);
textboxes.Add(boxUserID);
textboxes.Add(boxPingName);
textboxes.Add(boxMaxDynite);
textboxes.Add(boxPathWins);

checkboxes.Add(checkBoxDebugLogs);
checkboxes.Add(boxCheckAttack);
Expand Down Expand Up @@ -614,6 +639,11 @@ public void ApplyTheme(Color back, Color pan, Color btn, Color lab, Color cbox,
}
}

private void boxComPort_TextChanged(object sender, EventArgs e)
{

}

public void SetConfigValue(Control control, string content, string tooltip)
{
control.Text = content;
Expand Down
25 changes: 0 additions & 25 deletions AutoMaxLairUI - Code/AutoMaxLair.resx
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,6 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="boxVideoDelay.ToolTip" xml:space="preserve">
<value>Input a time (in seconds) if your capture card has any significant delay.
Most configurations can leave this value at 0 but people using OBS
virtual camera may have to increase this calue to 1 or 2 (seconds).
</value>
</data>
<data name="boxMode.ToolTip" xml:space="preserve">
<value>This is the mode that the program should use.

"Default": Perfect to accumulate Dynite Ore, it will never reset the game.

"Ball Saver": Resets the game, if the legendary is not shiny.
It will also keep track of your Dynite Ore and not catch the Boss if low on it.

"Strong Boss": Similiar to Ball Saver, but will also keep non legendary shinies.

"Keep path": Will force the game to always reset on a pre-saved path.
This will deplete your Dynite Ore quickly.</value>
</data>
<assembly alias="System.Drawing.Common" name="System.Drawing.Common, Version=4.0.2.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" />
<data name="pictureBox1.Image" type="System.Drawing.Bitmap, System.Drawing.Common" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
Expand Down Expand Up @@ -349,12 +330,6 @@ This will deplete your Dynite Ore quickly.</value>
1QPMAZEBkhIl0SGIihrXKiApbHDDQGkeEEQTilxEigy9nY6oBwcwLtaNGwjaGUqlVGQGQ6f7f64t2Cb+
dAjZAAAAAElFTkSuQmCC
</value>
</data>
<data name="boxPingSettings.ToolTip" xml:space="preserve">
<value>The update messages that the webhook will send you.
"all": provides all possible updates to your webhook, includes stats after a completed run.
"only shiny": will only push updates if shinies are found.
"none": ignores all discord messages.</value>
</data>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing.Common" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
Expand Down
6 changes: 6 additions & 0 deletions AutoMaxLairUI - Code/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ void Initialize_Add()
labels.Add(main.labelMessages);
labels.Add(main.labelAtk);
labels.Add(main.labelSpeed);
labels.Add(main.labelMaxDynite);
labels.Add(main.labelPathWins);
labels.Add(main.labelNonLegend);

comboboxes.Add(main.boxBossIndex);
comboboxes.Add(main.boxPokemon);
Expand All @@ -103,6 +106,7 @@ void Initialize_Add()
comboboxes.Add(main.boxVideoCapture);
comboboxes.Add(main.boxGameLanguage);
comboboxes.Add(main.boxPingSettings);
comboboxes.Add(main.boxNonLegend);

textboxes.Add(main.boxBaseBallValue);
textboxes.Add(main.boxLegendBallValue);
Expand All @@ -123,6 +127,8 @@ void Initialize_Add()
textboxes.Add(main.boxWebhookToken);
textboxes.Add(main.boxUserID);
textboxes.Add(main.boxPingName);
textboxes.Add(main.boxMaxDynite);
textboxes.Add(main.boxPathWins);

checkboxes.Add(main.checkBoxDebugLogs);
checkboxes.Add(main.boxCheckAttack);
Expand Down
12 changes: 8 additions & 4 deletions Config.sample.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ BASE_BALL = "premier-ball"

# === BASE_BALLS ===
# This is the current quantity of the ball that you selected in BASE_BALL
BASE_BALLS = 600
BASE_BALLS = 500

# === LEGENDARY_BALL ===
# This is the Pokéball that should be used for just the legendary boss Pokémon.
Expand Down Expand Up @@ -57,9 +57,8 @@ LEGENDARY_BALLS = 500
# "KEEP PATH" - Will force the game to always reset on a pre-saved path.
# Similar to "BALL SAVER" and "STRONG BOSS" but will always use the same path if it fails.
# This will deplete your Ore quickly.
# "FIND PATH" - Will run like STRONG BOSS mode but will stop when it consecutively wins the
# number of times inputted into "FIND PATH WINS". It is recommended to leave the
# NON_LEGEND setting as "default" to avoid any false posistives.
# "FIND PATH" - Will run like BALL SAVER mode but will stop when it consecutively wins the
# number of times inputted into "FIND PATH WINS".
# It can be used alongside KEEP PATH to find a winning path. Don't forget to update the
# CONSECUTIVE_RESETS section below, before starting KEEP PATH.
# It's up to the user to check if the path found was good or not.
Expand Down Expand Up @@ -102,6 +101,11 @@ VIDEO_SCALE = 0.5
# Please make sure there's always a decimal at the end of this value.
VIDEO_EXTRA_DELAY = 0.0

# === PABOTBASE_HEX ==
# Denote whether your microcontroller is using the PABotBase hex.
# If false, RemoteControl_xxxx.hex is assumed
PABOTBASE_HEX = false

# === BOSS_INDEX ===
# The position of the boss you're hunting on the menu.
# 0 is the top, 1 is the middle, and 2 is the bottom.
Expand Down
25 changes: 15 additions & 10 deletions auto_max_lair.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import automaxlair
from automaxlair import matchup_scoring

VERSION = 'v0.8-beta-20210328'
VERSION = 'v0.8-beta-20210402'

# load configuration from the config file
try:
Expand Down Expand Up @@ -555,7 +555,7 @@ def scientist(ctrlr) -> str:
# OrderedDict is unnecessary.
if average_score > existing_score:
ctrlr.log(f'Identified {run.pokemon.name_id} as our new Pokemon.')
ctrlr.push_button(None, 3)
ctrlr.push_button(None, 5)

return 'detect'

Expand All @@ -574,15 +574,15 @@ def select_pokemon(ctrlr) -> str:
ctrlr.log('No Pokemon caught.')
ctrlr.push_buttons((None, 10), (b'b', 1))
ctrlr.runs += 1
ctrlr.reset_run()
ctrlr.record_ore_reward()
ctrlr.log('Preparing for another run.')

ctrlr.send_discord_message(
"No Pokémon were caught in the last run.",
embed_fields=ctrlr.get_stats_for_discord(),
level="update"
)
ctrlr.record_ore_reward()
ctrlr.reset_run()
ctrlr.log('Preparing for another run.')

# No Pokemon to review, so go back to the beginning.
# Note that the "keep path" mode is meant to be used on a good path, so
# although the path would be lost that situation should never arise.
Expand Down Expand Up @@ -643,9 +643,15 @@ def select_pokemon(ctrlr) -> str:
# caught.
if (
(ctrlr.mode == 'keep path' and (run.num_caught < 4 or i > 0))
or (ctrlr.mode == 'ball saver' and run.num_caught == 4 and i > 0)
or (
(ctrlr.mode == 'ball saver' or ctrlr.mode == 'find path')
and run.num_caught == 4 and i > 0
)
):
if ctrlr.mode == 'ball saver' or ctrlr.check_sufficient_ore(2):
if (
(ctrlr.mode == 'ball saver' or ctrlr.mode == 'find path')
or ctrlr.check_sufficient_ore(2)
):
reset_game = True
break
else:
Expand Down Expand Up @@ -692,8 +698,7 @@ def select_pokemon(ctrlr) -> str:
ctrlr.push_button(b'^', 3 + VIDEO_EXTRA_DELAY)

if (
not take_pokemon and (
ctrlr.mode == 'strong boss' or ctrlr.mode == 'find path')
not take_pokemon and ctrlr.mode == 'strong boss'
and run.num_caught == 4 and ctrlr.check_sufficient_ore(1)
):
reset_game = True
Expand Down
Loading

0 comments on commit 4ed45a2

Please sign in to comment.