code refactor
This commit is contained in:
parent
85993ddec5
commit
7a39af0081
@ -1,6 +1,5 @@
|
|||||||
#anti-personnel mine
|
from mine import Mine
|
||||||
from src.mine import Mine
|
|
||||||
|
|
||||||
|
|
||||||
class AP_Mine(Mine):
|
class APMine(Mine):
|
||||||
pass
|
pass
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#anti-tank mine
|
from mine import Mine
|
||||||
from src.mine import Mine
|
|
||||||
|
|
||||||
|
|
||||||
class AT_Mine(Mine):
|
class ATMine(Mine):
|
||||||
pass
|
pass
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
from typing import List
|
from typing import List
|
||||||
from random import choices
|
from random import choices
|
||||||
from fieldsFactory import FieldsFactory
|
|
||||||
from field import Field
|
from field import Field
|
||||||
|
from fieldsFactory import FieldsFactory
|
||||||
|
|
||||||
|
|
||||||
def generate_field () -> List[List[Field]]:
|
def generate_field () -> List[List[Field]]:
|
||||||
fieldsFactory = FieldsFactory()
|
fields_factory = FieldsFactory()
|
||||||
fieldsList = fieldsFactory.getFieldsList()
|
fields_list = fields_factory.get_fields_list()
|
||||||
return [choices(fieldsList, weights=[10, 10, 4, 4, 4, 4, 4, 4, 4, 4, 4], k=10) for _ in range(10)]
|
return [choices(fields_list, weights=[10, 10, 4, 4, 4, 4, 4, 4, 4, 4, 4], k=10) for _ in range(10)]
|
||||||
|
|
||||||
|
|
||||||
class Environment:
|
class Environment:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
class Field:
|
class Field:
|
||||||
def __init__(self, number, isMined):
|
def __init__(self, number: int, is_mined: bool):
|
||||||
self.number = number
|
self.number = number
|
||||||
self.isMined = isMined
|
self.is_mined = is_mined
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from field import Field
|
from field import Field
|
||||||
|
|
||||||
|
|
||||||
class FieldsFactory:
|
class FieldsFactory:
|
||||||
def createField(self, number) -> Field:
|
def create_field(self, number: int) -> Field:
|
||||||
if number > 3:
|
if number > 3:
|
||||||
return Field(number, True)
|
return Field(number, True)
|
||||||
else:
|
else:
|
||||||
return Field(number, False)
|
return Field(number, False)
|
||||||
|
|
||||||
def getFieldsList(self) -> List[Field]:
|
def get_fields_list(self) -> List[Field]:
|
||||||
return [self.createField(i) for i in range(11)]
|
return [self.create_field(i) for i in range(11)]
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
class Mine:
|
class Mine:
|
||||||
def __init__(self, isArmed):
|
def __init__(self, is_armed: bool):
|
||||||
self.isArmed = isArmed
|
self.is_armed = is_armed
|
||||||
|
Loading…
Reference in New Issue
Block a user