From 35d84146d92d320e12ba668d6477e82b549d19d8 Mon Sep 17 00:00:00 2001 From: s450026 Date: Tue, 9 Jun 2020 14:13:21 +0200 Subject: [PATCH] Add plate class, showin plate on table, predict by plate class --- main.py | 84 ++++++++++++++++-------- resources/images/plate-empty.png | Bin 0 -> 1962 bytes resources/images/plate-full.png | Bin 0 -> 3588 bytes src/__pycache__/graphics.cpython-37.pyc | Bin 2013 -> 3534 bytes src/__pycache__/waiter.cpython-37.pyc | Bin 4523 -> 4797 bytes src/graphics.py | 18 ++++- src/plate.py | 13 ++++ 7 files changed, 88 insertions(+), 27 deletions(-) create mode 100644 resources/images/plate-empty.png create mode 100644 resources/images/plate-full.png create mode 100644 src/plate.py diff --git a/main.py b/main.py index ae31b35..e402baa 100644 --- a/main.py +++ b/main.py @@ -4,6 +4,8 @@ import sys from random import randrange from src.decisionTree import * +from src.plate import * + from src.SubprojectMaksymilianKierski.PlateRecognition import use_model_to_predict, text_speech # Marcin Dobrowolski @@ -26,8 +28,8 @@ if __name__ == "__main__": # AStar goal = None path = '' - - #Dominik + + # Dominik check = 0 queue = [] @@ -38,7 +40,17 @@ if __name__ == "__main__": # Maksymilian go = 0 - rand = 0 + randGo = 0 + waitPos = [[1, 2], [1, 5], [1, 8], [5, 4], [5, 8], + [8, 2], [8, 5], [8, 8], [12, 3], [12, 7]] + + tabPos = [[1, 2], [1, 5], [1, 8], [5, 4], [5, 8], + [8, 2], [8, 5], [8, 8], [12, 3], [12, 7]] + + pltPos = [[2, 3], [2, 6], [2, 9], [4, 4], [4, 8], + [9, 3], [9, 6], [9, 9], [11, 3], [11, 8]] + + plateArr = [] while True: for event in pygame.event.get(): @@ -55,7 +67,7 @@ if __name__ == "__main__": break if event.key == pygame.K_s: - tree.TasksList('check', [2,3]) + tree.TasksList('check', [2, 3]) tree.TasksList('eat', [9, 6]) tree.TasksList('order', [4, 8]) tree.TasksList('goToBar', [11, 4]) @@ -66,34 +78,53 @@ if __name__ == "__main__": check = 1 if event.key == pygame.K_m: - - tabPos = [[1, 2], [1, 5], [1, 8], [5, 4], [5, 8], - [8, 2], [8, 5], [8, 8], [12, 3], [12, 7]] - - if not [waiter.X, waiter.Y] in tabPos or go == 0: - if [waiter.X, waiter.Y] in tabPos: + if (not [waiter.X, waiter.Y] in waitPos) or go == 0: + if [waiter.X, waiter.Y] in waitPos: model = 'waiter_' + waiter.direction for x in range(-1, 2): waiterX = waiter.X + (x * 0.1) - print(waiterX) graphics.clear(waiterX, waiter.Y - 1) rand = randrange(9) - x = tabPos[rand][0] - y = tabPos[rand][1] - goal = (x, y) - path = waiter.findPath(goal) - path = waiter.translatePath(path) + # if this plate is exists + print('check{}{}{}'.format(plateArr, len(plateArr), rand)) + if plateArr and len(plateArr) >= rand and plateArr[rand] in plateArr: + randGo = rand + goal = (plateArr[randGo].table[0], plateArr[randGo].table[1]) + path = waiter.findPath(goal) + path = waiter.translatePath(path) + print('sec-1') - go = 1 + go = 1 + + # if this plate is not exists + else: + + randTable = random.choice(tabPos) + randIndex = tabPos.index(randTable) + tableCord = tabPos[randIndex] + plateCord = pltPos[randIndex] + print('rand{}'.format(randIndex)) + pictureAI = 'test-{}'.format(randIndex) + plateArr.append(Plate(graphics, plateCord, tableCord, 'plate-full.png', pictureAI)) + tabPos.pop(randIndex) + pltPos.pop(randIndex) + print(plateArr, pltPos) + + goal = (plateArr[len(plateArr) - 1].table[0], plateArr[len(plateArr) - 1].table[1]) + randGo = len(plateArr)-1 + path = waiter.findPath(goal) + path = waiter.translatePath(path) + print('sec-2') + go = 1 else: - predict = use_model_to_predict('test-{}'.format(rand)) + predict = use_model_to_predict(plateArr[randGo].pictureAI) if predict == 1: predict = 'EMPTY' else: predict = 'FOOD' - + print('sec-3') 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) pygame.display.flip() @@ -132,7 +163,7 @@ if __name__ == "__main__": goal = (x, y) path = waiter.findPath(goal) path = waiter.translatePath(path) - + # Dominik if check == 1: task = queue.pop(0) @@ -160,12 +191,13 @@ if __name__ == "__main__": path = path[1:] waiter.travel(nextStep, graphics) if path == '': - action = actions.pop(0) - if action[0] == 'takeOrder': - guest = newGuests.pop(0) - waiter.takeOrder(suggestionTreeRoot, guest) - graphics.clearGuest(guest) - tables.append(guest.cord) + print('') + # action = actions.pop(0) + # if action[0] == 'takeOrder': + # guest = newGuests.pop(0) + # waiter.takeOrder(suggestionTreeRoot, guest) + # graphics.clearGuest(guest) + # tables.append(guest.cord) pygame.display.flip() clock.tick(graphics.fps) diff --git a/resources/images/plate-empty.png b/resources/images/plate-empty.png new file mode 100644 index 0000000000000000000000000000000000000000..719c8cfaf93d63e0462f975e7a2e65016769d325 GIT binary patch literal 1962 zcmZ9McTm&W9>sqNb!k$AU}(WYM}hZ1rE z(v&6$JQWKdEfHx-Xl8{_7T$ZaZ)U$U=leNx=iHh5$C;aKZE4KUBgq2*0KcgT%Jz`( zBXM&cZfSjTJpiyv1R5DxUokQ^3JVS+;s~DJzQ(?xzQjOpTjNUrpp%}CcMX8zMUib0 z{_-bBaKY#9T&>XOKgFM8caGZhJZ@?V5lS&dOu!a>n5!fAUXSQ#w(U`^(AFf4;Lo zlx$HDO5og@}~RvhpGM2nihn6NBzdLIqy%eB9O7^fqq|AXz$4! zcw7)UUoi7c?=K7=OXFW3-OI2+E0v4$54;K^r^@OH4A1@2knVsxn<1|rj~0|7Z!Q*LqsCoHjP}*t?RSJKtaLC$d6tB^wL#%Ubt`ZeB<2 z?!35e!i*u7>i$?FEpFbXsB-N-%Fj&{>q#WXQ89+h1=@c77c)UNi6F^&(>S%e4+Wgn z>8>H=i=*az;@V>}=8%=01lzI$RAVYJzRr=e$|fz{YC^Sjd1c$CcSM|2O1gunN{H*= zZ~Toz;ojM#b{?z)n~;x!0p|?lbHI~C0ZzDRji^M5JJnD8#6s7Fjq^8YFi!sv+-v*Q@Thc#G)As%V4tPfN%Ok0*}0!A+Uj;cyV_dddYX zGY8rr;=|baY!-}myP*AX??sxXZFwPjO1G)4%;P{)$-)Kqsai##`FHstMHYu^`);3m zy~~n{woNllqWHP}$hQ0T$}XI#yc_h#Y}{A-^%i2k)0?&ii&x)+9U`Lek|CUQ$lBY2 z-sE1X&G7ZF_Qx=>l-C6dbz80%9K+NEFxB}SJ3-ra5|-(x>aE1Bq$ZX2GcgK#eeJ_B zgE7M~BQf2s;B392VtU7%8bKz)y^k5RDd{wG6LS4{i~kbkO0}7se6W}_g!mFMXX6Rq zIK#*7eaYr?0;Oh!1u0c8xhN&zE%WU$%cVoj4wTHQ2XA5b@%YP2gj_`_yD+RyhoMN? zNh6=MT*T!+pV@CxVR=^bwt<2;J)Fps`Z2>}NsZ;#%0j@bU8xUGLK|$C-+52RfF0kT z4_)CO7K<`}m*XW_hft#2UtT0v9RGd5A|n8oG!f!-f`c)=mAO?2Z#yR9tY%!q;_K?r zU;oZhqh&M!6li=xzkKNN(Lt_h4xP>06AhEyQrRXX-r2D~zcV{`;L)*rV@qFpBB~cu z}R>2aX4QWBocg_m*oR|NYynEGL{fYPDo2G~K80LP&N9SR9L z@wdl-6acpWoPz-%DG*@)U&iu~N0W7^qdWg4xD5Pv0$#@Ue}5E}nZwi^;x~ecV*~&| zP8|tkYI|}G0KlE5D8tJE96u=Ip-LKpsNs%8!L&Qmyj1%f4>wD(MwKjF(3I}$}&bI-m$fYZmT_8S! z)_zs8;3za5lcB12oX?DYr95Si8P_(oLs0YLmUV=V(gZzHxnCI2HPTZT>Fb1G(~<b>VrEswYk{Wrw*g>k9qC`al_;cTI9%+gh{%hao z2)~|A9loT!&HCc!gtNm5f9e4Rw6bDOw zrumaq*$iCSfyd#R!+x3_SLLHCUq-LmnSI)ifH`?Ijz=?*VWfe7Uw+aF)JDE3{72c! cyW*<4xTZ57^~w2h2Ojm@6m5yBz2tH0FQsyTUjP6A literal 0 HcmV?d00001 diff --git a/resources/images/plate-full.png b/resources/images/plate-full.png new file mode 100644 index 0000000000000000000000000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LMVL!R^{E4Sq#%cW(Of!~y!J?WK;US0q8y-|J>vi#wP4ZCM;>jUsk$IFWOF4+uLKuU`w>|w7juXNb3G|j%%*o~~%#B6J(iJ=w;%(&_VgAwe$ zHu;7LAG5KUOj`k%N})B)r(+#!#x*%PIqaN%xO>Q3Q?ndf=_eR$81ozCe0x5ra`(<~ zx%=PngGZFQ9`-RY)#A>#ElE5<=qKDLkz15`vrpx6-XGhK3239qMh+??*|n4^doQ@s zYeWYM>KKE+9<#bwSxhL(Mhz`q?csw%aL0a7+6gBSVc~8+8~KX`L`P>RA-X4UEaRsS ztKiIRrNw)jp^@}`RqyTDIhoaD$i>i*z!*pXb5K+AJ)GE(~zA@w#RKE9Z&y2(P%WL3AYFWCa_?!*a;l-UCW%|sc+7k z$)3b#jo35!tdzAQUrCnZ2{%*nJ=AHtjO$c=^9c~o3k`mkHL!5At* zmAyDeGJcvp1Y)^*bT` zoG0V-5krc6%)A)it>xz3?>+aK^&qL62M+w*EmT-7dR6r|aV!YH0+F8%;)6p|pEb6boO7$$3`K_v?Xy9k~ xQKWaD#_p?{+z|Wq=tPp+96A4iD+-RkcX*c3ouF>JPyaqB9SsBZ_p0_W{{_Fzl5GG0 literal 0 HcmV?d00001 diff --git a/src/__pycache__/graphics.cpython-37.pyc b/src/__pycache__/graphics.cpython-37.pyc index 83a60536881cf050d97afbe7d47ce85a36ab35f6..fd5f6b849a51d135fbe9bec7aae8645e04ffb294 100644 GIT binary patch literal 3534 zcmc&$TW=dh6rS0e*LLjO+@=))1cFk7YKOK|LaM5&q(nu?st72>609~mV`trs?ar=A zV!2Q4&)~t4c;PS211~(~FYv@UGwY4lO}M?Vt35MkE@#ho=FB(qs8T5rcs@D(?MJpk z$nU7k9t$cD;fwEsV1&_#v~@|_l+&IuHMw<4+qSAZ+-An9(Jt%|W-{wFVb&|7?J~Mc z>h>8}Agyt&(P#=D4@M&3aWg#hyHEt!H+u}IJcKX)76d14%1GN_lo_u{+tha37PFZH zy3GpAh08QmbK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