From 81bc9028d12fbcd912cdff78f4684bfb7ed455c6 Mon Sep 17 00:00:00 2001 From: Sosa <102399727+definitelynotsosa@users.noreply.github.com> Date: Wed, 22 Jun 2022 00:43:49 -0400 Subject: [PATCH 1/4] Update default.nip Fixing white claw bases --- config/default.nip | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/config/default.nip b/config/default.nip index e2b16b4..ed5fb31 100644 --- a/config/default.nip +++ b/config/default.nip @@ -881,14 +881,12 @@ //------------------------------------------------------ // <<<<<<<<< [ Non-Ethereal Superior/Non-Superior Assassin Claws ] >>>>>>>>> -[Type] == Assassinclaw && [Class] == Elite && ([Quality] == Normal || [Quality] == Superior) && [Flag] != Ethereal # ([Skilllightningsentry] >= 3 || [Skilldeathsentry] >= 3) && [Sockets] == 0 // Chaos -[Type] == Assassinclaw && [Class] == Elite && ([Quality] == Normal || [Quality] == Superior) && [Flag] != Ethereal # ([Skilllightningsentry] >= 3 || [Skilldeathsentry] >= 3) && [Sockets] == 3 // Chaos Socketed -[Type] == Assassinclaw && [Class] == Elite && ([Quality] == Normal || [Quality] == Superior) && [Flag] != Ethereal # ([Skillweaponblock] >= 3 || [Skillclawmastery] >= 2 || [Skillfade] >= 2 || [Skillbladeshield] >= 2 || [Skilldragonflight] >= 2 || [Skillmindblast] >= 1) && [Sockets] == 0 // Chaos -[Type] == Assassinclaw && [Class] == Elite && ([Quality] == Normal || [Quality] == Superior) && [Flag] != Ethereal # ([Skillweaponblock] >= 3 || [Skillclawmastery] >= 2 || [Skillfade] >= 2 || [Skillbladeshield] >= 2 || [Skilldragonflight] >= 2 || [Skillmindblast] >= 1) && [Sockets] == 3 // Chaos Socketed -[Type] == Assassinclaw && [Class] == Elite && ([Quality] == Normal || [Quality] == Superior) && [Flag] != Ethereal # [Skillbladeshield] >= 3 && ([Skillweaponblock] >= 3 || [Skillclawmastery] >= 2 || [Skillfade] >= 2 || [Skillvenom] >= 2 || [Skilldragonflight] >= 2 || [Skillmindblast] >= 1) && [Sockets] == 0 // Chaos -[Type] == Assassinclaw && [Class] == Elite && ([Quality] == Normal || [Quality] == Superior) && [Flag] != Ethereal # [Skillbladeshield] >= 3 && ([Skillweaponblock] >= 3 || [Skillclawmastery] >= 2 || [Skillfade] >= 2 || [Skillvenom] >= 2 || [Skilldragonflight] >= 2 || [Skillmindblast] >= 1) && [Sockets] == 3 // Chaos Socketed -[Type] == Assassinclaw && [Class] == Elite && ([Quality] == Normal || [Quality] == Superior) && [Flag] != Ethereal # [Skillweaponblock] >= 3 && ([Skillclawmastery] >= 2 || [Skillfade] >= 2 || [Skillvenom] >= 2 || [Skillbladeshield] >= 2 || [Skilldragonflight] >= 2 || [Skillmindblast] >= 1) && [Sockets] == 0 // Chaos -[Type] == Assassinclaw && [Class] == Elite && ([Quality] == Normal || [Quality] == Superior) && [Flag] != Ethereal # [Skillweaponblock] >= 3 && ([Skillclawmastery] >= 2 || [Skillfade] >= 2 || [Skillvenom] >= 2 || [Skillbladeshield] >= 2 || [Skilldragonflight] >= 2 || [Skillmindblast] >= 1) && [Sockets] == 3 // Chaos Socketed +([Name] == Suwayyah || [Name] == FeralClaws || [Name] == RunicTalons || [Name] == GreaterTalons || [Name] == GreaterClaws) && ([Quality] == Normal || [Quality] == Superior) && [Flag] != Ethereal # [SkillLightningsentry] >= 3 && [Skillfade] >= 3 && ([Skillbladeshield] >= 3 || [Skillweaponblock] >= 3 || [Skillclawmastery] >= 2 || [Skillvenom] >= 2 || [Skilldragonflight] >= 2 || [Skillmindblast] >= 1) && [Sockets] == 0 // Chaos +([Name] == Suwayyah || [Name] == FeralClaws || [Name] == RunicTalons || [Name] == GreaterTalons || [Name] == GreaterClaws) && ([Quality] == Normal || [Quality] == Superior) && [Flag] != Ethereal # [SkillLightningsentry] >= 3 && [Skillfade] >= 3 && ([Skillbladeshield] >= 3 || [Skillweaponblock] >= 3 || [Skillclawmastery] >= 2 || [Skillvenom] >= 2 || [Skilldragonflight] >= 2 || [Skillmindblast] >= 1) && [Sockets] == 3 // Chaos Socketed +([Name] == Suwayyah || [Name] == FeralClaws || [Name] == RunicTalons || [Name] == GreaterTalons || [Name] == GreaterClaws) && ([Quality] == Normal || [Quality] == Superior) && [Flag] != Ethereal # [SkillLightningsentry] >= 3 && [Skillmindblast] >= 3 && ([Skillweaponblock] >= 2 || [Skillclawmastery] >= 2 || [Skillfade] >= 2 || [Skillvenom] >= 2 || [Skillbladeshield] >= 2 || [Skilldragonflight] >= 2) && [Sockets] == 0 // Chaos +([Name] == Suwayyah || [Name] == FeralClaws || [Name] == RunicTalons || [Name] == GreaterTalons || [Name] == GreaterClaws) && ([Quality] == Normal || [Quality] == Superior) && [Flag] != Ethereal # [SkillLightningsentry] >= 3 && [Skillmindblast] >= 3 && ([Skillweaponblock] >= 2 || [Skillclawmastery] >= 2 || [Skillfade] >= 2 || [Skillvenom] >= 2 || [Skillbladeshield] >= 2 || [Skilldragonflight] >= 2) && [Sockets] == 3 // Chaos Socketed +([Name] == Suwayyah || [Name] == FeralClaws || [Name] == RunicTalons || [Name] == GreaterTalons || [Name] == GreaterClaws) && ([Quality] == Normal || [Quality] == Superior) && [Flag] != Ethereal # [SkillLightningsentry] >= 3 && [Skillvenom] >= 3 && ([Skillweaponblock] >= 2 || [Skillclawmastery] >= 2 || [Skillfade] >= 2 || [Skillbladeshield] >= 2 || [Skilldragonflight] >= 2 || [Skillmindblast] >= 1) && [Sockets] == 0 // Chaos +([Name] == Suwayyah || [Name] == FeralClaws || [Name] == RunicTalons || [Name] == GreaterTalons || [Name] == GreaterClaws) && ([Quality] == Normal || [Quality] == Superior) && [Flag] != Ethereal # [SkillLightningsentry] >= 3 && [Skillvenom] >= 3 && ([Skillweaponblock] >= 2 || [Skillclawmastery] >= 2 || [Skillfade] >= 2 || [Skillbladeshield] >= 2 || [Skilldragonflight] >= 2 || [Skillmindblast] >= 1) && [Sockets] == 3 // Chaos Socketed //----------------------------------------------- //================= Staves Bases ================ From 9b2d52a39bca7c723bbcc66beda32e6f9cc991a2 Mon Sep 17 00:00:00 2001 From: Wang Xiang Date: Thu, 23 Jun 2022 17:51:40 +0800 Subject: [PATCH 2/4] Update diablo.py _sealdance() I watched 10 hours of diablo run by 4 fohdins. About 30% were fail games which aborted in middle run, especially on detecting that if the seal is openned. In almost every fail game caused by this reason, the seal was openned successfully, but the decisions were closed for 5 times and the game was aborted. By increasing the numbers of try and reduce the seal_opentemplates threshold to 0.7, the incorrect judgements on seal's open status seldom occur, and the ratio of failed games typically reduced. Now it is about 12% mostly caused by temporary high latency or getting lost after teleport to pick item. --- src/run/diablo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/run/diablo.py b/src/run/diablo.py index 2c40635..d5aa805 100644 --- a/src/run/diablo.py +++ b/src/run/diablo.py @@ -113,11 +113,11 @@ class Diablo: # OPEN SEALS def _sealdance(self, seal_opentemplates: list[str], seal_closedtemplates: list[str], seal_layout: str, seal_node: str) -> bool: i = 0 - while i < 4: + while i < 8: Logger.debug(seal_layout + ": trying to open (try #" + str(i+1)+")") self._char.select_by_template(seal_closedtemplates, threshold=0.5, timeout=0.1, telekinesis=True) wait(i*0.5) - found = template_finder.search_and_wait(seal_opentemplates, threshold=0.75, timeout=0.1).valid + found = template_finder.search_and_wait(seal_opentemplates, threshold=0.7, timeout=0.1).valid if found: Logger.info(seal_layout +": is open - "+'\033[92m'+" open"+'\033[0m') break From 5089abaca66df04050616fae198f725fd7275019 Mon Sep 17 00:00:00 2001 From: Wang Xiang Date: Thu, 23 Jun 2022 19:13:59 +0800 Subject: [PATCH 3/4] Update default.nip Shadowplates (#927) Add expressions for Shadowplates in Armor Bases section. --- config/default.nip | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config/default.nip b/config/default.nip index ed5fb31..0ec4b0a 100644 --- a/config/default.nip +++ b/config/default.nip @@ -629,6 +629,7 @@ //[Name] == Scarabhusk && [Quality] == Normal && [Flag] != Ethereal # [Sockets] == 0 // Plain //[Name] == Wyrmhide && [Quality] == Normal && [Flag] != Ethereal # [Sockets] == 0 // Plain //[Name] == Lightplate && [Quality] == Normal && [Flag] != Ethereal # [Sockets] == 0 // Plain +//[Name] == Shadowplate && [Quality] == Normal && [Flag] != Ethereal # [Sockets] == 0 // Plain //[Name] == Sacredarmor && [Quality] == Normal && [Flag] != Ethereal # [Sockets] == 0 // Plain // <<<<<<<<< [ Non-Ethereal Socketed Armor ] >>>>>>>>> @@ -640,6 +641,7 @@ //[Name] == Scarabhusk && [Quality] == Normal && [Flag] != Ethereal # [Sockets] >= 3 // Socketed //[Name] == Wyrmhide && [Quality] == Normal && [Flag] != Ethereal # [Sockets] >= 3 // Socketed //[Name] == Lightplate && [Quality] == Normal && [Flag] != Ethereal # [Sockets] >= 3 // Socketed +//[Name] == Shadowplate && [Quality] == Normal && [Flag] != Ethereal # [Sockets] >= 4 // Socketed //[Name] == Sacredarmor && [Quality] == Normal && [Flag] != Ethereal # [Sockets] >= 4 // Socketed // <<<<<<<<< [ Non-Ethereal Superior Non-Socketed Armor ] >>>>>>>>> @@ -651,6 +653,7 @@ [Name] == Scarabhusk && [Quality] == Superior && [Flag] != Ethereal # [Sockets] == 0 && [Enhanceddefense] >= 10 // Plain Superior [Name] == Wyrmhide && [Quality] == Superior && [Flag] != Ethereal # [Sockets] == 0 && [Enhanceddefense] >= 10 // Plain Superior //[Name] == Lightplate && [Quality] == Superior && [Flag] != Ethereal # [Sockets] == 0 && [Enhanceddefense] >= 10 // Plain Superior +//[Name] == Shadowplate && [Quality] == Superior && [Flag] != Ethereal # [Sockets] == 0 && [Enhanceddefense] >= 10 // Plain Superior //[Name] == Sacredarmor && [Quality] == Superior && [Flag] != Ethereal # [Sockets] == 0 && [Enhanceddefense] >= 10 // Plain Superior // <<<<<<<<< [ Non-Ethereal Superior Socketed Armor ] >>>>>>>>> @@ -662,6 +665,7 @@ [Name] == Scarabhusk && [Quality] == Superior && [Flag] != Ethereal # [Enhanceddefense] >= 10 && [Sockets] >= 3 // Socketed Sup [Name] == Wyrmhide && [Quality] == Superior && [Flag] != Ethereal # [Enhanceddefense] >= 10 && [Sockets] >= 3 // Socketed Sup //[Name] == Lightplate && [Quality] == Superior && [Flag] != Ethereal # [Enhanceddefense] >= 10 && [Sockets] >= 3 // Socketed Sup +//[Name] == Shadowplate && [Quality] == Superior && [Flag] != Ethereal # [Enhanceddefense] >= 10 && [Sockets] >= 4 // Socketed Sup //[Name] == Sacredarmor && [Quality] == Superior && [Flag] != Ethereal # [Enhanceddefense] >= 10 && [Sockets] >= 4 // Socketed Sup // <<<<<<<<< [ Ethereal Socketed/Non-Socketed Armor ] >>>>>>>>> @@ -673,6 +677,7 @@ [Name] == Scarabhusk && [Quality] == Normal && [Flag] == Ethereal # ([Sockets] == 0 || [Sockets] >= 3) // Socketed Eth [Name] == Wyrmhide && [Quality] == Normal && [Flag] == Ethereal # ([Sockets] == 0 || [Sockets] >= 3) // Socketed Eth //[Name] == Lightplate && [Quality] == Normal && [Flag] == Ethereal # ([Sockets] == 0 || [Sockets] >= 3) // Socketed Eth +[Name] == Shadowplate && [Quality] == Normal && [Flag] == Ethereal # ([Sockets] == 0 || [Sockets] == 4) // Socketed Eth [Name] == Sacredarmor && [Quality] == Normal && [Flag] == Ethereal # ([Sockets] == 0 || [Sockets] == 4) // Socketed Eth // <<<<<<<<< [ Ethereal Superior Socketed/Non-Socketed Armor ] >>>>>>>>> @@ -684,6 +689,7 @@ [Name] == Scarabhusk && [Quality] == Superior && [Flag] == Ethereal # ([Sockets] == 0 || [Sockets] >= 3) && [Enhanceddefense] >= 10 // Socketed Eth Sup [Name] == Wyrmhide && [Quality] == Superior && [Flag] == Ethereal # ([Sockets] == 0 || [Sockets] >= 3) && [Enhanceddefense] >= 10 // Socketed Eth Sup [Name] == Lightplate && [Quality] == Superior && [Flag] == Ethereal # ([Sockets] == 0 || [Sockets] == 3) && [Enhanceddefense] >= 10 // Socketed Eth Sup +[Name] == Shadowplate && [Quality] == Superior && [Flag] == Ethereal # ([Sockets] == 0 || [Sockets] >= 4) && [Enhanceddefense] >= 10 // Socketed Eth Sup [Name] == Sacredarmor && [Quality] == Superior && [Flag] == Ethereal # ([Sockets] == 0 || [Sockets] >= 4) && [Enhanceddefense] >= 10 // Socketed Eth Sup //----------------------------------------------- From 197ff41e69e3c09433b4ce31da83968bee41b9d1 Mon Sep 17 00:00:00 2001 From: Gleed Date: Thu, 23 Jun 2022 13:42:39 -0400 Subject: [PATCH 4/4] Fix Fix: template_finder.search() tests were terminating after first "assert" --- test/template_finder_test.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/test/template_finder_test.py b/test/template_finder_test.py index 9e1a1a5..65cb5f9 100644 --- a/test/template_finder_test.py +++ b/test/template_finder_test.py @@ -5,36 +5,36 @@ from utils.misc import is_in_roi import screen import utils.download_test_assets # downloads assets if they don't already exist, doesn't need to be called -@pytest.mark.parametrize("template1_path, template2_path, template3_path, screen_path, expected_roi", [( - "test/assets/stash_slot_empty.png", # empty stash slot - "test/assets/stash_slot_slash.png", # empty stash slot but has a drawn slash - "test/assets/stash_slot_cross.png", # empty stash slot but has a drawn X - "test/assets/stash_slots.png", # image with three empty slots and one slot with a draw slash - [38, 0, 38, 38]) # region of slash -]) -def test_match_behavior(template1_path, template2_path, template3_path, screen_path, expected_roi): - screen.set_window_position(0, 0) - image = cv2.imread(screen_path) - empty = cv2.imread(template1_path) - slash = cv2.imread(template2_path) - cross = cv2.imread(template3_path) +screen.set_window_position(0, 0) + +image = cv2.imread("test/assets/stash_slots.png") +empty = cv2.imread("test/assets/stash_slot_empty.png") +slash = cv2.imread("test/assets/stash_slot_slash.png") +cross = cv2.imread("test/assets/stash_slot_cross.png") +slash_expected_roi = [38, 0, 38, 38] + +def test_search(): threshold=0.6 """ - Test first match + Test default search behavior (first match) - searches first for cross, which doesn't perfectly match but should reach above threshold - if cross matches above threshold as expected, then it won't bother to search for slash, which has a perfect match on the image - test passes if the template match score is not perfect """ match = template_finder.search([cross, slash], image, threshold) assert threshold <= match.score < 1 + +def test_search_best_match(): """ - Test best match + Test search "best_match" behavior - searches first for cross, which doesn't perfectly match - searches next for slash, which perfectly matches on image - test passes if the center of the template match lies within the expected region of the slash """ match = template_finder.search([cross, slash], image, threshold=0.6, best_match=True) - assert is_in_roi(expected_roi, match.center) + assert is_in_roi(slash_expected_roi, match.center) + +def test_search_all(): """ Test all matches - searches for empty slots with high threshold