removed unnecessary comments and code
This commit is contained in:
parent
75b3ca043a
commit
048a9757e5
Binary file not shown.
@ -2,7 +2,7 @@
|
|||||||
import pygame
|
import pygame
|
||||||
import random
|
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 tile import Tile
|
||||||
from ground import Dirt
|
from ground import Dirt
|
||||||
|
|
||||||
@ -47,27 +47,6 @@ def drawWindow(win):
|
|||||||
pygame.display.flip()
|
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):
|
def get_tile_coordinates(index):
|
||||||
if index < len(tiles):
|
if index < len(tiles):
|
||||||
tile = tiles[index]
|
tile = tiles[index]
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from crop_protection_product import CropProtectionProduct
|
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
|
from area.field import fieldX, fieldY, tiles
|
||||||
import pygame
|
import pygame
|
||||||
import time
|
import time
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
from queue import Queue
|
from area.constants import TILE_SIZE
|
||||||
from area.constants import DIRECTION_EAST, DIRECTION_WEST, DIRECTION_NORTH, DIRECTION_SOUTH, TILE_SIZE
|
|
||||||
from area.field import get_tile_coordinates, tiles, fieldX, fieldY
|
|
||||||
import copy
|
import copy
|
||||||
from area.tractor import Tractor
|
from area.tractor import Tractor
|
||||||
|
|
||||||
@ -76,14 +74,6 @@ class Node:
|
|||||||
def copy(self):
|
def copy(self):
|
||||||
return copy.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):
|
def goal_test(elem, goalstate):
|
||||||
if elem.get_x() == goalstate[0] and elem.get_y() == goalstate[1]:
|
if elem.get_x() == goalstate[0] and elem.get_y() == goalstate[1]:
|
||||||
@ -91,6 +81,9 @@ def goal_test(elem, goalstate):
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
#State as a tuple (x,y,direction)
|
||||||
|
|
||||||
#actions(string): move, rotate_to_left, rotate_to_right
|
#actions(string): move, rotate_to_left, rotate_to_right
|
||||||
|
|
||||||
#main search function:
|
#main search function:
|
||||||
@ -167,8 +160,7 @@ def succ(elem, tractor):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#returns list of actions
|
||||||
|
|
||||||
def get_moves(elem):
|
def get_moves(elem):
|
||||||
move_list = []
|
move_list = []
|
||||||
while (elem.get_parent() != None):
|
while (elem.get_parent() != None):
|
||||||
@ -177,7 +169,3 @@ def get_moves(elem):
|
|||||||
move_list.reverse()
|
move_list.reverse()
|
||||||
return move_list
|
return move_list
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#Testy
|
|
||||||
|
@ -2,7 +2,7 @@ import pygame
|
|||||||
import time
|
import time
|
||||||
import random
|
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.field import drawWindow
|
||||||
from area.tractor import Tractor, do_actions
|
from area.tractor import Tractor, do_actions
|
||||||
from area.field import tiles, fieldX, fieldY
|
from area.field import tiles, fieldX, fieldY
|
||||||
@ -35,9 +35,10 @@ def main():
|
|||||||
|
|
||||||
|
|
||||||
#graphsearch activation:
|
#graphsearch activation:
|
||||||
istate = Istate(170, 100, 2)
|
istate = Istate(170, 100, 2) #initial state
|
||||||
|
|
||||||
goaltest = []
|
goaltest = []
|
||||||
goaltest.append(tile_x)
|
goaltest.append(tile_x) #final state (consists of x and y because direction doesnt matter)
|
||||||
goaltest.append(tile_y)
|
goaltest.append(tile_y)
|
||||||
|
|
||||||
tractor = Tractor(0*TILE_SIZE, 0*TILE_SIZE, 2, None, None)
|
tractor = Tractor(0*TILE_SIZE, 0*TILE_SIZE, 2, None, None)
|
||||||
@ -65,7 +66,7 @@ def main():
|
|||||||
d1.pests_and_weeds()
|
d1.pests_and_weeds()
|
||||||
tile1.ground=d1
|
tile1.ground=d1
|
||||||
|
|
||||||
#movement based on route-planning test:
|
#movement based on route-planning (test):
|
||||||
|
|
||||||
tractor.draw_tractor(WIN)
|
tractor.draw_tractor(WIN)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
@ -77,9 +78,4 @@ def main():
|
|||||||
print("\n")
|
print("\n")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# in loop move tractor:
|
|
||||||
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user