added requirements.txt

This commit is contained in:
jedryb 2022-06-05 12:53:56 +02:00
parent 2cf7573a57
commit 921aeec597
5 changed files with 16 additions and 8 deletions

4
assets/cnn_model/assets/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

View File

@ -2,10 +2,12 @@ import pygame
import warnings import warnings
warnings.simplefilter(action='ignore', category=FutureWarning) warnings.simplefilter(action='ignore', category=FutureWarning)
from src.utils.xgb_model import XgbModel from src.utils.xgb_model import XgbModel
from src.utils.cnn_model import CnnModel
from src.world import World from src.world import World
from src.tractor import Tractor from src.tractor import Tractor
from src.settings import Settings from src.settings import Settings
from src.utils.bfs import BFSSearcher from src.utils.bfs import BFSSearcher
from src.utils.astar import a_star_search
from src.constants import Constants as C from src.constants import Constants as C
from utils.display_info import display_tile_info from utils.display_info import display_tile_info
@ -17,6 +19,8 @@ def main():
settings = Settings() settings = Settings()
xgb_model = XgbModel() xgb_model = XgbModel()
world = World(settings, xgb_model) world = World(settings, xgb_model)
cnn_model = CnnModel(world)
cnn_model.init_model()
tractor = Tractor("Spalinowy", "Nawóz 1", settings, 0 * settings.tile_size, 0 * settings.tile_size, C.RIGHT) tractor = Tractor("Spalinowy", "Nawóz 1", settings, 0 * settings.tile_size, 0 * settings.tile_size, C.RIGHT)
plants_to_water = [tile for tile in world.tiles if tile.to_water == 1] plants_to_water = [tile for tile in world.tiles if tile.to_water == 1]
clock = pygame.time.Clock() # FPS purpose clock = pygame.time.Clock() # FPS purpose
@ -30,7 +34,7 @@ def main():
cords_idx = tractor.find_nearest_cords(tractor.curr_position, goals) cords_idx = tractor.find_nearest_cords(tractor.curr_position, goals)
end_cords = goals[cords_idx] end_cords = goals[cords_idx]
start_dir = tractor.curr_direction start_dir = tractor.curr_direction
path = BFSSearcher().search(start_cords, end_cords, start_dir) path = a_star_search(start_cords, end_cords, start_dir, world)
run = True run = True
while run: while run:
@ -56,7 +60,7 @@ def main():
cords_idx = tractor.find_nearest_cords(tractor.curr_position, goals) cords_idx = tractor.find_nearest_cords(tractor.curr_position, goals)
end_cords = goals[cords_idx] end_cords = goals[cords_idx]
start_dir = tractor.curr_direction start_dir = tractor.curr_direction
path = BFSSearcher().search(start_cord, end_cords, start_dir) path = a_star_search(start_cord, end_cords, start_dir, world)
pygame.time.wait(settings.freeze_time) pygame.time.wait(settings.freeze_time)
pygame.display.update() pygame.display.update()

BIN
requirements.txt Normal file

Binary file not shown.

View File

@ -27,22 +27,22 @@ class Tractor(Sprite):
self.curr_direction = C.RIGHT self.curr_direction = C.RIGHT
self.image = pygame.transform.scale( self.image = pygame.transform.scale(
pygame.image.load('assets/images/tractor/tractor-transparent-right.png'), pygame.image.load('assets/images/tractor/tractor-transparent-right.png'),
(self.settings.tile_size, self.settings.tile_size)) (self.settings.tile_size - 1, self.settings.tile_size - 1))
elif self.curr_direction == C.RIGHT: elif self.curr_direction == C.RIGHT:
self.curr_direction = C.DOWN self.curr_direction = C.DOWN
self.image = pygame.transform.scale( self.image = pygame.transform.scale(
pygame.image.load('assets/images/tractor/tractor-transparent-down.png'), pygame.image.load('assets/images/tractor/tractor-transparent-down.png'),
(self.settings.tile_size, self.settings.tile_size)) (self.settings.tile_size - 1, self.settings.tile_size - 1))
elif self.curr_direction == C.DOWN: elif self.curr_direction == C.DOWN:
self.curr_direction = C.LEFT self.curr_direction = C.LEFT
self.image = pygame.transform.scale( self.image = pygame.transform.scale(
pygame.image.load('assets/images/tractor/tractor-transparent-left.png'), pygame.image.load('assets/images/tractor/tractor-transparent-left.png'),
(self.settings.tile_size, self.settings.tile_size)) (self.settings.tile_size - 1, self.settings.tile_size - 1))
elif self.curr_direction == C.LEFT: elif self.curr_direction == C.LEFT:
self.curr_direction = C.UP self.curr_direction = C.UP
self.image = pygame.transform.scale( self.image = pygame.transform.scale(
pygame.image.load('assets/images/tractor/tractor-transparent-up.png'), pygame.image.load('assets/images/tractor/tractor-transparent-up.png'),
(self.settings.tile_size, self.settings.tile_size)) (self.settings.tile_size - 1, self.settings.tile_size - 1))
pygame.time.wait(self.settings.freeze_time) # bez tego sie kreci jak hot-wheels pygame.time.wait(self.settings.freeze_time) # bez tego sie kreci jak hot-wheels

View File

@ -38,7 +38,7 @@ class World:
for tile in row: for tile in row:
if tile == 1: if tile == 1:
type = 'farm' # type farm mówimy nam ogólnie, ze jest to pole uprawne, szczegóły rośliny potem type = 'farm' # type farm mówimy nam ogólnie, ze jest to pole uprawne, szczegóły rośliny potem
cost = 0 cost = 100000
stan_nawodnienia = self.model.df.iloc[df_idx]['stan_nawodnienia'] stan_nawodnienia = self.model.df.iloc[df_idx]['stan_nawodnienia']
rodzaj_gleby = self.model.df.iloc[df_idx]['rodzaj_gleby'] rodzaj_gleby = self.model.df.iloc[df_idx]['rodzaj_gleby']
stan_nawiezienia = self.model.df.iloc[df_idx]['stan_nawiezienia'] stan_nawiezienia = self.model.df.iloc[df_idx]['stan_nawiezienia']
@ -68,7 +68,7 @@ class World:
elif tile == 0: elif tile == 0:
img = pygame.transform.scale(self.rock, (self.settings.tile_size, self.settings.tile_size)) img = pygame.transform.scale(self.rock, (self.settings.tile_size, self.settings.tile_size))
type = 'rock' # podobnie j.w., na polu rock nie mamy upraw type = 'rock' # podobnie j.w., na polu rock nie mamy upraw
cost = 100 cost = 1
stan_nawodnienia = None stan_nawodnienia = None
rodzaj_gleby = None rodzaj_gleby = None