Compare commits
13 Commits
master
...
VowpalWabb
Author | SHA1 | Date | |
---|---|---|---|
7fdc198997 | |||
60e9a253be | |||
6fbd5c76d0 | |||
113b8ebea9 | |||
d95378c72e | |||
913dba936f | |||
c969355d70 | |||
42d124cc6e | |||
|
94064f5d03 | ||
|
635292d9f5 | ||
|
15f88b9e20 | ||
|
abb6dbb5dd | ||
22e4a12eff |
7
.\Resources\Maps\map20190601214903979447_auto.txt
Normal file
7
.\Resources\Maps\map20190601214903979447_auto.txt
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
14 5
|
||||||
|
10 1
|
||||||
|
R R R R R R R R R R R R R R
|
||||||
|
R R H H R H E E E Y R B E R
|
||||||
|
E R E E R H E E E E R R E R
|
||||||
|
E R E G R E E R E E R H E E
|
||||||
|
R R R R R R R R R R R R R R
|
10
.\Resources\Maps\map20190601214912092732_auto.txt
Normal file
10
.\Resources\Maps\map20190601214912092732_auto.txt
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
10 8
|
||||||
|
5 3
|
||||||
|
E R R R H R R R H E
|
||||||
|
E R E R E R R R E E
|
||||||
|
E R E R H R E R E E
|
||||||
|
E R H R E R E R E E
|
||||||
|
E R E R E R E R H Y
|
||||||
|
R R R R R R R R R R
|
||||||
|
H G B R E R E R E E
|
||||||
|
R R R R R R R R R R
|
8
.\Resources\Maps\map20190603114041754808_auto.txt
Normal file
8
.\Resources\Maps\map20190603114041754808_auto.txt
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
9 6
|
||||||
|
6 3
|
||||||
|
R R R R R R R R R
|
||||||
|
E R E E R E R H R
|
||||||
|
R R R R R R R R R
|
||||||
|
Y H B E R E R E R
|
||||||
|
E E E E R E R G R
|
||||||
|
E E E E R E H E R
|
7
.\Resources\Maps\map20190603114044897991_auto.txt
Normal file
7
.\Resources\Maps\map20190603114044897991_auto.txt
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
14 5
|
||||||
|
6 1
|
||||||
|
E R E E E E E R E R E E R H
|
||||||
|
R R R R R R R R R R R R R R
|
||||||
|
H E R E E H E R E H E E R E
|
||||||
|
G E E B H E E R E Y H H R E
|
||||||
|
R R R R R R R R R R R R R R
|
59
.\VowPalInputData\input_map20190603114044897991_auto.txt
Normal file
59
.\VowPalInputData\input_map20190603114044897991_auto.txt
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
3 1.0 map20190603114044897991_auto|GC_Position 5,1 |GC_Area E(4,0) R(4,1) E(4,2) E(5,0) H(5,2) E(6,0) R(6,1) E(6,2)
|
||||||
|
1 1.0 map20190603114044897991_auto|GC_Position 5,1 |GC_Area E(4,0) R(4,1) E(4,2) E(5,0) H(5,2) E(6,0) R(6,1) E(6,2)
|
||||||
|
3 1.0 map20190603114044897991_auto|GC_Position 4,1 |GC_Area E(3,0) R(3,1) E(3,2) E(4,0) E(4,2) E(5,0) R(5,1) H(5,2)
|
||||||
|
3 1.0 map20190603114044897991_auto|GC_Position 3,1 |GC_Area E(2,0) R(2,1) R(2,2) E(3,0) E(3,2) E(4,0) R(4,1) E(4,2)
|
||||||
|
3 1.0 map20190603114044897991_auto|GC_Position 2,1 |GC_Area R(1,0) R(1,1) E(1,2) E(2,0) R(2,2) E(3,0) R(3,1) E(3,2)
|
||||||
|
3 1.0 map20190603114044897991_auto|GC_Position 1,1 |GC_Area E(0,0) R(0,1) H(0,2) R(1,0) E(1,2) E(2,0) R(2,1) R(2,2)
|
||||||
|
3 1.0 map20190603114044897991_auto|GC_Position 0,1 |GC_Area E(0,0) H(0,2) R(1,0) R(1,1) E(1,2)
|
||||||
|
1 1.0 map20190603114044897991_auto|GC_Position 0,1 |GC_Area E(0,0) H(0,2) R(1,0) R(1,1) E(1,2)
|
||||||
|
2 1.0 map20190603114044897991_auto|GC_Position 1,1 |GC_Area E(0,0) R(0,1) H(0,2) R(1,0) E(1,2) E(2,0) R(2,1) R(2,2)
|
||||||
|
2 1.0 map20190603114044897991_auto|GC_Position 2,1 |GC_Area R(1,0) R(1,1) E(1,2) E(2,0) R(2,2) E(3,0) R(3,1) E(3,2)
|
||||||
|
2 1.0 map20190603114044897991_auto|GC_Position 3,1 |GC_Area E(2,0) R(2,1) R(2,2) E(3,0) E(3,2) E(4,0) R(4,1) E(4,2)
|
||||||
|
2 1.0 map20190603114044897991_auto|GC_Position 4,1 |GC_Area E(3,0) R(3,1) E(3,2) E(4,0) E(4,2) E(5,0) R(5,1) H(5,2)
|
||||||
|
2 1.0 map20190603114044897991_auto|GC_Position 5,1 |GC_Area E(4,0) R(4,1) E(4,2) E(5,0) H(5,2) E(6,0) R(6,1) E(6,2)
|
||||||
|
2 1.0 map20190603114044897991_auto|GC_Position 6,1 |GC_Area E(5,0) R(5,1) H(5,2) E(6,0) E(6,2) R(7,0) R(7,1) R(7,2)
|
||||||
|
2 1.0 map20190603114044897991_auto|GC_Position 7,1 |GC_Area E(6,0) R(6,1) E(6,2) R(7,0) R(7,2) E(8,0) R(8,1) E(8,2)
|
||||||
|
2 1.0 map20190603114044897991_auto|GC_Position 8,1 |GC_Area R(7,0) R(7,1) R(7,2) E(8,0) E(8,2) R(9,0) R(9,1) H(9,2)
|
||||||
|
2 1.0 map20190603114044897991_auto|GC_Position 9,1 |GC_Area E(8,0) R(8,1) E(8,2) R(9,0) H(9,2) E(10,0) R(10,1) E(10,2)
|
||||||
|
1 1.0 map20190603114044897991_auto|GC_Position 9,1 |GC_Area E(8,0) R(8,1) E(8,2) R(9,0) H(9,2) E(10,0) R(10,1) E(10,2)
|
||||||
|
2 1.0 map20190603114044897991_auto|GC_Position 10,1 |GC_Area R(9,0) R(9,1) H(9,2) E(10,0) E(10,2) E(11,0) R(11,1) E(11,2)
|
||||||
|
2 1.0 map20190603114044897991_auto|GC_Position 11,1 |GC_Area E(10,0) R(10,1) E(10,2) E(11,0) E(11,2) R(12,0) R(12,1) R(12,2)
|
||||||
|
2 1.0 map20190603114044897991_auto|GC_Position 12,1 |GC_Area E(11,0) R(11,1) E(11,2) R(12,0) R(12,2) H(13,0) R(13,1) E(13,2)
|
||||||
|
2 1.0 map20190603114044897991_auto|GC_Position 13,1 |GC_Area R(12,0) R(12,1) R(12,2) H(13,0) E(13,2)
|
||||||
|
1 1.0 map20190603114044897991_auto|GC_Position 13,1 |GC_Area R(12,0) R(12,1) R(12,2) H(13,0) E(13,2)
|
||||||
|
3 1.0 map20190603114044897991_auto|GC_Position 12,1 |GC_Area E(11,0) R(11,1) E(11,2) R(12,0) R(12,2) H(13,0) R(13,1) E(13,2)
|
||||||
|
3 1.0 map20190603114044897991_auto|GC_Position 11,1 |GC_Area E(10,0) R(10,1) E(10,2) E(11,0) E(11,2) R(12,0) R(12,1) R(12,2)
|
||||||
|
3 1.0 map20190603114044897991_auto|GC_Position 10,1 |GC_Area R(9,0) R(9,1) H(9,2) E(10,0) E(10,2) E(11,0) R(11,1) E(11,2)
|
||||||
|
3 1.0 map20190603114044897991_auto|GC_Position 9,1 |GC_Area E(8,0) R(8,1) E(8,2) R(9,0) H(9,2) E(10,0) R(10,1) E(10,2)
|
||||||
|
3 1.0 map20190603114044897991_auto|GC_Position 8,1 |GC_Area R(7,0) R(7,1) R(7,2) E(8,0) E(8,2) R(9,0) R(9,1) H(9,2)
|
||||||
|
3 1.0 map20190603114044897991_auto|GC_Position 7,1 |GC_Area E(6,0) R(6,1) E(6,2) R(7,0) R(7,2) E(8,0) R(8,1) E(8,2)
|
||||||
|
5 1.0 map20190603114044897991_auto|GC_Position 7,2 |GC_Area R(6,1) E(6,2) E(6,3) R(7,1) R(7,3) R(8,1) E(8,2) E(8,3)
|
||||||
|
5 1.0 map20190603114044897991_auto|GC_Position 7,3 |GC_Area E(6,2) E(6,3) R(6,4) R(7,2) R(7,4) E(8,2) E(8,3) R(8,4)
|
||||||
|
5 1.0 map20190603114044897991_auto|GC_Position 7,4 |GC_Area E(6,3) R(6,4) R(7,3) E(8,3) R(8,4)
|
||||||
|
3 1.0 map20190603114044897991_auto|GC_Position 6,4 |GC_Area E(5,3) R(5,4) E(6,3) R(7,3) R(7,4)
|
||||||
|
3 1.0 map20190603114044897991_auto|GC_Position 5,4 |GC_Area H(4,3) R(4,4) E(5,3) E(6,3) R(6,4)
|
||||||
|
3 1.0 map20190603114044897991_auto|GC_Position 4,4 |GC_Area B(3,3) R(3,4) H(4,3) E(5,3) R(5,4)
|
||||||
|
1 1.0 map20190603114044897991_auto|GC_Position 4,4 |GC_Area B(3,3) R(3,4) H(4,3) E(5,3) R(5,4)
|
||||||
|
2 1.0 map20190603114044897991_auto|GC_Position 5,4 |GC_Area H(4,3) R(4,4) E(5,3) E(6,3) R(6,4)
|
||||||
|
2 1.0 map20190603114044897991_auto|GC_Position 6,4 |GC_Area E(5,3) R(5,4) E(6,3) R(7,3) R(7,4)
|
||||||
|
2 1.0 map20190603114044897991_auto|GC_Position 7,4 |GC_Area E(6,3) R(6,4) R(7,3) E(8,3) R(8,4)
|
||||||
|
2 1.0 map20190603114044897991_auto|GC_Position 8,4 |GC_Area R(7,3) R(7,4) E(8,3) Y(9,3) R(9,4)
|
||||||
|
2 1.0 map20190603114044897991_auto|GC_Position 9,4 |GC_Area E(8,3) R(8,4) Y(9,3) H(10,3) R(10,4)
|
||||||
|
2 1.0 map20190603114044897991_auto|GC_Position 10,4 |GC_Area Y(9,3) R(9,4) H(10,3) H(11,3) R(11,4)
|
||||||
|
1 1.0 map20190603114044897991_auto|GC_Position 10,4 |GC_Area Y(9,3) R(9,4) H(10,3) H(11,3) R(11,4)
|
||||||
|
2 1.0 map20190603114044897991_auto|GC_Position 11,4 |GC_Area H(10,3) R(10,4) H(11,3) R(12,3) R(12,4)
|
||||||
|
1 1.0 map20190603114044897991_auto|GC_Position 11,4 |GC_Area H(10,3) R(10,4) H(11,3) R(12,3) R(12,4)
|
||||||
|
3 1.0 map20190603114044897991_auto|GC_Position 10,4 |GC_Area Y(9,3) R(9,4) H(10,3) H(11,3) R(11,4)
|
||||||
|
3 1.0 map20190603114044897991_auto|GC_Position 9,4 |GC_Area E(8,3) R(8,4) Y(9,3) H(10,3) R(10,4)
|
||||||
|
1 1.0 map20190603114044897991_auto|GC_Position 9,4 |GC_Area E(8,3) R(8,4) Y(9,3) H(10,3) R(10,4)
|
||||||
|
3 1.0 map20190603114044897991_auto|GC_Position 8,4 |GC_Area R(7,3) R(7,4) E(8,3) Y(9,3) R(9,4)
|
||||||
|
3 1.0 map20190603114044897991_auto|GC_Position 7,4 |GC_Area E(6,3) R(6,4) R(7,3) E(8,3) R(8,4)
|
||||||
|
3 1.0 map20190603114044897991_auto|GC_Position 6,4 |GC_Area E(5,3) R(5,4) E(6,3) R(7,3) R(7,4)
|
||||||
|
3 1.0 map20190603114044897991_auto|GC_Position 5,4 |GC_Area H(4,3) R(4,4) E(5,3) E(6,3) R(6,4)
|
||||||
|
3 1.0 map20190603114044897991_auto|GC_Position 4,4 |GC_Area B(3,3) R(3,4) H(4,3) E(5,3) R(5,4)
|
||||||
|
3 1.0 map20190603114044897991_auto|GC_Position 3,4 |GC_Area E(2,3) R(2,4) B(3,3) H(4,3) R(4,4)
|
||||||
|
1 1.0 map20190603114044897991_auto|GC_Position 3,4 |GC_Area E(2,3) R(2,4) B(3,3) H(4,3) R(4,4)
|
||||||
|
3 1.0 map20190603114044897991_auto|GC_Position 2,4 |GC_Area E(1,3) R(1,4) E(2,3) B(3,3) R(3,4)
|
||||||
|
3 1.0 map20190603114044897991_auto|GC_Position 1,4 |GC_Area G(0,3) R(0,4) E(1,3) E(2,3) R(2,4)
|
||||||
|
3 1.0 map20190603114044897991_auto|GC_Position 0,4 |GC_Area G(0,3) E(1,3) R(1,4)
|
||||||
|
1 1.0 map20190603114044897991_auto|GC_Position 0,4 |GC_Area G(0,3) E(1,3) R(1,4)
|
18
.\VowPalInputData\input_map_001.txt
Normal file
18
.\VowPalInputData\input_map_001.txt
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
2 1.0 map_001|GC_Position 3,1 |GC_Area E(2,0) R(2,1) E(2,2) V(3,0) R(3,2) E(4,0) E(4,1) E(4,2)
|
||||||
|
5 1.0 map_001|GC_Position 3,2 |GC_Area R(2,1) E(2,2) E(2,3) R(3,1) R(3,3) E(4,1) E(4,2) R(4,3)
|
||||||
|
5 1.0 map_001|GC_Position 3,3 |GC_Area E(2,2) E(2,3) E(2,4) R(3,2) E(3,4) E(4,2) R(4,3) R(4,4)
|
||||||
|
2 1.0 map_001|GC_Position 4,3 |GC_Area R(3,2) R(3,3) E(3,4) E(4,2) R(4,4) R(5,2) R(5,3) V(5,4)
|
||||||
|
2 1.0 map_001|GC_Position 5,3 |GC_Area E(4,2) R(4,3) R(4,4) R(5,2) V(5,4) E(6,2) R(6,3) E(6,4)
|
||||||
|
2 1.0 map_001|GC_Position 6,3 |GC_Area R(5,2) R(5,3) V(5,4) E(6,2) E(6,4) G(7,2) R(7,3) R(7,4)
|
||||||
|
2 1.0 map_001|GC_Position 7,3 |GC_Area E(6,2) R(6,3) E(6,4) G(7,2) R(7,4) E(8,2) E(8,3) E(8,4)
|
||||||
|
5 1.0 map_001|GC_Position 7,4 |GC_Area R(6,3) E(6,4) R(6,5) R(7,3) R(7,5) E(8,3) E(8,4) E(8,5)
|
||||||
|
5 1.0 map_001|GC_Position 7,5 |GC_Area E(6,4) R(6,5) R(6,6) R(7,4) V(7,6) E(8,4) E(8,5) E(8,6)
|
||||||
|
3 1.0 map_001|GC_Position 6,5 |GC_Area V(5,4) E(5,5) R(5,6) E(6,4) R(6,6) R(7,4) R(7,5) V(7,6)
|
||||||
|
5 1.0 map_001|GC_Position 6,6 |GC_Area E(5,5) R(5,6) R(5,7) R(6,5) E(6,7) R(7,5) V(7,6) E(7,7)
|
||||||
|
3 1.0 map_001|GC_Position 5,6 |GC_Area R(4,5) E(4,6) R(4,7) E(5,5) R(5,7) R(6,5) R(6,6) E(6,7)
|
||||||
|
5 1.0 map_001|GC_Position 5,7 |GC_Area E(4,6) R(4,7) V(4,8) R(5,6) R(5,8) R(6,6) E(6,7) R(6,8)
|
||||||
|
3 1.0 map_001|GC_Position 4,7 |GC_Area V(3,6) R(3,7) E(3,8) E(4,6) V(4,8) R(5,6) R(5,7) R(5,8)
|
||||||
|
3 1.0 map_001|GC_Position 3,7 |GC_Area R(2,6) R(2,7) V(2,8) V(3,6) E(3,8) E(4,6) R(4,7) V(4,8)
|
||||||
|
3 1.0 map_001|GC_Position 2,7 |GC_Area B(1,6) E(1,7) E(1,8) R(2,6) V(2,8) V(3,6) R(3,7) E(3,8)
|
||||||
|
4 1.0 map_001|GC_Position 2,6 |GC_Area R(1,5) B(1,6) E(1,7) R(2,5) R(2,7) R(3,5) V(3,6) R(3,7)
|
||||||
|
1 1.0 map_001|GC_Position 2,6 |GC_Area R(1,5) B(1,6) E(1,7) R(2,5) R(2,7) R(3,5) V(3,6) R(3,7)
|
5
.\VowPalInputData\input_map_005.txt
Normal file
5
.\VowPalInputData\input_map_005.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
2 1.0 map_005|GC_Position 2,6 |GC_Area R(1,5) R(1,6) E(2,5) E(3,5) R(3,6)
|
||||||
|
2 1.0 map_005|GC_Position 3,6 |GC_Area E(2,5) R(2,6) E(3,5) E(4,5) R(4,6)
|
||||||
|
2 1.0 map_005|GC_Position 4,6 |GC_Area E(3,5) R(3,6) E(4,5) R(5,5) R(5,6)
|
||||||
|
2 1.0 map_005|GC_Position 5,6 |GC_Area E(4,5) R(4,6) R(5,5) E(6,5) V(6,6)
|
||||||
|
1 1.0 map_005|GC_Position 5,6 |GC_Area E(4,5) R(4,6) R(5,5) E(6,5) V(6,6)
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -5,4 +5,4 @@ env
|
|||||||
.vscode
|
.vscode
|
||||||
*.swp
|
*.swp
|
||||||
linux_env
|
linux_env
|
||||||
moveset_data.json
|
moveset_data.json
|
||||||
|
@ -2,26 +2,27 @@ from DataModels.Cell import Cell
|
|||||||
from DataModels.Road import Road
|
from DataModels.Road import Road
|
||||||
from DataModels.House import House
|
from DataModels.House import House
|
||||||
from DataModels.Dump import Dump
|
from DataModels.Dump import Dump
|
||||||
from config import GRID_WIDTH, GRID_HEIGHT, DELAY
|
from config import GRID_WIDTH, GRID_HEIGHT, DELAY, CLOSE_ON_END
|
||||||
from utilities import movement, check_moves, save_moveset
|
from utilities import movement, check_moves, save_moveset
|
||||||
|
from vowpal_utils import parse_list, MAP_CONTENT
|
||||||
from Traversal.DFS import DFS
|
from Traversal.DFS import DFS
|
||||||
from Traversal.BestFS import BestFS
|
from Traversal.BestFS import BestFS
|
||||||
from Traversal.BFS import BFS
|
from Traversal.BFS import BFS
|
||||||
import pygame
|
import pygame, sys
|
||||||
|
|
||||||
class GC(Cell):
|
class GC(Cell):
|
||||||
moves_made = 0
|
moves_made = 0
|
||||||
|
algorithm_run = False
|
||||||
def __init__(self, x, y, max_rubbish, yellow=0, green=0, blue=0):
|
def __init__(self, x, y, max_rubbish, yellow=0, green=0, blue=0):
|
||||||
Cell.__init__(self, x, y, max_rubbish, yellow, green, blue)
|
Cell.__init__(self, x, y, max_rubbish, yellow, green, blue)
|
||||||
self.moves = []
|
self.moves = []
|
||||||
self.old_time = pygame.time.get_ticks()
|
self.old_time = pygame.time.get_ticks()
|
||||||
|
|
||||||
def move(self, direction, environment):
|
def move(self, direction, environment):
|
||||||
self.x, self.y = movement(environment, self.x, self.y)[0][direction]
|
self.x, self.y = movement(environment, self.x, self.y)[0][direction]
|
||||||
self.update_rect(self.x, self.y)
|
self.update_rect(self.x, self.y)
|
||||||
self.moves_made = self.moves_made + 1 #moves counter
|
self.moves_made = self.moves_made + 1 #moves counter
|
||||||
|
|
||||||
print(check_moves(environment, self.x, self.y,direction))
|
|
||||||
|
|
||||||
def collect(self, enviromnent):
|
def collect(self, enviromnent):
|
||||||
x, y = [self.x, self.y]
|
x, y = [self.x, self.y]
|
||||||
coordinates = [(x, y - 1), (x, y + 1), (x - 1, y), (x + 1, y)]
|
coordinates = [(x, y - 1), (x, y + 1), (x - 1, y), (x + 1, y)]
|
||||||
@ -41,80 +42,96 @@ class GC(Cell):
|
|||||||
return self.moves_made
|
return self.moves_made
|
||||||
|
|
||||||
def find_houses(self,enviromnent, house_count,dump_count, mode):
|
def find_houses(self,enviromnent, house_count,dump_count, mode):
|
||||||
|
self.algorithm_run = True
|
||||||
|
|
||||||
x = self.x
|
x = self.x
|
||||||
y = self.y
|
y = self.y
|
||||||
result = []
|
result = []
|
||||||
|
whole_result=[]
|
||||||
element_list=[]
|
element_list=[]
|
||||||
house_count_after_search=house_count
|
house_count_after_search=house_count
|
||||||
for home in range(house_count):
|
for home in range(house_count):
|
||||||
|
last_x = x
|
||||||
|
last_y = y
|
||||||
avalible_moves = check_moves(enviromnent, x,y)
|
avalible_moves = check_moves(enviromnent, x,y)
|
||||||
if mode == "DFS":
|
if mode == "DFS":
|
||||||
house,[x,y],result = DFS(enviromnent,avalible_moves,[[x,y]],House)
|
house,[x,y],result = DFS(enviromnent,avalible_moves,[[x,y]],House)
|
||||||
elif mode == "BFS":
|
elif mode == "BFS":
|
||||||
house,[x,y],result = BFS(enviromnent,avalible_moves,[[x,y]],House)
|
house,[x,y],result = BFS(enviromnent,avalible_moves,[[x,y]],House)
|
||||||
result = result[1::]
|
self.moves.extend(parse_list(result[1:], last_x,last_y))
|
||||||
self.moves.extend(result)
|
|
||||||
element_list.append(house)
|
element_list.append(house)
|
||||||
|
|
||||||
|
MAP_CONTENT[house.y][house.x] = 'V'
|
||||||
for dump in range(dump_count):
|
for dump in range(dump_count):
|
||||||
|
last_x = x
|
||||||
|
last_y = y
|
||||||
avalible_moves = check_moves(enviromnent, x,y)
|
avalible_moves = check_moves(enviromnent, x,y)
|
||||||
if mode == "DFS":
|
if mode == "DFS":
|
||||||
dump,[x,y],result = DFS(enviromnent,avalible_moves,[[x,y]],Dump)
|
dump,[x,y],result = DFS(enviromnent,avalible_moves,[[x,y]],Dump)
|
||||||
elif mode == "BFS":
|
elif mode == "BFS":
|
||||||
dump,[x,y],result = BFS(enviromnent,avalible_moves,[[x,y]],Dump)
|
dump,[x,y],result = BFS(enviromnent,avalible_moves,[[x,y]],Dump)
|
||||||
self.moves.extend(result)
|
self.moves.extend(parse_list(result[1:], last_x,last_y))
|
||||||
element_list.append(dump)
|
element_list.append(dump)
|
||||||
for x in element_list:
|
for x in element_list:
|
||||||
x.unvisited = True
|
x.unvisited = True
|
||||||
self.moves.reverse()
|
self.moves.reverse()
|
||||||
save_moveset(self.moves)
|
save_moveset(self.moves)
|
||||||
|
|
||||||
|
|
||||||
def find_houses_BestFS(self, environment):
|
def find_houses_BestFS(self, environment):
|
||||||
|
self.algorithm_run = True
|
||||||
|
|
||||||
x = self.x
|
x = self.x
|
||||||
y = self.y
|
y = self.y
|
||||||
result = [[x,y]]
|
result = [[x,y]]
|
||||||
|
whole_result=[]
|
||||||
houses_list = []
|
houses_list = []
|
||||||
dump_list = []
|
dump_list = []
|
||||||
a = 0
|
a = 0
|
||||||
for row in environment:
|
for row in environment:
|
||||||
b = 0
|
b = 0
|
||||||
for col in row:
|
for col in row:
|
||||||
if (type(col) is House):
|
if (type(col) is House):
|
||||||
houses_list.append([col,[a,b]])
|
houses_list.append([col,[a,b]])
|
||||||
if (type(col) is Dump):
|
if (type(col) is Dump):
|
||||||
dump_list.append([col,[a,b]])
|
dump_list.append([col,[a,b]])
|
||||||
b += 1
|
b += 1
|
||||||
a += 1
|
a += 1
|
||||||
|
|
||||||
x, y = self.x, self.y
|
x, y = self.x, self.y
|
||||||
|
print(MAP_CONTENT)
|
||||||
for i in range(len(houses_list)):
|
for i in range(len(houses_list)):
|
||||||
|
last_x = x
|
||||||
|
last_y = y
|
||||||
available_movement = check_moves(environment, x, y)
|
available_movement = check_moves(environment, x, y)
|
||||||
output = BestFS(environment, available_movement, [[x,y]], houses_list)
|
output = BestFS(environment, available_movement, [[x,y]], houses_list)
|
||||||
if(output != None):
|
if(output != None):
|
||||||
[x,y],result,houses_list = output[0], output[1], output[2]
|
[x,y],result,houses_list,house = output[0], output[1], output[2], output[3]
|
||||||
self.moves.extend(result[1:])
|
MAP_CONTENT[house.y][house.x] = 'V'
|
||||||
|
self.moves.extend(parse_list(result[1:], last_x,last_y))
|
||||||
for i in range(len(dump_list)):
|
for i in range(len(dump_list)):
|
||||||
|
last_x = x
|
||||||
|
last_y = y
|
||||||
available_movement = check_moves(environment, x, y)
|
available_movement = check_moves(environment, x, y)
|
||||||
output = BestFS(environment, available_movement, [[x,y]], dump_list)
|
output = BestFS(environment, available_movement, [[x,y]], dump_list)
|
||||||
if(output != None):
|
if(output != None):
|
||||||
[x,y],result,dump_list = output[0], output[1], output[2]
|
[x,y],result,dump_list = output[0], output[1], output[2]
|
||||||
self.moves.extend(result[1:])
|
self.moves.extend(parse_list(result[1:], last_x,last_y))
|
||||||
self.moves.reverse()
|
self.moves.reverse()
|
||||||
|
print(MAP_CONTENT)
|
||||||
save_moveset(self.moves)
|
save_moveset(self.moves)
|
||||||
|
|
||||||
|
|
||||||
def make_actions_from_list(self,environment):
|
def make_actions_from_list(self,environment):
|
||||||
now = pygame.time.get_ticks()
|
now = pygame.time.get_ticks()
|
||||||
if len(self.moves)==0 or now - self.old_time <= DELAY:
|
if len(self.moves)==0 or now - self.old_time <= DELAY:
|
||||||
|
if(len(self.moves)==0 and CLOSE_ON_END=="true" and self.algorithm_run):
|
||||||
|
print("DONE")
|
||||||
|
sys.exit()
|
||||||
return
|
return
|
||||||
|
|
||||||
self.old_time = pygame.time.get_ticks()
|
self.old_time = pygame.time.get_ticks()
|
||||||
if self.moves[-1] == "pick_garbage":
|
if self.moves[-1] == "pick_garbage":
|
||||||
self.collect(environment)
|
self.collect(environment)
|
||||||
self.moves.pop()
|
self.moves.pop()
|
||||||
return
|
return
|
||||||
self.x, self.y = self.moves.pop()
|
direction = self.moves.pop()
|
||||||
self.moves_made = self.moves_made + 1 #moves counter
|
self.move(direction,environment)
|
||||||
self.update_rect(self.x,self.y)
|
|
||||||
|
@ -5,4 +5,4 @@ class Road( pygame.sprite.Sprite ):
|
|||||||
def __init__( self, x, y ):
|
def __init__( self, x, y ):
|
||||||
pygame.sprite.Sprite.__init__( self )
|
pygame.sprite.Sprite.__init__( self )
|
||||||
self.rect = pygame.Rect( x * CELL_SIZE, y * CELL_SIZE, CELL_SIZE, CELL_SIZE )
|
self.rect = pygame.Rect( x * CELL_SIZE, y * CELL_SIZE, CELL_SIZE, CELL_SIZE )
|
||||||
self.image = pygame.image.load("Resources/Images/Image_Road.png")
|
self.image = pygame.image.load("Resources/Images/Image_Road.png")
|
||||||
|
@ -59,7 +59,7 @@ def GenerateMap():
|
|||||||
|
|
||||||
possible_roads_to_modify = [i for i in roads if i not in intersections_area]
|
possible_roads_to_modify = [i for i in roads if i not in intersections_area]
|
||||||
roads_to_modify = []
|
roads_to_modify = []
|
||||||
for i in range(1,len(possible_roads_to_modify)//3):
|
for i in range(1,len(possible_roads_to_modify)//3):
|
||||||
choice = random.choice(possible_roads_to_modify)
|
choice = random.choice(possible_roads_to_modify)
|
||||||
possible_roads_to_modify.remove(choice)
|
possible_roads_to_modify.remove(choice)
|
||||||
roads_to_modify.append(choice)
|
roads_to_modify.append(choice)
|
||||||
@ -90,7 +90,7 @@ def GenerateMap():
|
|||||||
else:
|
else:
|
||||||
route.append(current_tile)
|
route.append(current_tile)
|
||||||
current_tile = [current_tile[0]+direction,current_tile[1]]
|
current_tile = [current_tile[0]+direction,current_tile[1]]
|
||||||
|
|
||||||
#choose if the route should be complete or not
|
#choose if the route should be complete or not
|
||||||
if(len(route)>1):
|
if(len(route)>1):
|
||||||
if(random.randint(1,100)<=65): #40% chance for route not to be full length
|
if(random.randint(1,100)<=65): #40% chance for route not to be full length
|
||||||
@ -113,7 +113,7 @@ def GenerateMap():
|
|||||||
objects_area = [c for c in objects_area if c not in roads] #remove coords that contain roads
|
objects_area = [c for c in objects_area if c not in roads] #remove coords that contain roads
|
||||||
objects_area.sort()
|
objects_area.sort()
|
||||||
objects_area = [objects_area[i] for i in range(len(objects_area)) if i == 0 or objects_area[i] != objects_area[i-1]] #remove duplicates
|
objects_area = [objects_area[i] for i in range(len(objects_area)) if i == 0 or objects_area[i] != objects_area[i-1]] #remove duplicates
|
||||||
|
|
||||||
houses_area = [i.copy() for i in objects_area]
|
houses_area = [i.copy() for i in objects_area]
|
||||||
for o in objects_area:
|
for o in objects_area:
|
||||||
if(o[0] < 0 or o[1] < 0 or o[0] >= width or o[1] >= height):
|
if(o[0] < 0 or o[1] < 0 or o[0] >= width or o[1] >= height):
|
||||||
@ -132,7 +132,7 @@ def GenerateMap():
|
|||||||
houses_to_leave_count = len(houses_area)//4
|
houses_to_leave_count = len(houses_area)//4
|
||||||
while(len(houses_area) > houses_to_leave_count):
|
while(len(houses_area) > houses_to_leave_count):
|
||||||
houses_area.remove(random.choice(houses_area))
|
houses_area.remove(random.choice(houses_area))
|
||||||
|
|
||||||
#insert houses into the grid
|
#insert houses into the grid
|
||||||
for coord in houses_area:
|
for coord in houses_area:
|
||||||
grid[coord[1]][coord[0]] = "H"
|
grid[coord[1]][coord[0]] = "H"
|
||||||
@ -141,7 +141,7 @@ def GenerateMap():
|
|||||||
GC_position = random.choice(roads)
|
GC_position = random.choice(roads)
|
||||||
|
|
||||||
#Save map to file
|
#Save map to file
|
||||||
name = ".\\Resources\\Maps\\map"+str(datetime.datetime.now().strftime("%Y%m%d%H%M%S"))+"_auto.txt"
|
name = "./Resources/Maps/map"+str(datetime.datetime.now().strftime("%Y%m%d%H%M%S%f"))+"_auto.txt"
|
||||||
map_file = open(name, "w+")
|
map_file = open(name, "w+")
|
||||||
map_file.write(str(width)+" "+str(height)+"\n")
|
map_file.write(str(width)+" "+str(height)+"\n")
|
||||||
map_file.write(str(GC_position[0])+" "+str(GC_position[1])+"\n")
|
map_file.write(str(GC_position[0])+" "+str(GC_position[1])+"\n")
|
||||||
@ -150,4 +150,4 @@ def GenerateMap():
|
|||||||
map_file.close()
|
map_file.close()
|
||||||
print(name)
|
print(name)
|
||||||
|
|
||||||
return(name)
|
return(name)
|
||||||
|
@ -15,7 +15,7 @@ def CalculateDistance(gc, object_list):
|
|||||||
return min_distance_goal
|
return min_distance_goal
|
||||||
|
|
||||||
def BestFS(grid, available_movement, gc_moveset, object_list, depth = 0):
|
def BestFS(grid, available_movement, gc_moveset, object_list, depth = 0):
|
||||||
|
|
||||||
x, y = gc_moveset[-1][0], gc_moveset[-1][1]
|
x, y = gc_moveset[-1][0], gc_moveset[-1][1]
|
||||||
|
|
||||||
#calculate distance to the nearest object
|
#calculate distance to the nearest object
|
||||||
@ -25,11 +25,11 @@ def BestFS(grid, available_movement, gc_moveset, object_list, depth = 0):
|
|||||||
gc_moveset.append("pick_garbage")
|
gc_moveset.append("pick_garbage")
|
||||||
cell = grid[min_distance_goal[0][0]][min_distance_goal[0][1]]
|
cell = grid[min_distance_goal[0][0]][min_distance_goal[0][1]]
|
||||||
object_list.remove([cell,min_distance_goal[0]])
|
object_list.remove([cell,min_distance_goal[0]])
|
||||||
return([x, y], gc_moveset, object_list)
|
return([x, y], gc_moveset, object_list,cell)
|
||||||
|
|
||||||
#if depth exceeded, return
|
#if depth exceeded, return
|
||||||
if(depth > 15 or len(available_movement) == 0):
|
if(depth > 15 or len(available_movement) == 0):
|
||||||
return
|
return
|
||||||
|
|
||||||
#set preffered directions based on the closest object
|
#set preffered directions based on the closest object
|
||||||
preffered_directions = []
|
preffered_directions = []
|
||||||
@ -65,4 +65,4 @@ def BestFS(grid, available_movement, gc_moveset, object_list, depth = 0):
|
|||||||
gc_moveset_next.append([x_next,y_next])
|
gc_moveset_next.append([x_next,y_next])
|
||||||
result = BestFS(grid, available_movement_next, gc_moveset_next, object_list, depth + 1)
|
result = BestFS(grid, available_movement_next, gc_moveset_next, object_list, depth + 1)
|
||||||
if result!= None:
|
if result!= None:
|
||||||
return result
|
return result
|
||||||
|
29
config.py
29
config.py
@ -1,15 +1,34 @@
|
|||||||
import sys, random
|
import sys, random, MapGenerator
|
||||||
from MapGenerator import GenerateMap
|
|
||||||
|
|
||||||
CELL_SIZE = 64
|
CELL_SIZE = 64
|
||||||
FPS = 60
|
FPS = 60
|
||||||
DELAY = 50
|
DELAY = 10
|
||||||
|
|
||||||
try:
|
try:
|
||||||
MAP_NAME = sys.argv[1]
|
map_mode = sys.argv[1]
|
||||||
|
if(map_mode == "auto"):
|
||||||
|
MAP_NAME = MapGenerator.GenerateMap()
|
||||||
|
else:
|
||||||
|
MAP_NAME = map_mode
|
||||||
except:
|
except:
|
||||||
MAP_NAME = GenerateMap()
|
print("ERROR: Invalid map mode\n Please enter \"auto\" for generated map or provide a path to an existing map.")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
if(len(sys.argv)>2):
|
||||||
|
CLOSE_ON_END = sys.argv[2]
|
||||||
|
if(CLOSE_ON_END != "true" and CLOSE_ON_END != "false"):
|
||||||
|
print("ERROR: Invalid close on end statement\n Please enter \"true\" or \"false\" to specify if app has to shut after finding solution.")
|
||||||
|
sys.exit()
|
||||||
|
else:
|
||||||
|
print("ERROR: Invalid close on end statement\n Please enter \"true\" or \"false\" to specify if app has to shut after finding solution.")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
ALGORITHM = None
|
||||||
|
if(len(sys.argv)>3):
|
||||||
|
ALGORITHM = sys.argv[3]
|
||||||
|
if(ALGORITHM != "bfs" and ALGORITHM != "dfs" and ALGORITHM!= "bestfs"):
|
||||||
|
print("ERROR: Invalid agorithm statement\n Please enter \"bfs\", \"dfs\" or \"bestfs\" to specify algorithm you want to use.")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
map = open( MAP_NAME, 'r' )
|
map = open( MAP_NAME, 'r' )
|
||||||
|
|
||||||
|
13
main.py
Normal file → Executable file
13
main.py
Normal file → Executable file
@ -3,7 +3,7 @@
|
|||||||
import pygame
|
import pygame
|
||||||
import sys
|
import sys
|
||||||
from random import randint
|
from random import randint
|
||||||
from config import WINDOW_HEIGHT, WINDOW_WIDTH, GRID_HEIGHT, GRID_WIDTH, HOUSE_CAPACITY, FPS, GC_X, GC_Y, MAP_NAME
|
from config import WINDOW_HEIGHT, WINDOW_WIDTH, GRID_HEIGHT, GRID_WIDTH, HOUSE_CAPACITY, FPS, GC_X, GC_Y, MAP_NAME, ALGORITHM
|
||||||
|
|
||||||
from PIL import Image,ImageDraw
|
from PIL import Image,ImageDraw
|
||||||
|
|
||||||
@ -21,6 +21,8 @@ dump_count=0
|
|||||||
FPS_CLOCK = pygame.time.Clock()
|
FPS_CLOCK = pygame.time.Clock()
|
||||||
GAME_WINDOW = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT), 0, 32)
|
GAME_WINDOW = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT), 0, 32)
|
||||||
|
|
||||||
|
algorithm = ALGORITHM
|
||||||
|
|
||||||
map = open(MAP_NAME, 'r')
|
map = open(MAP_NAME, 'r')
|
||||||
map.readline()
|
map.readline()
|
||||||
map.readline()
|
map.readline()
|
||||||
@ -83,6 +85,15 @@ pygame_sprites.add(gc)
|
|||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
|
if(algorithm != None):
|
||||||
|
if(algorithm == "bfs"):
|
||||||
|
gc.find_houses(map_objects,house_count,dump_count, "BFS")
|
||||||
|
elif(algorithm == "dfs"):
|
||||||
|
gc.find_houses(map_objects,house_count,dump_count, "DFS")
|
||||||
|
elif (algorithm == "bestfs"):
|
||||||
|
gc.find_houses_BestFS(map_objects)
|
||||||
|
algorithm = None
|
||||||
|
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
if event.type == pygame.QUIT:
|
if event.type == pygame.QUIT:
|
||||||
pygame.quit()
|
pygame.quit()
|
||||||
|
14
utilities.py
14
utilities.py
@ -1,7 +1,6 @@
|
|||||||
from config import GRID_WIDTH, GRID_HEIGHT
|
from config import GRID_WIDTH, GRID_HEIGHT
|
||||||
from DataModels.Road import Road
|
from DataModels.Road import Road
|
||||||
import json, os, platform
|
import platform,os,json
|
||||||
|
|
||||||
def movement(environment, x ,y):
|
def movement(environment, x ,y):
|
||||||
movement = {
|
movement = {
|
||||||
"right": (x + 1, y) if x + 1 < GRID_WIDTH and type(environment[x + 1][y]) == Road else (x, y),
|
"right": (x + 1, y) if x + 1 < GRID_WIDTH and type(environment[x + 1][y]) == Road else (x, y),
|
||||||
@ -24,13 +23,14 @@ def check_moves(environment, x,y,direction=None):
|
|||||||
return ([dir for dir in movement(environment, x, y)[0] if movement(environment, x,y)[0][dir] != (x,y)])
|
return ([dir for dir in movement(environment, x, y)[0] if movement(environment, x,y)[0][dir] != (x,y)])
|
||||||
return ([dir for dir in movement(environment, x, y)[0] if movement(environment, x,y)[0][dir] != (x,y) and dir != movement(environment,x,y)[1][direction]])
|
return ([dir for dir in movement(environment, x, y)[0] if movement(environment, x,y)[0][dir] != (x,y) and dir != movement(environment,x,y)[1][direction]])
|
||||||
|
|
||||||
|
|
||||||
def save_moveset(moveset):
|
def save_moveset(moveset):
|
||||||
if platform.system() == 'Windows':
|
if platform.system() == 'Windows':
|
||||||
path = '\moveset_data.json'
|
path = '\moveset_data.json'
|
||||||
else:
|
else:
|
||||||
path = '/moveset_data.json'
|
path = '/moveset_data.json'
|
||||||
output_file = os.path.normpath(os.getcwd()) + path
|
output_file = os.path.normpath(os.getcwd()) + path
|
||||||
|
|
||||||
results = {}
|
results = {}
|
||||||
try:
|
try:
|
||||||
f = open(output_file, 'r+')
|
f = open(output_file, 'r+')
|
||||||
@ -38,16 +38,16 @@ def save_moveset(moveset):
|
|||||||
open(output_file, 'a').close()
|
open(output_file, 'a').close()
|
||||||
finally:
|
finally:
|
||||||
f = open(output_file, 'r+')
|
f = open(output_file, 'r+')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
results = json.load(f)
|
results = json.load(f)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
finally:
|
finally:
|
||||||
if "moveset" not in results:
|
if "moveset" not in results:
|
||||||
results = { "moveset": [] }
|
results = { "moveset": [] }
|
||||||
|
|
||||||
results["moveset"].append(moveset)
|
results["moveset"].append(moveset)
|
||||||
f.seek(0)
|
f.seek(0)
|
||||||
json.dump(results, f, indent=1)
|
json.dump(results, f, indent=1)
|
||||||
f.close()
|
f.close()
|
||||||
|
7
vowpal_auto_run.ps1
Normal file
7
vowpal_auto_run.ps1
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
param (
|
||||||
|
[Parameter(Mandatory=$true)][string]$loop
|
||||||
|
)
|
||||||
|
|
||||||
|
for($i = 1; $i -le $loop; $i++){
|
||||||
|
python main.py auto true bestfs
|
||||||
|
}
|
4
vowpal_run.sh
Executable file
4
vowpal_run.sh
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
python3 main.py ./Resources/Maps/$1 true bestfs
|
||||||
|
python3 main.py ./Resources/Maps/$1 true bfs
|
||||||
|
python3 main.py ./Resources/Maps/$1 true dfs
|
86
vowpal_utils.py
Normal file
86
vowpal_utils.py
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
import re
|
||||||
|
from config import MAP_NAME, GRID_WIDTH, GRID_HEIGHT, GC_X, GC_Y
|
||||||
|
import os.path
|
||||||
|
|
||||||
|
COORDINATES_LIST = []
|
||||||
|
MOVES_LIST = []
|
||||||
|
|
||||||
|
with open( MAP_NAME, 'r' ) as map:
|
||||||
|
MAP_CONTENT = map.readlines()[2:]
|
||||||
|
MAP_CONTENT = [list(row.strip().replace(" ","")) for row in MAP_CONTENT]
|
||||||
|
|
||||||
|
moves_mapping = {
|
||||||
|
"pick_garbage": 1,
|
||||||
|
"right": 2,
|
||||||
|
"left": 3,
|
||||||
|
"up": 4,
|
||||||
|
"down": 5
|
||||||
|
}
|
||||||
|
|
||||||
|
def parse_list(whole_result,current_x,current_y):
|
||||||
|
global COORDINATES_LIST, MOVES_LIST
|
||||||
|
COORDINATES_LIST = whole_result.copy()
|
||||||
|
moves = []
|
||||||
|
parser = {'[0,1]':"down",'[0,-1]':"up",'[1,0]':"right",'[-1,0]':"left"}
|
||||||
|
for x in range(len(whole_result)):
|
||||||
|
if whole_result[x]=="pick_garbage":
|
||||||
|
moves.append(whole_result[x])
|
||||||
|
else:
|
||||||
|
x_subtraction = whole_result[x][0] - current_x
|
||||||
|
y_subtraction = whole_result[x][1] - current_y
|
||||||
|
current_x = whole_result[x][0]
|
||||||
|
current_y = whole_result[x][1]
|
||||||
|
moves.append(parser[f"[{x_subtraction},{y_subtraction}]"])
|
||||||
|
MOVES_LIST = moves.copy()
|
||||||
|
generate_input(1.0)
|
||||||
|
return moves
|
||||||
|
|
||||||
|
def generate_input(importance):
|
||||||
|
i = 0 #we'll use it to map coords to moves
|
||||||
|
input_file_content = []
|
||||||
|
for position in COORDINATES_LIST:
|
||||||
|
|
||||||
|
coords = check_position(position, i) #set valid gc position
|
||||||
|
|
||||||
|
#vowpal config goes here
|
||||||
|
label = moves_mapping[MOVES_LIST[i]]
|
||||||
|
tag = re.findall("(map_[0-9]+|map[0-9]+_auto)", MAP_NAME)[0]
|
||||||
|
gc_position = "|GC_Position "+str(coords[0])+","+str(coords[1])
|
||||||
|
input_line = str(label) + " " + str(importance) + " " + tag + gc_position+" |GC_Area "
|
||||||
|
|
||||||
|
area = get_gc_area(coords,1)
|
||||||
|
for a in area:
|
||||||
|
input_line += a + " "
|
||||||
|
|
||||||
|
i += 1
|
||||||
|
input_file_content.append(input_line)
|
||||||
|
#save to file
|
||||||
|
filename = "./VowPalInputData/input_" + str(tag) + ".txt"
|
||||||
|
if os.path.exists(filename):
|
||||||
|
input_file = open(filename,"a+")
|
||||||
|
else:
|
||||||
|
input_file = open(filename,"w+")
|
||||||
|
for line in input_file_content:
|
||||||
|
print(line)
|
||||||
|
input_file.write(line+"\n")
|
||||||
|
input_file.close()
|
||||||
|
|
||||||
|
def get_gc_area(position, radius):
|
||||||
|
area = []
|
||||||
|
for x in range(max(0, position[0] - radius), min(position[0] + radius + 1, GRID_WIDTH)): #prevents giong abroad
|
||||||
|
for y in range(max(0, position[1] - radius), min(position[1] + radius + 1, GRID_HEIGHT)):
|
||||||
|
if([x,y] == position): #we dont need gc data here
|
||||||
|
continue
|
||||||
|
area.append(MAP_CONTENT[y][x]+"("+str(x)+","+str(y)+")")
|
||||||
|
return area
|
||||||
|
|
||||||
|
def check_position(position, i):
|
||||||
|
if(type(position) is list): #if position valid, return it
|
||||||
|
return position
|
||||||
|
elif(position == "pick_garbage"): #if invalid, look for recent coords. if not found, return initial coords
|
||||||
|
for j in range(i-1,-1,-1):
|
||||||
|
if(type(COORDINATES_LIST[j]) is list):
|
||||||
|
return COORDINATES_LIST[j]
|
||||||
|
return [GC_X, GC_Y]
|
||||||
|
else: #in case sh t happened
|
||||||
|
print("An error has ocurred while processing GC position.")
|
Loading…
Reference in New Issue
Block a user