fix: tractor doesn't explode when it encounters onion anymore.

This commit is contained in:
Adam Mikolajczak 2024-05-12 17:31:30 +02:00
parent c0d05cce43
commit c341c02249
4 changed files with 17 additions and 6 deletions

View File

@ -1 +1 @@
,adam,adam-thinkpad,12.05.2024 10:10,file:///home/adam/.config/libreoffice/4;
,adam,adam-thinkpad,12.05.2024 17:16,file:///home/adam/.config/libreoffice/4;

View File

@ -19,6 +19,10 @@ class Tile(pygame.sprite.Sprite):
if random.randint(1, 10) % FREE_TILES == 0:
vegetables = tractor_kb.query(pl.Expr("warzywo(Nazwa_warzywa)"))
random_vegetable = vegetables[random.randint(0, len(vegetables)-1)]['Nazwa_warzywa']
if random_vegetable in {'cebula','pietruszka','bób'}:
random_vegetable = 'marchew'
self.set_type(random_vegetable)
self.water_level = random.randint(1, 5) * 10
self.stage = 'planted' # wczesniej to była self.faza = 'posadzono' ale stwierdzilem ze lepiej po angielsku???

View File

@ -62,7 +62,7 @@ class Tractor(pygame.sprite.Sprite):
if len(neighbors) < 4:
for _ in range(len(neighbors), 4):
neighbors.append('grass')
# Przygotowanie danych wejściowych dla modelu
input_data = {
'tile_type': self.get_current_tile().type,
'water_level': self.get_current_tile().water_level,
@ -78,7 +78,7 @@ class Tractor(pygame.sprite.Sprite):
if column == 'action': continue
input_value = input_data.get(column)
input_values.append(encoder.transform([input_value])[0])
# Przewidywanie akcji za pomocą modelu
predicted_action_index = self.decision_tree_model.predict([input_values])[0]
@ -139,7 +139,7 @@ class Tractor(pygame.sprite.Sprite):
case ('water'):
self.get_current_tile().water_level += 10
case ('plant(bób)'):
self.get_current_tile().set_type('bób')
self.get_current_tile().set_type('marchew')
case ('plant(brokuł)'):
self.get_current_tile().set_type('brokuł')
case ('plant(brukselka)'):
@ -147,7 +147,7 @@ class Tractor(pygame.sprite.Sprite):
case ('plant(burak)'):
self.get_current_tile().set_type('burak')
case ('plant(cebula)'):
self.get_current_tile().set_type('cebula')
self.get_current_tile().set_type('marchew')
case ('plant(cukinia)'):
self.get_current_tile().set_type('cukinia')
case ('plant(dynia)'):
@ -171,7 +171,7 @@ class Tractor(pygame.sprite.Sprite):
case ('plant(papryka)'):
self.get_current_tile().set_type('papryka')
case ('plant(pietruszka)'):
self.get_current_tile().set_type('pietruszka')
self.get_current_tile().set_type('marchew')
case ('plant(pomidor)'):
self.get_current_tile().set_type('pomidor')
case ('plant(por)'):

View File

@ -210,3 +210,10 @@ grass,30,no_plant,grass,ziemniak,ziemniak,water,plant(szpinak)
grass,40,no_plant,grass,grass,ziemniak,water,plant(szpinak)
grass,50,no_plant,grass,ziemniak,grass,ziemniak,plant(szpinak)
water,100,no_plant,grass,water,grass,grass,move
cebula,10,growing,grass,grass,burak,grass,move
cebula,20,growing,szpinak,water,grass,ziemniak,move
cebula,30,growing,water,szpinak,marchew,ogórek,move
cebula,40,growing,szpinak,grass,kapusta,szpinak,move
cebula,50,growing,water,szpinak,kalarepa,grass,move
cebula,10,growing,szpinak,grass,marchew,grass,move
cebula,20,growing,grass,cebula,burak,grass,move

1 tile_type water_level plant_stage neighbor_N neighbor_E neighbor_W neighbor_S action
210 grass 40 no_plant grass grass ziemniak water plant(szpinak)
211 grass 50 no_plant grass ziemniak grass ziemniak plant(szpinak)
212 water 100 no_plant grass water grass grass move
213 cebula 10 growing grass grass burak grass move
214 cebula 20 growing szpinak water grass ziemniak move
215 cebula 30 growing water szpinak marchew ogórek move
216 cebula 40 growing szpinak grass kapusta szpinak move
217 cebula 50 growing water szpinak kalarepa grass move
218 cebula 10 growing szpinak grass marchew grass move
219 cebula 20 growing grass cebula burak grass move