Compare commits
No commits in common. "e0397b95a7a9880a69748df32aa57d4b2e2a1706" and "a8c5b1b434116d4cee52f88400e15bffbffc33b8" have entirely different histories.
e0397b95a7
...
a8c5b1b434
8
BFS.py
8
BFS.py
@ -1,6 +1,4 @@
|
|||||||
import random
|
import random
|
||||||
|
|
||||||
import pygame
|
|
||||||
import Node
|
import Node
|
||||||
from displayControler import NUM_X, NUM_Y
|
from displayControler import NUM_X, NUM_Y
|
||||||
|
|
||||||
@ -86,9 +84,6 @@ def BFS1(istate):
|
|||||||
x.parent = elem
|
x.parent = elem
|
||||||
x.action = resp[0]
|
x.action = resp[0]
|
||||||
fringe.append(x)
|
fringe.append(x)
|
||||||
for event in pygame.event.get():
|
|
||||||
if event.type == pygame.QUIT:
|
|
||||||
quit()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -164,9 +159,6 @@ def BFS2(istate):
|
|||||||
x.parent = elem
|
x.parent = elem
|
||||||
x.action = resp[0]
|
x.action = resp[0]
|
||||||
fringe.append(x)
|
fringe.append(x)
|
||||||
for event in pygame.event.get():
|
|
||||||
if event.type == pygame.QUIT:
|
|
||||||
quit()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
8
Image.py
8
Image.py
@ -6,7 +6,6 @@ class Image:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.plants_image_dict={}
|
self.plants_image_dict={}
|
||||||
self.tractor_image=None
|
self.tractor_image=None
|
||||||
self.garage_image=None
|
|
||||||
def load_images(self):
|
def load_images(self):
|
||||||
files_plants={0:"borowka",
|
files_plants={0:"borowka",
|
||||||
1:"kukurydza",
|
1:"kukurydza",
|
||||||
@ -20,8 +19,6 @@ class Image:
|
|||||||
self.plants_image_dict[files_plants[index]]=plant_image
|
self.plants_image_dict[files_plants[index]]=plant_image
|
||||||
tractor_image=pygame.image.load("images/traktor.png")
|
tractor_image=pygame.image.load("images/traktor.png")
|
||||||
tractor_image=pygame.transform.scale(tractor_image,(dCon.CUBE_SIZE,dCon.CUBE_SIZE))
|
tractor_image=pygame.transform.scale(tractor_image,(dCon.CUBE_SIZE,dCon.CUBE_SIZE))
|
||||||
garage=pygame.image.load("images/garage.png")
|
|
||||||
self.garage_image=pygame.transform.scale(garage,(dCon.CUBE_SIZE,dCon.CUBE_SIZE))
|
|
||||||
def return_random_plant(self):
|
def return_random_plant(self):
|
||||||
x=random.randint(0,5)
|
x=random.randint(0,5)
|
||||||
keys=list(self.plants_image_dict.keys())
|
keys=list(self.plants_image_dict.keys())
|
||||||
@ -29,7 +26,4 @@ class Image:
|
|||||||
return (plant,self.plants_image_dict[plant])
|
return (plant,self.plants_image_dict[plant])
|
||||||
|
|
||||||
def return_plant(self,plant_name):
|
def return_plant(self,plant_name):
|
||||||
return (plant_name,self.plants_image_dict[plant_name])
|
return (plant_name,self.plants_image_dict[plant_name])
|
||||||
|
|
||||||
def return_garage(self):
|
|
||||||
return self.garage_image
|
|
7
Pole.py
7
Pole.py
@ -33,18 +33,13 @@ class Pole:
|
|||||||
slot_dict=self.get_slot_dict()
|
slot_dict=self.get_slot_dict()
|
||||||
for coordinates in slot_dict:
|
for coordinates in slot_dict:
|
||||||
slot_dict[coordinates].draw()
|
slot_dict[coordinates].draw()
|
||||||
garage=self.slot_dict[(0,0)]
|
|
||||||
garage.set_garage_image()
|
|
||||||
|
|
||||||
def randomize_colors(self):
|
def randomize_colors(self):
|
||||||
pygame.display.update()
|
pygame.display.update()
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
self.ui.render_text("Randomizing Crops")
|
self.ui.render_text("Randomizing Crops")
|
||||||
for coordinates in self.slot_dict:
|
for coordinates in self.slot_dict:
|
||||||
if(coordinates==(0,0)):
|
self.slot_dict[coordinates].set_random_plant()
|
||||||
continue
|
|
||||||
else:
|
|
||||||
self.slot_dict[coordinates].set_random_plant()
|
|
||||||
|
|
||||||
def change_color_of_slot(self,coordinates,color): #Coordinates must be tuple (x,y) (left top slot has cord (0,0) ), color has to be from defined in Colors.py or custom in RGB value (R,G,B)
|
def change_color_of_slot(self,coordinates,color): #Coordinates must be tuple (x,y) (left top slot has cord (0,0) ), color has to be from defined in Colors.py or custom in RGB value (R,G,B)
|
||||||
self.get_slot_from_cord(coordinates).color_change(color)
|
self.get_slot_from_cord(coordinates).color_change(color)
|
||||||
|
14
Slot.py
14
Slot.py
@ -15,7 +15,6 @@ class Slot:
|
|||||||
self.screen=screen
|
self.screen=screen
|
||||||
self.field=pygame.Rect(self.x_axis*dCon.CUBE_SIZE,self.y_axis*dCon.CUBE_SIZE,dCon.CUBE_SIZE,dCon.CUBE_SIZE)
|
self.field=pygame.Rect(self.x_axis*dCon.CUBE_SIZE,self.y_axis*dCon.CUBE_SIZE,dCon.CUBE_SIZE,dCon.CUBE_SIZE)
|
||||||
self.image_loader=image_loader
|
self.image_loader=image_loader
|
||||||
self.garage_image=None
|
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
pygame.draw.rect(self.screen,Colors.BROWN,self.field,0) #Draw field
|
pygame.draw.rect(self.screen,Colors.BROWN,self.field,0) #Draw field
|
||||||
@ -40,11 +39,6 @@ class Slot:
|
|||||||
self.screen.blit(self.plant_image, (self.x_axis * dCon.CUBE_SIZE, self.y_axis * dCon.CUBE_SIZE))
|
self.screen.blit(self.plant_image, (self.x_axis * dCon.CUBE_SIZE, self.y_axis * dCon.CUBE_SIZE))
|
||||||
pygame.draw.rect(self.screen, Colors.BLACK, self.field, BORDER_THICKNESS)
|
pygame.draw.rect(self.screen, Colors.BLACK, self.field, BORDER_THICKNESS)
|
||||||
|
|
||||||
def set_garage_image(self):
|
|
||||||
self.plant_image=self.image_loader.return_garage()
|
|
||||||
self.screen.blit(self.plant_image, (self.x_axis * dCon.CUBE_SIZE, self.y_axis * dCon.CUBE_SIZE))
|
|
||||||
pygame.draw.rect(self.screen, Colors.BLACK, self.field, BORDER_THICKNESS)
|
|
||||||
|
|
||||||
|
|
||||||
def random_plant(self): #Probably will not be used later only for demo purpouse
|
def random_plant(self): #Probably will not be used later only for demo purpouse
|
||||||
return self.image_loader.return_random_plant()
|
return self.image_loader.return_random_plant()
|
||||||
@ -59,12 +53,4 @@ class Slot:
|
|||||||
return f"wspolrzedne: (X:{self.x_axis} Y:{self.y_axis}) "+self.plant.report_status()
|
return f"wspolrzedne: (X:{self.x_axis} Y:{self.y_axis}) "+self.plant.report_status()
|
||||||
def irrigatePlant(self):
|
def irrigatePlant(self):
|
||||||
self.plant.stan.nawodnienie = 100
|
self.plant.stan.nawodnienie = 100
|
||||||
|
|
||||||
def setHydrate(self,index):
|
|
||||||
if(index==0):
|
|
||||||
self.plant.stan.nawodnienie=random.randint(0,60)
|
|
||||||
elif(index==1):
|
|
||||||
self.plant.stan.nawodnienie=random.randint(61,100)
|
|
||||||
elif(index==-1):
|
|
||||||
pass
|
|
||||||
|
|
44
Tractor.py
44
Tractor.py
@ -6,11 +6,6 @@ import Slot
|
|||||||
import Osprzet
|
import Osprzet
|
||||||
import Node
|
import Node
|
||||||
|
|
||||||
tab = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 0, 1, 0, 1, 1,
|
|
||||||
0, 1, 0, 1, 0, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 0, 0, 0, 0, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
|
|
||||||
|
|
||||||
|
|
||||||
class Tractor:
|
class Tractor:
|
||||||
@ -18,7 +13,7 @@ class Tractor:
|
|||||||
DIRECTION_SOUTH = 'S'
|
DIRECTION_SOUTH = 'S'
|
||||||
DIRECTION_WEST = 'W'
|
DIRECTION_WEST = 'W'
|
||||||
DIRECTION_EAST = 'E'
|
DIRECTION_EAST = 'E'
|
||||||
def __init__(self,slot,screen, osprzet,clock,bfs2_flag):
|
def __init__(self,slot,screen, osprzet,clock):
|
||||||
self.tractor_images = {
|
self.tractor_images = {
|
||||||
Tractor.DIRECTION_NORTH: pygame.transform.scale(pygame.image.load('images/traktorN.png'),
|
Tractor.DIRECTION_NORTH: pygame.transform.scale(pygame.image.load('images/traktorN.png'),
|
||||||
(dCon.CUBE_SIZE, dCon.CUBE_SIZE)),
|
(dCon.CUBE_SIZE, dCon.CUBE_SIZE)),
|
||||||
@ -36,7 +31,6 @@ class Tractor:
|
|||||||
self.osprzet = osprzet
|
self.osprzet = osprzet
|
||||||
self.clock=clock
|
self.clock=clock
|
||||||
self.slot_hydrate_dict={}
|
self.slot_hydrate_dict={}
|
||||||
self.bfs2_flag=bfs2_flag
|
|
||||||
|
|
||||||
|
|
||||||
def draw_tractor(self):
|
def draw_tractor(self):
|
||||||
@ -108,30 +102,13 @@ class Tractor:
|
|||||||
self.do_move_if_valid(pole,(0,0))
|
self.do_move_if_valid(pole,(0,0))
|
||||||
|
|
||||||
def initial_move(self,pole):
|
def initial_move(self,pole):
|
||||||
if (self.bfs2_flag==True):
|
for y in range (0,dCon.NUM_Y):
|
||||||
index=0
|
if(y%2==0):
|
||||||
|
for x in range(0,dCon.NUM_X):
|
||||||
for y in range (0,dCon.NUM_Y):
|
self.snake_move(pole,x,y)
|
||||||
if(y%2==0):
|
else:
|
||||||
for x in range(0,dCon.NUM_X):
|
for x in range(dCon.NUM_X,-1,-1):
|
||||||
if(pole.is_valid_move((x,y))):
|
self.snake_move(pole,x,y)
|
||||||
pole.get_slot_from_cord((x,y)).setHydrate(tab[index])
|
|
||||||
self.snake_move(pole,x,y)
|
|
||||||
index=index+1
|
|
||||||
else:
|
|
||||||
for x in range(dCon.NUM_X,-1,-1):
|
|
||||||
if(pole.is_valid_move((x,y))):
|
|
||||||
pole.get_slot_from_cord((x,y)).setHydrate(tab[index])
|
|
||||||
self.snake_move(pole,x,y)
|
|
||||||
index=index+1
|
|
||||||
else:
|
|
||||||
for y in range (0,dCon.NUM_Y):
|
|
||||||
if(y%2==0):
|
|
||||||
for x in range(0,dCon.NUM_X):
|
|
||||||
self.snake_move(pole,x,y)
|
|
||||||
else:
|
|
||||||
for x in range(dCon.NUM_X,-1,-1):
|
|
||||||
self.snake_move(pole,x,y)
|
|
||||||
|
|
||||||
|
|
||||||
def snake_move(self,pole,x,y):
|
def snake_move(self,pole,x,y):
|
||||||
@ -178,8 +155,5 @@ class Tractor:
|
|||||||
else:
|
else:
|
||||||
print("Brak akcji przypisanych do tego sprzętu.")
|
print("Brak akcji przypisanych do tego sprzętu.")
|
||||||
def irrigateSlot(self):
|
def irrigateSlot(self):
|
||||||
try:
|
self.slot.irrigatePlant()
|
||||||
self.slot.irrigatePlant()
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
CUBE_SIZE = 64
|
CUBE_SIZE = 64
|
||||||
NUM_X = 10
|
NUM_X = 6
|
||||||
NUM_Y = 5
|
NUM_Y = 3
|
||||||
|
|
||||||
#returns true if tractor can move to specified slot
|
#returns true if tractor can move to specified slot
|
||||||
def isValidMove(x, y):
|
def isValidMove(x, y):
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 11 KiB |
Loading…
Reference in New Issue
Block a user