modify factory and env to use new images
This commit is contained in:
parent
84b7ae9b9c
commit
9ded9c43a2
@ -8,7 +8,12 @@ from tilesFactory import TilesFactory
|
|||||||
def generate_field() -> List[List[Tile]]:
|
def generate_field() -> List[List[Tile]]:
|
||||||
tiles_factory = TilesFactory()
|
tiles_factory = TilesFactory()
|
||||||
tiles_list = tiles_factory.get_tiles_list()
|
tiles_list = tiles_factory.get_tiles_list()
|
||||||
return [choices(tiles_list, weights=[10, 10, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4], k=10) for _ in range(10)]
|
return [choices(
|
||||||
|
tiles_list,
|
||||||
|
weights=[20, 20] + [4 for _ in range(5)] + [10 for _ in range(9)] + [3 for _ in range(18)],
|
||||||
|
k=10)
|
||||||
|
for _ in range(10)
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class Environment:
|
class Environment:
|
||||||
|
@ -4,12 +4,13 @@ from importlib import import_module
|
|||||||
|
|
||||||
from tile import Tile
|
from tile import Tile
|
||||||
from const import IMAGES
|
from const import IMAGES
|
||||||
from machine_learning.data_set import visibility, stability, ground, armed
|
from machine_learning.data_set import visibility, stability, armed
|
||||||
|
|
||||||
|
|
||||||
class TilesFactory:
|
class TilesFactory:
|
||||||
def create_tile(self, number: int) -> Tile:
|
def create_tile(self, number: int) -> Tile:
|
||||||
img = IMAGES[number]
|
img = IMAGES[number]
|
||||||
|
img_ground = img.name.split('_')[0]
|
||||||
if img.mine_type:
|
if img.mine_type:
|
||||||
module = import_module(f'{img.mine_type.lower()}_mine')
|
module = import_module(f'{img.mine_type.lower()}_mine')
|
||||||
return Tile(
|
return Tile(
|
||||||
@ -17,7 +18,7 @@ class TilesFactory:
|
|||||||
0,
|
0,
|
||||||
self.get_random_value(visibility),
|
self.get_random_value(visibility),
|
||||||
self.get_random_value(stability),
|
self.get_random_value(stability),
|
||||||
self.get_random_value(ground),
|
img_ground,
|
||||||
getattr(module, f'{img.mine_type}Mine')(
|
getattr(module, f'{img.mine_type}Mine')(
|
||||||
uniform(
|
uniform(
|
||||||
0.5,
|
0.5,
|
||||||
@ -28,20 +29,20 @@ class TilesFactory:
|
|||||||
else:
|
else:
|
||||||
return Tile(
|
return Tile(
|
||||||
number,
|
number,
|
||||||
5,
|
30,
|
||||||
self.get_random_value(visibility),
|
self.get_random_value(visibility),
|
||||||
self.get_random_value(stability),
|
self.get_random_value(stability),
|
||||||
self.get_random_value(ground)
|
img_ground
|
||||||
) if 'grass' in img.name else Tile(
|
) if 'mud' in img.name else Tile(
|
||||||
number,
|
number,
|
||||||
30,
|
5,
|
||||||
self.get_random_value(visibility),
|
self.get_random_value(visibility),
|
||||||
self.get_random_value(stability),
|
self.get_random_value(stability),
|
||||||
self.get_random_value(ground)
|
img_ground
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_tiles_list(self) -> List[Tile]:
|
def get_tiles_list(self) -> List[Tile]:
|
||||||
return [self.create_tile(i) for i in range(13)]
|
return [self.create_tile(i) for i in range(34)]
|
||||||
|
|
||||||
def get_random_value(self, values):
|
def get_random_value(self, values):
|
||||||
return choice(values)
|
return choice(values)
|
||||||
|
Loading…
Reference in New Issue
Block a user