Add randomly change the plate from full to empty
26
main.py
@ -51,7 +51,17 @@ if __name__ == "__main__":
|
|||||||
[9, 3], [9, 6], [9, 9], [11, 3], [11, 8]]
|
[9, 3], [9, 6], [9, 9], [11, 3], [11, 8]]
|
||||||
|
|
||||||
plateArr = []
|
plateArr = []
|
||||||
|
|
||||||
|
def changePlate():
|
||||||
|
if plateArr and len(plateArr) > 0:
|
||||||
|
if randrange(30) == 17:
|
||||||
|
plate = random.choice(plateArr)
|
||||||
|
if not plate.empty:
|
||||||
|
randomPlate = randrange(5)+10
|
||||||
|
plate.changePlate('plate-empty.png', 'test-{}'.format(randomPlate))
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
changePlate()
|
||||||
|
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
# rabbit.check(waiter.matrix, waiter.X, waiter.Y)
|
# rabbit.check(waiter.matrix, waiter.X, waiter.Y)
|
||||||
@ -87,7 +97,7 @@ if __name__ == "__main__":
|
|||||||
rand = randrange(9)
|
rand = randrange(9)
|
||||||
|
|
||||||
# if this plate is exists
|
# if this plate is exists
|
||||||
print('check{}{}{}'.format(plateArr, len(plateArr), rand))
|
print(rand)
|
||||||
if plateArr and len(plateArr) >= rand and plateArr[rand] in plateArr:
|
if plateArr and len(plateArr) >= rand and plateArr[rand] in plateArr:
|
||||||
randGo = rand
|
randGo = rand
|
||||||
goal = (plateArr[randGo].table[0], plateArr[randGo].table[1])
|
goal = (plateArr[randGo].table[0], plateArr[randGo].table[1])
|
||||||
@ -118,12 +128,16 @@ if __name__ == "__main__":
|
|||||||
print('sec-2')
|
print('sec-2')
|
||||||
go = 1
|
go = 1
|
||||||
else:
|
else:
|
||||||
predict = use_model_to_predict(plateArr[randGo].pictureAI)
|
if plateArr[randGo].checked:
|
||||||
|
predict = 'CHECKED'
|
||||||
if predict == 1:
|
|
||||||
predict = 'EMPTY'
|
|
||||||
else:
|
else:
|
||||||
predict = 'FOOD'
|
predict = use_model_to_predict(plateArr[randGo].pictureAI)
|
||||||
|
|
||||||
|
if predict == 1:
|
||||||
|
predict = 'EMPTY'
|
||||||
|
plateArr[randGo].checkPlate()
|
||||||
|
else:
|
||||||
|
predict = 'FOOD'
|
||||||
print('sec-3')
|
print('sec-3')
|
||||||
text_speech('arialnarrow.ttf', 25, predict, (255, 255, 255), (0, 128, 0),
|
text_speech('arialnarrow.ttf', 25, predict, (255, 255, 255), (0, 128, 0),
|
||||||
(waiter.X * 50 + 25), (waiter.Y * 50 - 25), False, False, screen=graphics.screen)
|
(waiter.X * 50 + 25), (waiter.Y * 50 - 25), False, False, screen=graphics.screen)
|
||||||
|
BIN
src/SubprojectMaksymilianKierski/Data/TestData/test-11.jpg
Normal file
After Width: | Height: | Size: 37 KiB |
BIN
src/SubprojectMaksymilianKierski/Data/TestData/test-12.jpg
Normal file
After Width: | Height: | Size: 4.0 KiB |
BIN
src/SubprojectMaksymilianKierski/Data/TestData/test-13.jpg
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
src/SubprojectMaksymilianKierski/Data/TestData/test-14.jpg
Normal file
After Width: | Height: | Size: 74 KiB |
BIN
src/SubprojectMaksymilianKierski/Data/TestData/test-15.jpg
Normal file
After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 107 KiB |
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 7.7 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 857 KiB |
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 9.6 KiB |
@ -80,10 +80,12 @@ class Graphics:
|
|||||||
def drawFullPlate(self, x, y, picture):
|
def drawFullPlate(self, x, y, picture):
|
||||||
self.screen.blit(pygame.image.load(relative_path + picture),
|
self.screen.blit(pygame.image.load(relative_path + picture),
|
||||||
(x * self.block_size, y * self.block_size))
|
(x * self.block_size, y * self.block_size))
|
||||||
def drawEmptyPlate(self, x, y):
|
def drawEmptyPlate(self, x, y, picture):
|
||||||
|
self.screen.blit(self.image['floor'],
|
||||||
|
(x * self.block_size, y * self.block_size))
|
||||||
self.screen.blit(self.image['table'],
|
self.screen.blit(self.image['table'],
|
||||||
(x * self.block_size, y * self.block_size))
|
(x * self.block_size, y * self.block_size))
|
||||||
self.screen.blit(self.image['plate-full'],
|
self.screen.blit(pygame.image.load(relative_path + picture),
|
||||||
(x * self.block_size, y * self.block_size))
|
(x * self.block_size, y * self.block_size))
|
||||||
def clearPlate(self, x, y):
|
def clearPlate(self, x, y):
|
||||||
self.screen.blit(self.image['table'],
|
self.screen.blit(self.image['table'],
|
||||||
|
14
src/plate.py
@ -1,13 +1,19 @@
|
|||||||
|
|
||||||
class Plate:
|
class Plate:
|
||||||
def __init__(self, graphics, plate, table, picture, pictureAI):
|
def __init__(self, graphics, plate, table, picture, pictureAI):
|
||||||
self.plate = plate
|
self.plate = plate
|
||||||
self.table = table
|
self.table = table
|
||||||
self.picture = picture
|
self.picture = picture
|
||||||
self.pictureAI = pictureAI
|
self.pictureAI = pictureAI
|
||||||
|
self.graphics = graphics
|
||||||
|
self.empty = False
|
||||||
|
self.checked = False
|
||||||
graphics.drawFullPlate(self.plate[0], self.plate[1], picture)
|
graphics.drawFullPlate(self.plate[0], self.plate[1], picture)
|
||||||
|
|
||||||
|
def changePlate(self, newPicture, newPictureAI):
|
||||||
|
self.graphics.drawEmptyPlate(self.plate[0], self.plate[1], newPicture)
|
||||||
|
self.picture = newPicture
|
||||||
|
self.pictureAI = newPictureAI
|
||||||
|
self.empty = True
|
||||||
|
|
||||||
def changePlate(self):
|
def checkPlate(self):
|
||||||
print('keep')
|
self.checked = True
|
||||||
|
|
||||||
|