diff --git a/campaign/event_20200423_cn/a1.py b/campaign/event_20200423_cn/a1.py index 1059cbb00..79c57dc45 100644 --- a/campaign/event_20200423_cn/a1.py +++ b/campaign/event_20200423_cn/a1.py @@ -5,7 +5,6 @@ from module.logger import logger MAP = CampaignMap() -MAP.camera_sight = (-4, -2, 5, 3) MAP.map_data = ''' -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- @@ -26,26 +25,15 @@ class Config: MAP_HAS_MOVABLE_ENEMY = True MAP_HAS_SIREN = True MAP_HAS_DYNAMIC_RED_BORDER = True - MAP_GRID_CENTER_TOLERANCE = 0.3 MAP_SIREN_COUNT = 2 - INTERNAL_LINES_HOUGHLINES_THRESHOLD = 50 - EDGE_LINES_HOUGHLINES_THRESHOLD = 50 - CAMERA_SWIPE_MULTIPLY_X = 200 * 0.7 - CAMERA_SWIPE_MULTIPLY_Y = 140 * 0.7 - COINCIDENT_POINT_ENCOURAGE_DISTANCE = 1. - MID_DIFF_RANGE_H = (45, 70) - MID_DIFF_RANGE_V = (97 - 3, 97 + 3) TRUST_EDGE_LINES = True - VANISH_POINT_RANGE = ((540, 740), (-4000, -2000)) - DISTANCE_POINT_X_RANGE = ((-2000, -1000),) INTERNAL_LINES_FIND_PEAKS_PARAMETERS = { 'height': (80, 255 - 40), 'width': (0.9, 10), 'prominence': 10, 'distance': 35, - 'wlen': 100, } EDGE_LINES_FIND_PEAKS_PARAMETERS = { 'height': (255 - 40, 255), diff --git a/campaign/event_20200423_cn/a2.py b/campaign/event_20200423_cn/a2.py index 5a16d13d5..7a7e4dc99 100644 --- a/campaign/event_20200423_cn/a2.py +++ b/campaign/event_20200423_cn/a2.py @@ -5,7 +5,6 @@ from module.logger import logger from campaign.event_20200423_cn.a1 import Config MAP = CampaignMap() -MAP.camera_sight = (-4, -2, 5, 3) MAP.map_data = ''' -- -- -- -- -- -- -- -- -- -- ++ ++ ++ -- diff --git a/campaign/event_20200423_cn/a3.py b/campaign/event_20200423_cn/a3.py index d81023535..7141601ee 100644 --- a/campaign/event_20200423_cn/a3.py +++ b/campaign/event_20200423_cn/a3.py @@ -5,7 +5,6 @@ from module.logger import logger from campaign.event_20200423_cn.a1 import Config MAP = CampaignMap() -MAP.camera_sight = (-4, -2, 5, 3) MAP.map_data = ''' SP SP -- -- -- -- -- -- -- SP -- -- -- ++ ++ ++ -- -- diff --git a/campaign/event_20200423_cn/b1.py b/campaign/event_20200423_cn/b1.py index e92f8c1ac..a302592b9 100644 --- a/campaign/event_20200423_cn/b1.py +++ b/campaign/event_20200423_cn/b1.py @@ -5,7 +5,6 @@ from module.logger import logger MAP = CampaignMap() -MAP.camera_sight = (-4, -2, 5, 3) MAP.map_data = ''' -- -- -- -- -- -- -- -- -- -- ++ ++ -- -- -- -- ++ -- @@ -25,26 +24,15 @@ class Config: MAP_HAS_FLEET_STEP = True MAP_HAS_MOVABLE_ENEMY = True MAP_HAS_SIREN = True - MAP_GRID_CENTER_TOLERANCE = 0.3 MAP_SIREN_COUNT = 2 - INTERNAL_LINES_HOUGHLINES_THRESHOLD = 50 - EDGE_LINES_HOUGHLINES_THRESHOLD = 50 - CAMERA_SWIPE_MULTIPLY_X = 200 * 0.7 - CAMERA_SWIPE_MULTIPLY_Y = 140 * 0.7 - COINCIDENT_POINT_ENCOURAGE_DISTANCE = 1. - MID_DIFF_RANGE_H = (45, 70) - MID_DIFF_RANGE_V = (97 - 3, 97 + 3) TRUST_EDGE_LINES = True - VANISH_POINT_RANGE = ((540, 740), (-4000, -2000)) - DISTANCE_POINT_X_RANGE = ((-2000, -1000),) INTERNAL_LINES_FIND_PEAKS_PARAMETERS = { 'height': (80, 255 - 40), 'width': (0.9, 10), 'prominence': 10, 'distance': 35, - 'wlen': 100, } EDGE_LINES_FIND_PEAKS_PARAMETERS = { 'height': (255 - 40, 255), @@ -54,5 +42,6 @@ class Config: } + class Campaign(CampaignBase): MAP = MAP diff --git a/campaign/event_20200423_cn/b2.py b/campaign/event_20200423_cn/b2.py index 5ceccce09..0f59f36fb 100644 --- a/campaign/event_20200423_cn/b2.py +++ b/campaign/event_20200423_cn/b2.py @@ -5,7 +5,6 @@ from module.logger import logger from campaign.event_20200423_cn.b1 import Config as ConfigBase MAP = CampaignMap() -MAP.camera_sight = (-4, -2, 5, 3) MAP.map_data = ''' -- -- -- -- SP SP -- -- ++ ++ -- -- -- -- -- -- -- -- ++ ++ diff --git a/campaign/event_20200423_cn/b3.py b/campaign/event_20200423_cn/b3.py index 605572e08..62b93b3db 100644 --- a/campaign/event_20200423_cn/b3.py +++ b/campaign/event_20200423_cn/b3.py @@ -5,7 +5,6 @@ from module.logger import logger from campaign.event_20200423_cn.b1 import Config as ConfigBase MAP = CampaignMap() -MAP.camera_sight = (-4, -2, 5, 3) MAP.map_data = ''' -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ++ ++ diff --git a/campaign/event_20200423_cn/c1.py b/campaign/event_20200423_cn/c1.py new file mode 100644 index 000000000..79c57dc45 --- /dev/null +++ b/campaign/event_20200423_cn/c1.py @@ -0,0 +1,47 @@ +from module.campaign.campaign_base import CampaignBase +from module.map.map_base import CampaignMap +from module.map.map_grids import SelectedGrids, RoadGrids +from module.logger import logger + + +MAP = CampaignMap() +MAP.map_data = ''' + -- -- -- -- -- -- -- -- -- + -- -- -- -- -- -- -- -- -- + -- -- -- ++ ++ -- ++ -- -- + -- -- -- ++ ++ -- -- -- -- + SP -- -- -- -- -- -- ++ -- + SP SP -- -- -- -- -- ++ -- +''' + + +class Config: + SUBMARINE = 0 + FLEET_BOSS = 1 + + POOR_MAP_DATA = True + MAP_HAS_AMBUSH = False + MAP_HAS_FLEET_STEP = True + MAP_HAS_MOVABLE_ENEMY = True + MAP_HAS_SIREN = True + MAP_HAS_DYNAMIC_RED_BORDER = True + MAP_SIREN_COUNT = 2 + + TRUST_EDGE_LINES = True + + INTERNAL_LINES_FIND_PEAKS_PARAMETERS = { + 'height': (80, 255 - 40), + 'width': (0.9, 10), + 'prominence': 10, + 'distance': 35, + } + EDGE_LINES_FIND_PEAKS_PARAMETERS = { + 'height': (255 - 40, 255), + 'prominence': 10, + 'distance': 50, + 'wlen': 1000 + } + + +class Campaign(CampaignBase): + MAP = MAP diff --git a/campaign/event_20200423_cn/c2.py b/campaign/event_20200423_cn/c2.py new file mode 100644 index 000000000..ce688b853 --- /dev/null +++ b/campaign/event_20200423_cn/c2.py @@ -0,0 +1,20 @@ +from module.campaign.campaign_base import CampaignBase +from module.map.map_base import CampaignMap +from module.map.map_grids import SelectedGrids, RoadGrids +from module.logger import logger +from campaign.event_20200423_cn.c1 import Config + +MAP = CampaignMap() +MAP.map_data = ''' + -- -- -- -- -- -- -- + -- -- -- ++ ++ ++ -- + -- -- -- -- -- -- -- + -- -- ++ -- -- -- -- + -- -- -- -- -- -- -- + SP -- -- -- -- ++ -- + SP SP -- -- -- ++ -- +''' + + +class Campaign(CampaignBase): + MAP = MAP diff --git a/campaign/event_20200423_cn/c3.py b/campaign/event_20200423_cn/c3.py new file mode 100644 index 000000000..9f3237805 --- /dev/null +++ b/campaign/event_20200423_cn/c3.py @@ -0,0 +1,20 @@ +from module.campaign.campaign_base import CampaignBase +from module.map.map_base import CampaignMap +from module.map.map_grids import SelectedGrids, RoadGrids +from module.logger import logger +from campaign.event_20200423_cn.c1 import Config + +MAP = CampaignMap() +MAP.map_data = ''' + SP SP -- -- -- -- -- -- -- + SP -- -- -- ++ ++ ++ -- -- + -- -- -- -- -- -- -- -- -- + -- ++ -- -- -- -- -- -- -- + -- ++ -- -- ++ ++ -- -- -- + -- -- -- -- -- -- -- ++ ++ + -- -- -- -- -- -- -- ++ ++ +''' + + +class Campaign(CampaignBase): + MAP = MAP diff --git a/campaign/event_20200423_cn/d1.py b/campaign/event_20200423_cn/d1.py new file mode 100644 index 000000000..16e592bc4 --- /dev/null +++ b/campaign/event_20200423_cn/d1.py @@ -0,0 +1,46 @@ +from module.campaign.campaign_base import CampaignBase +from module.map.map_base import CampaignMap +from module.map.map_grids import SelectedGrids, RoadGrids +from module.logger import logger + + +MAP = CampaignMap() +MAP.map_data = ''' + -- -- -- -- -- -- -- -- -- + -- ++ ++ -- -- -- -- ++ -- + -- -- -- -- -- -- -- -- -- + -- -- ++ ++ ++ -- -- -- -- + -- -- -- -- -- -- -- -- -- + ++ ++ -- -- -- -- ++ -- -- + ++ ++ SP SP -- -- ++ -- -- +''' + + +class Config: + SUBMARINE = 0 + FLEET_BOSS = 2 + POOR_MAP_DATA = True + MAP_HAS_AMBUSH = False + MAP_HAS_FLEET_STEP = True + MAP_HAS_MOVABLE_ENEMY = True + MAP_HAS_SIREN = True + MAP_SIREN_COUNT = 3 + + TRUST_EDGE_LINES = True + + INTERNAL_LINES_FIND_PEAKS_PARAMETERS = { + 'height': (80, 255 - 40), + 'width': (0.9, 10), + 'prominence': 10, + 'distance': 35, + } + EDGE_LINES_FIND_PEAKS_PARAMETERS = { + 'height': (255 - 40, 255), + 'prominence': 10, + 'distance': 50, + 'wlen': 1000 + } + + +class Campaign(CampaignBase): + MAP = MAP diff --git a/campaign/event_20200423_cn/d2.py b/campaign/event_20200423_cn/d2.py new file mode 100644 index 000000000..caa0b1993 --- /dev/null +++ b/campaign/event_20200423_cn/d2.py @@ -0,0 +1,24 @@ +from module.campaign.campaign_base import CampaignBase +from module.map.map_base import CampaignMap +from module.map.map_grids import SelectedGrids, RoadGrids +from module.logger import logger +from campaign.event_20200423_cn.d1 import Config as ConfigBase + +MAP = CampaignMap() +MAP.map_data = ''' + -- -- -- -- SP SP -- -- ++ ++ + -- -- -- -- -- -- -- -- ++ ++ + ++ ++ ++ -- -- -- -- -- -- -- + -- -- -- -- ++ ++ -- -- -- -- + -- -- -- -- -- -- -- -- -- -- + -- ++ -- -- -- -- ++ -- -- -- + -- ++ -- -- -- -- -- -- -- -- +''' + + +class Config(ConfigBase): + FLEET_BOSS = 2 + + +class Campaign(CampaignBase): + MAP = MAP diff --git a/campaign/event_20200423_cn/d3.py b/campaign/event_20200423_cn/d3.py new file mode 100644 index 000000000..870572401 --- /dev/null +++ b/campaign/event_20200423_cn/d3.py @@ -0,0 +1,24 @@ +from module.campaign.campaign_base import CampaignBase +from module.map.map_base import CampaignMap +from module.map.map_grids import SelectedGrids, RoadGrids +from module.logger import logger +from campaign.event_20200423_cn.d1 import Config as ConfigBase + +MAP = CampaignMap() +MAP.map_data = ''' + -- -- -- -- -- -- -- -- -- + -- -- -- -- -- -- -- ++ ++ + ++ ++ -- -- ++ ++ -- -- -- + -- -- -- -- ++ ++ -- -- SP + ++ ++ -- -- -- -- -- -- SP + -- -- -- -- -- -- -- ++ -- + -- -- ++ ++ ++ -- -- -- -- +''' + + +class Config(ConfigBase): + FLEET_BOSS = 2 + + +class Campaign(CampaignBase): + MAP = MAP diff --git a/module/device/control.py b/module/device/control.py index d27822784..40e4379ff 100644 --- a/module/device/control.py +++ b/module/device/control.py @@ -66,7 +66,7 @@ class Control(Connection): # @retry() def _click_uiautomator2(self, x, y): - self.device.click(x, y) + self.device.click(int(x), int(y)) # @retry() def _click_adb(self, x, y): diff --git a/module/map/fleet.py b/module/map/fleet.py index c6fe7663b..d57de7ce6 100644 --- a/module/map/fleet.py +++ b/module/map/fleet.py @@ -190,7 +190,9 @@ class Fleet(Camera, MapOperation, AmbushHandler): logger.info(f'Carrier spawn: {diff}') elif self.config.POOR_MAP_DATA: for grid in self.map: - grid.wipe_out() + grid.reset() + if result == 'combat': + self.ensure_edge_insight() self.full_scan() self.find_path_initial() diff --git a/module/map/grid_predictor.py b/module/map/grid_predictor.py index 796df7797..762c7636e 100644 --- a/module/map/grid_predictor.py +++ b/module/map/grid_predictor.py @@ -38,9 +38,9 @@ class GridPredictor: 0, # g ((-x0 + x1) / (-x2 + x3) - 1) / self.ENEMY_PERSPECTIVE_IMAGE_SIZE[1] # h ) - self.image_transform = self.image.transform(self.ENEMY_PERSPECTIVE_IMAGE_SIZE, Image.PERSPECTIVE, self._perspective) def predict(self): + self.image_transform = self.image.transform(self.ENEMY_PERSPECTIVE_IMAGE_SIZE, Image.PERSPECTIVE, self._perspective) # self.image_hole = self.get_relative_image((-1, -1, 1, 1)) self.is_enemy = self.predict_static_red_border() diff --git a/module/map/map.py b/module/map/map.py index 333239923..66f41a466 100644 --- a/module/map/map.py +++ b/module/map/map.py @@ -238,7 +238,7 @@ class Map(Fleet): logger.hr('Clear BOSS') grids = grids.sort(cost=True, weight=True) logger.info('Grids: %s' % str(grids)) - self.clear_chosen_enemy(grids[0], expected='boss') + self.clear_chosen_enemy(grids[0]) logger.warning('BOSS not detected, trying all boss spawn point.') self.clear_potential_boss() diff --git a/module/map/perspective.py b/module/map/perspective.py index b3ad08ead..32e82d6f1 100644 --- a/module/map/perspective.py +++ b/module/map/perspective.py @@ -82,6 +82,8 @@ class Perspective: self.vanish_point = optimize.brute(self._vanish_point_value, self.config.VANISH_POINT_RANGE) distance_point_x = optimize.brute(self._distant_point_value, self.config.DISTANCE_POINT_X_RANGE)[0] self.distant_point = np.array([distance_point_x, self.vanish_point[1]]) + logger.info(f' vanish_point: ({", ".join([str(int(x)).rjust(5) for x in self.vanish_point])})') + logger.info(f' distant_point: ({", ".join([str(int(x)).rjust(5) for x in self.distant_point])})') # Re-generate lines. Useless after mid_cleanse function added. # self.horizontal = self.crossings.link(None, is_horizontal=True).group()