mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-12 05:08:19 +08:00
Opt: Avoid importing numpy and opencv to reduce memory usage of web server process
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
import operator
|
||||
|
||||
import numpy as np
|
||||
|
||||
|
||||
class SelectedGrids:
|
||||
def __init__(self, grids):
|
||||
@@ -221,6 +219,7 @@ class SelectedGrids:
|
||||
Returns:
|
||||
SelectedGrids:
|
||||
"""
|
||||
import numpy as np
|
||||
if not self:
|
||||
return self
|
||||
location = np.array(self.location)
|
||||
@@ -239,6 +238,7 @@ class SelectedGrids:
|
||||
Returns:
|
||||
SelectedGrids:
|
||||
"""
|
||||
import numpy as np
|
||||
if not self:
|
||||
return self
|
||||
vector = np.subtract(self.location, center)
|
||||
@@ -286,9 +286,9 @@ class RoadGrids:
|
||||
"""
|
||||
grids = []
|
||||
for block in self.grids:
|
||||
if np.any([grid.is_fleet for grid in block]):
|
||||
if any([grid.is_fleet for grid in block]):
|
||||
continue
|
||||
if np.any([grid.is_cleared for grid in block]):
|
||||
if any([grid.is_cleared for grid in block]):
|
||||
continue
|
||||
if block.count - block.select(is_enemy=True).count == 1:
|
||||
grids += block.select(is_enemy=True).grids
|
||||
@@ -301,9 +301,9 @@ class RoadGrids:
|
||||
"""
|
||||
grids = []
|
||||
for block in self.grids:
|
||||
if np.any([grid.is_fleet for grid in block]):
|
||||
if any([grid.is_fleet for grid in block]):
|
||||
continue
|
||||
if np.any([grid.is_cleared for grid in block]):
|
||||
if any([grid.is_cleared for grid in block]):
|
||||
continue
|
||||
if block.select(is_enemy=True).count >= 1:
|
||||
grids += block.select(is_enemy=True).grids
|
||||
|
||||
Reference in New Issue
Block a user