fix choices range and weights, change defusing the condition

This commit is contained in:
matixezor 2021-03-16 20:50:53 +01:00
parent 62af2ec7f4
commit d664576a22
2 changed files with 4 additions and 4 deletions

View File

@ -3,7 +3,7 @@ from random import choices
def generate_field() -> List[List[int]]: def generate_field() -> List[List[int]]:
return [choices(range(9), weights=[8, 8, 4, 4, 4, 4, 4, 4, 4], k=10) for _ in range(10)] return [choices(range(11), weights=[10, 10, 4, 4, 4, 4, 4, 4, 4, 4, 4], k=10) for _ in range(10)]
class Environment: class Environment:

View File

@ -1,9 +1,9 @@
import pygame as pg import pygame as pg
from const import ICON
from agent import Agent from agent import Agent
from game_ui import GameUi from game_ui import GameUi
from environment import Environment from environment import Environment
from const import ICON, IMAGES_MAPPING
def main(): def main():
@ -31,8 +31,8 @@ def main():
elif event.key == pg.K_w and agent.y*80 > 0: elif event.key == pg.K_w and agent.y*80 > 0:
game_ui.move('y', -1) game_ui.move('y', -1)
elif event.key == pg.K_SPACE: elif event.key == pg.K_SPACE:
if env.field[agent.y][agent.x] in [2, 3]: if env.field[agent.y][agent.x] > 3:
env.field[agent.y][agent.x] -= 2 env.field[agent.y][agent.x] = IMAGES_MAPPING[env.field[agent.y][agent.x]]
game_ui.update() game_ui.update()