add random field generation
This commit is contained in:
parent
9feb4048c6
commit
9ea066a79e
@ -1,10 +1,11 @@
|
|||||||
from typing import List
|
from typing import List
|
||||||
|
from random import choices
|
||||||
|
|
||||||
from const import DEFAULT_FIELD
|
|
||||||
|
def generate_field() -> List[List[int]]:
|
||||||
|
return [choices(range(6), weights=[8, 8, 4, 4, 4, 4], k=10) for y in range(10)]
|
||||||
|
|
||||||
|
|
||||||
class Environment:
|
class Environment:
|
||||||
def __init__(self, field: List[List[int]] = DEFAULT_FIELD):
|
def __init__(self, field: List[List[int]] = None):
|
||||||
self.field = field
|
self.field = field if field else generate_field()
|
||||||
self.rows = len(field)
|
|
||||||
self.cols = len(field[0])
|
|
||||||
|
@ -3,6 +3,7 @@ import pygame
|
|||||||
from const import ICON
|
from const import ICON
|
||||||
from agent import Agent
|
from agent import Agent
|
||||||
from game_ui import GameUi
|
from game_ui import GameUi
|
||||||
|
from const import DEFAULT_FIELD
|
||||||
from environment import Environment
|
from environment import Environment
|
||||||
|
|
||||||
|
|
||||||
@ -11,7 +12,7 @@ def main():
|
|||||||
pygame.display.set_caption('Super Saper')
|
pygame.display.set_caption('Super Saper')
|
||||||
pygame.display.set_icon(pygame.image.load(ICON))
|
pygame.display.set_icon(pygame.image.load(ICON))
|
||||||
|
|
||||||
env = Environment()
|
env = Environment(DEFAULT_FIELD)
|
||||||
agent = Agent()
|
agent = Agent()
|
||||||
game_ui = GameUi(agent, env)
|
game_ui = GameUi(agent, env)
|
||||||
game_ui.update()
|
game_ui.update()
|
||||||
|
Loading…
Reference in New Issue
Block a user