Route_planning_bfs #2
Binary file not shown.
@ -2,7 +2,7 @@
|
||||
import pygame
|
||||
import random
|
||||
|
||||
from area.constants import WIDTH,HEIGHT,FIELD_WIDTH,FIELD_HEIGHT,TILE_SIZE,GREY,ROWS,COLS
|
||||
from area.constants import WIDTH,FIELD_WIDTH,TILE_SIZE,GREY,ROWS,COLS
|
||||
from tile import Tile
|
||||
from ground import Dirt
|
||||
|
||||
@ -47,27 +47,6 @@ def drawWindow(win):
|
||||
pygame.display.flip()
|
||||
|
||||
|
||||
#experimental:
|
||||
# def update_tiles(win, tractor):
|
||||
# tiles = createTiles()
|
||||
# for tile in tiles:
|
||||
# if tile.x == tractor.previous_x and tile.y == tractor.previous_y:
|
||||
# tile.x = tractor.x
|
||||
# tile.y = tractor.y
|
||||
|
||||
# if tile.image is not None:
|
||||
# new_tile = Tile(tile.x, tile.y)
|
||||
# new_tile.image = tile.image
|
||||
|
||||
|
||||
# tiles.append(new_tile)
|
||||
|
||||
# image = pygame.image.load(tile.image).convert()
|
||||
# image = pygame.transform.scale(image, (TILE_SIZE, TILE_SIZE))
|
||||
# win.blit(image, (tile.x + fieldX-1, tile.y + fieldY-1))
|
||||
|
||||
|
||||
|
||||
def get_tile_coordinates(index):
|
||||
if index < len(tiles):
|
||||
tile = tiles[index]
|
||||
|
@ -1,5 +1,5 @@
|
||||
from crop_protection_product import CropProtectionProduct
|
||||
from area.constants import TILE_SIZE, DIRECTION_EAST, DIRECTION_SOUTH, DIRECTION_WEST, DIRECTION_NORTH, FIELD_WIDTH, FIELD_HEIGHT, WIDTH, HEIGHT
|
||||
from area.constants import TILE_SIZE, DIRECTION_EAST, DIRECTION_SOUTH, DIRECTION_WEST, DIRECTION_NORTH
|
||||
from area.field import fieldX, fieldY, tiles
|
||||
import pygame
|
||||
import time
|
||||
|
@ -1,6 +1,4 @@
|
||||
from queue import Queue
|
||||
from area.constants import DIRECTION_EAST, DIRECTION_WEST, DIRECTION_NORTH, DIRECTION_SOUTH, TILE_SIZE
|
||||
from area.field import get_tile_coordinates, tiles, fieldX, fieldY
|
||||
from area.constants import TILE_SIZE
|
||||
import copy
|
||||
from area.tractor import Tractor
|
||||
|
||||
@ -75,14 +73,6 @@ class Node:
|
||||
|
||||
def copy(self):
|
||||
return copy.copy(self)
|
||||
|
||||
#State:
|
||||
def get_state(self):
|
||||
x = self.get_x()
|
||||
y = self.get_y()
|
||||
direct = self.get_direction()
|
||||
state = (x, y, direct)
|
||||
return state #returns state as a tuple (x,y,direction)
|
||||
|
||||
|
||||
def goal_test(elem, goalstate):
|
||||
@ -90,6 +80,9 @@ def goal_test(elem, goalstate):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
#State as a tuple (x,y,direction)
|
||||
|
||||
#actions(string): move, rotate_to_left, rotate_to_right
|
||||
|
||||
@ -167,8 +160,7 @@ def succ(elem, tractor):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#returns list of actions
|
||||
def get_moves(elem):
|
||||
move_list = []
|
||||
while (elem.get_parent() != None):
|
||||
@ -177,7 +169,3 @@ def get_moves(elem):
|
||||
move_list.reverse()
|
||||
return move_list
|
||||
|
||||
|
||||
|
||||
|
||||
#Testy
|
||||
|
@ -2,7 +2,7 @@ import pygame
|
||||
import time
|
||||
import random
|
||||
|
||||
from area.constants import WIDTH, HEIGHT, TILE_SIZE, GREY
|
||||
from area.constants import WIDTH, HEIGHT, TILE_SIZE
|
||||
from area.field import drawWindow
|
||||
from area.tractor import Tractor, do_actions
|
||||
from area.field import tiles, fieldX, fieldY
|
||||
@ -35,9 +35,10 @@ def main():
|
||||
|
||||
|
||||
#graphsearch activation:
|
||||
istate = Istate(170, 100, 2)
|
||||
goaltest = []
|
||||
goaltest.append(tile_x)
|
||||
istate = Istate(170, 100, 2) #initial state
|
||||
|
||||
goaltest = []
|
||||
goaltest.append(tile_x) #final state (consists of x and y because direction doesnt matter)
|
||||
goaltest.append(tile_y)
|
||||
|
||||
tractor = Tractor(0*TILE_SIZE, 0*TILE_SIZE, 2, None, None)
|
||||
@ -65,7 +66,7 @@ def main():
|
||||
d1.pests_and_weeds()
|
||||
tile1.ground=d1
|
||||
|
||||
#movement based on route-planning test:
|
||||
#movement based on route-planning (test):
|
||||
|
||||
tractor.draw_tractor(WIN)
|
||||
time.sleep(1)
|
||||
@ -77,9 +78,4 @@ def main():
|
||||
print("\n")
|
||||
|
||||
|
||||
|
||||
|
||||
# in loop move tractor:
|
||||
|
||||
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user