Funkcje traktora zwracają suckes lub porażkę
This commit is contained in:
parent
4138753bb0
commit
bb09620196
@ -1,4 +1,5 @@
|
||||
# import tensorflow
|
||||
# import keras
|
||||
import numpy
|
||||
|
||||
class main():
|
||||
def __init__(self,traktor,field,ui,path):
|
||||
|
2
main.py
2
main.py
@ -2,7 +2,7 @@ import pygame, sys
|
||||
import tractor,pathfinding,field,ui,Justyna,Kamila,Marcin,Piotrek
|
||||
from pygame.locals import *
|
||||
|
||||
pole = field.field(1)
|
||||
pole = field.field()
|
||||
path = pathfinding.pathfinding()
|
||||
traktor = tractor.tractor(pole)
|
||||
UI = ui.game_ui(traktor,pole)
|
||||
|
38
tractor.py
38
tractor.py
@ -60,73 +60,85 @@ class tractor():
|
||||
|
||||
def move_left(self):
|
||||
if self.poz[0] == 0:
|
||||
pass
|
||||
return 0
|
||||
else:
|
||||
self.set_poz([-1,0])
|
||||
self.set_poz_on_screen([-70,0])
|
||||
print("Ruch w lewo")
|
||||
self.set_turn(1)
|
||||
self.moves_up()
|
||||
return 1
|
||||
|
||||
def move_up(self):
|
||||
if self.poz[1] == 0:
|
||||
pass
|
||||
return 0
|
||||
else:
|
||||
self.set_poz([0, -1])
|
||||
self.set_poz_on_screen([0, -70])
|
||||
print("Ruch w górę")
|
||||
self.set_turn(2)
|
||||
self.moves_up()
|
||||
return 1
|
||||
|
||||
def move_right(self):
|
||||
if self.poz[0] == 9:
|
||||
pass
|
||||
return 0
|
||||
else:
|
||||
self.set_poz([1, 0])
|
||||
self.set_poz_on_screen([70, 0])
|
||||
self.set_turn(3)
|
||||
print("Ruch w prawo")
|
||||
self.moves_up()
|
||||
return 1
|
||||
|
||||
def move_down(self):
|
||||
if self.poz[1] == 9:
|
||||
pass
|
||||
return 0
|
||||
else:
|
||||
self.set_poz([0, 1])
|
||||
self.set_poz_on_screen([0, 70])
|
||||
self.set_turn(0)
|
||||
print("Ruch w dół")
|
||||
self.moves_up()
|
||||
return 1
|
||||
|
||||
def work(self):
|
||||
if self.get_mode() == 0:
|
||||
self.water()
|
||||
print("Podlanie pola")
|
||||
return (self.water())
|
||||
|
||||
if self.get_mode() == 1:
|
||||
self.weeds()
|
||||
print("Odchwaszczenie pola")
|
||||
return (self.weeds())
|
||||
|
||||
if self.get_mode() == 2:
|
||||
self.plant()
|
||||
print("Zasadzenie pola")
|
||||
return (self.plant())
|
||||
|
||||
if self.get_mode() == 3:
|
||||
self.harvest()
|
||||
print("Zbiory z pola")
|
||||
return (self.harvest())
|
||||
|
||||
def water(self):
|
||||
if self.field.get_value(self.poz) in [0, 1, 2, 3]:
|
||||
print("Podlanie pola")
|
||||
self.field.change_value(self.poz,4)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
def weeds(self):
|
||||
if self.field.get_value(self.poz) in [1, 3, 5, 7]:
|
||||
print("Odchwaszczenie pola")
|
||||
self.field.change_value(self.poz,-1)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
def plant(self):
|
||||
if self.field.get_value(self.poz) in [0, 1, 4, 5]:
|
||||
print("Zasadzenie pola")
|
||||
self.field.change_value(self.poz,2)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
def harvest(self):
|
||||
if self.field.get_value(self.poz) == 8:
|
||||
self.field.change_value(self.poz,-8)
|
||||
self.field.change_value(self.poz,-8)
|
||||
print("Zbiory z pola")
|
||||
return 1
|
||||
return 0
|
Loading…
Reference in New Issue
Block a user