From 9ebb4a0f15924e50ed24b4564fdcd7a491a4976e Mon Sep 17 00:00:00 2001 From: Art-cyber520 Date: Sun, 9 May 2021 15:25:53 +0200 Subject: [PATCH] Graphsearch A*, heurystyka, action cost --- .idea/misc.xml | 2 +- .idea/sapper.iml | 2 +- bin/Classess/Field.py | 2 +- bin/Classess/Node.py | 150 ++++++++++++++++-- bin/Classess/__pycache__/Field.cpython-38.pyc | Bin 3131 -> 3223 bytes bin/Classess/__pycache__/Mine.cpython-38.pyc | Bin 520 -> 520 bytes bin/Classess/__pycache__/Node.cpython-38.pyc | Bin 2761 -> 4100 bytes .../__pycache__/Player.cpython-38.pyc | Bin 1911 -> 1865 bytes .../__pycache__/__init__.cpython-38.pyc | Bin 174 -> 174 bytes bin/Main/__pycache__/main.cpython-38.pyc | Bin 6496 -> 8484 bytes bin/main/main.py | 40 +++-- resources/Globals.py | 6 +- resources/__pycache__/Globals.cpython-38.pyc | Bin 0 -> 579 bytes resources/__pycache__/__init__.cpython-38.pyc | Bin 0 -> 171 bytes 14 files changed, 174 insertions(+), 28 deletions(-) create mode 100644 resources/__pycache__/Globals.cpython-38.pyc create mode 100644 resources/__pycache__/__init__.cpython-38.pyc diff --git a/.idea/misc.xml b/.idea/misc.xml index 5ea737b..d1e22ec 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/.idea/sapper.iml b/.idea/sapper.iml index c19edc0..d0876a7 100644 --- a/.idea/sapper.iml +++ b/.idea/sapper.iml @@ -2,7 +2,7 @@ - + \ No newline at end of file diff --git a/bin/Classess/Field.py b/bin/Classess/Field.py index b8cdcd3..65e254f 100644 --- a/bin/Classess/Field.py +++ b/bin/Classess/Field.py @@ -74,4 +74,4 @@ class Field(object): def PuttingLargeImage(self, large_img_name): self.large_image_canvas.image = large_img_name - self.large_image_canvas.create_image(0, 0, anchor=NW, image=large_img_name) + self.large_image_canvas.create_image(0, 0, anchor=NW, image=large_img_name) \ No newline at end of file diff --git a/bin/Classess/Node.py b/bin/Classess/Node.py index 2a2cd01..fa2506e 100644 --- a/bin/Classess/Node.py +++ b/bin/Classess/Node.py @@ -1,11 +1,15 @@ from resources.Globals import * +images_coord_list = [] +cell_expense_list = [] + class Node: def __init__(self): self.state = State() - self.parent = None + self.parent = [] self.action = "" + self.priority = 0 class State: @@ -14,6 +18,14 @@ class State: self.direction = "" +def init_data(coord_list, expense_list): + global images_coord_list + global cell_expense_list + + images_coord_list = coord_list + cell_expense_list = expense_list + + def successor(state): node_state_left = Node() @@ -98,11 +110,86 @@ def successor(state): return [node_state_left, node_state_right] -def graph_search(fringe, explored, start_state, end_state_coord): +def get_cell_expense(node): + global images_coord_list + global cell_expense_list + for i in range(0, len(images_coord_list)): + if (images_coord_list[i][0] <= node.state.coord[0] and node.state.coord[0] <= images_coord_list[i][0] + IMAGE_SIZE) and (images_coord_list[i][1] <= node.state.coord[1] and node.state.coord[1] <= images_coord_list[i][1] + IMAGE_SIZE): + return cell_expense_list[i] + + +def heurystyka(node_now): + + if node_now.action == "Left" or node_now.action == "Right": + return node_now.parent[2] + (get_cell_expense(node_now) / 2) + elif node_now.action == "Up": + return node_now.parent[2] + (get_cell_expense(node_now) * 2) + elif node_now.action == "": + return get_cell_expense(node_now) + + +# def graph_search(fringe, explored, start_state, end_state_coord): +# +# node = Node() +# node.state = start_state +# node.parent = node.state +# fringe.append(node) +# iterator = 0 +# +# end_loop = True +# while end_loop: +# if len(fringe) == 0: +# end_loop = False +# #return False +# +# elem = fringe[iterator] +# +# if elem.state.coord == end_state_coord: +# return fringe +# +# explored.append(elem) +# +# another_states = successor(elem.state) +# for i in range(0, len(another_states)): +# n = len(fringe) +# for j in range(0, n): +# if another_states[i].state.coord[0] == fringe[j].state.coord[0] and another_states[i].state.coord[1] == fringe[j].state.coord[1]: +# if another_states[i].state.direction == fringe[j].state.direction: +# break +# else: +# states = [] +# for k in range(0, len(fringe)): +# new_state = [fringe[k].state.coord, fringe[k].state.direction] +# states.append(new_state) +# now_state = [another_states[i].state.coord, another_states[i].state.direction] +# if now_state in states: +# break +# +# another_states[i].parent = elem.state +# fringe.append(another_states[i]) +# else: +# states = [] +# for k in range(0, len(fringe)): +# new_state = [fringe[k].state.coord, fringe[k].state.direction] +# states.append(new_state) +# now_state = [another_states[i].state.coord, another_states[i].state.direction] +# +# if now_state in states: +# break +# +# if another_states[i].state.direction == fringe[j].state.direction: +# another_states[i].parent = elem.state +# fringe.append(another_states[i]) +# iterator += 1 + + +def graph_search_A(fringe, explored, start_state, end_state_coord): node = Node() node.state = start_state - node.parent = node.state + node.priority = heurystyka(node) + node.parent = [node.state.coord, node.state.direction, node.priority] + fringe.append(node) iterator = 0 @@ -110,7 +197,7 @@ def graph_search(fringe, explored, start_state, end_state_coord): while end_loop: if len(fringe) == 0: end_loop = False - #return False + # return False elem = fringe[iterator] @@ -121,10 +208,15 @@ def graph_search(fringe, explored, start_state, end_state_coord): another_states = successor(elem.state) for i in range(0, len(another_states)): + another_states[i].parent = [elem.state.coord, elem.state.direction, elem.priority] + p = heurystyka(another_states[i]) + n = len(fringe) for j in range(0, n): if another_states[i].state.coord[0] == fringe[j].state.coord[0] and another_states[i].state.coord[1] == fringe[j].state.coord[1]: - if another_states[i].state.direction == fringe[j].state.direction: + if another_states[i].state.direction == fringe[j].state.direction and p < fringe[j].priority: + another_states[i].priority = p + fringe[j] = another_states[i] break else: states = [] @@ -133,10 +225,30 @@ def graph_search(fringe, explored, start_state, end_state_coord): states.append(new_state) now_state = [another_states[i].state.coord, another_states[i].state.direction] if now_state in states: - break + index = states.index(now_state) + if p < fringe[index].priority: + another_states[i].priority = p + fringe[index] = another_states[i] + break + else: + break - another_states[i].parent = elem.state + another_states[i].priority = p fringe.append(another_states[i]) + + n1 = len(fringe) + + while n1 > 1: + change = False + for l in range(0, n1 - 1): + if fringe[l].priority > fringe[l + 1].priority: + fringe[l], fringe[l + 1] = fringe[l + 1], fringe[l] + change = True + + n1 -= 1 + + if not change: + break else: states = [] for k in range(0, len(fringe)): @@ -145,9 +257,29 @@ def graph_search(fringe, explored, start_state, end_state_coord): now_state = [another_states[i].state.coord, another_states[i].state.direction] if now_state in states: - break + index = states.index(now_state) + if p < fringe[index].priority: + another_states[i].priority = p + fringe[index] = another_states[i] + break + else: + break if another_states[i].state.direction == fringe[j].state.direction: - another_states[i].parent = elem.state + another_states[i].priority = p fringe.append(another_states[i]) + + n2 = len(fringe) + + while n2 > 1: + change = False + for h in range(0, n2 - 1): + if fringe[h].priority > fringe[h + 1].priority: + fringe[h], fringe[h + 1] = fringe[h + 1], fringe[h] + change = True + + n2 -= 1 + + if not change: + break iterator += 1 diff --git a/bin/Classess/__pycache__/Field.cpython-38.pyc b/bin/Classess/__pycache__/Field.cpython-38.pyc index b7ba1f299d5456ba06c791afe77160b26a980025..8cf8c4b571ec150d00a58de12d5e59d0e4a1e05d 100644 GIT binary patch delta 653 zcmXX^&ubGw6rQ&~C+Tj}{7#x5Dvgm%rIz#}=tXD=MXX@sC6}1&tR?BTDZ5i>Pac{> zE)l|j0Z~wI-aQC<@L%xYWe?tS_n-&CH?{-so9})5&6_tf`=u~1+D~mePH|AW>=Vaa$XX6W#!)Zi zUVsc5vo`@WMFQq8*b+0wgvTaisACuzask^I6VhEiAczTOA+GQwPw_O*FpJq!4V5gq zv%?(Ev*juF#0xUNawOQw6svWMs1@Jk-jl2Ez*kwaKv)VRjg>NN>(W?4V`*6CX{O}~ z%d*^5k;laL^LvAJg^)!P53!Kfve3mhwIJHccPNRvdLK05stvKO+v2tQS^Uvcf@u!U zm}@hrh}-%d#FyGzsQ%|wwP_E!Xq?u6K6g9fzK{XMQzOXbPL+uUS^0EQ)jjo8klgy;?^- zxFsPe;iiO~gogMO+ep=rIy5Lq<+_9$;#cf3Y>DmoPk1QSmQGzAWw|z_2oz|Qs-Td4no7A+L`fDpn6%mvk3))K}XesW&v~@yENI@nmSV4Md z4rw8W@W7q~1ePx6sB?EB>EeTfSg*M}wo^)t=`upstOU9&~k!fT$ z&c*q-5Eo@yx)Y9yKPG*@Uy94po8XLbMb`^QMrJ1_dIHpfkEKs!@tww1NdqEtxbxVl zu<+H;SL-ju1zD^R$)!Ir@YWTAS12_V$C;FgNc1x)3%;=c9veSt6&h@VTF_=|n4hxm zv<5By0C~zkzzOr1G#c>SY0-7~;{2kIV3K}aw^7dG9twn@qAr*SlvbNz8dls& vRo%m4E_Sw>o2{MpGo@!!w-K=AE?L^C9QY%O@XpQndU}@%gVXb1+z{*^H<*Qs diff --git a/bin/Classess/__pycache__/Mine.cpython-38.pyc b/bin/Classess/__pycache__/Mine.cpython-38.pyc index 3767a9cc2fb781199f1261efe12ece825ab87e64..71445718f9828d5cdf24fa7d00ca7c66d31d074e 100644 GIT binary patch delta 20 acmeBR>0sdw<>lpK0D{%JJsY|IG6Dc8tpvLO delta 20 ZcmeBR>0sdw<>lpK0D=OWmW|wh838Cl1cv|s diff --git a/bin/Classess/__pycache__/Node.cpython-38.pyc b/bin/Classess/__pycache__/Node.cpython-38.pyc index d1caddce48f6418ce3c933aa54510f5e6ea5d5e3..fe72028e0ca5aca27b43dcb2d0da8918b89db303 100644 GIT binary patch literal 4100 zcmbVP&2JmW6`z^?;BrM#AC@J{O?xO(BQy#FaStt0A&6niA3>uUk&G0C()F6NrYKUo z;_M2xjO9r=^iUK+QMA{lC<^#rX#NHL0m1fIpn!Yqp@*LOdv7UnB}+{a5<5HdK4yON z-kbMkpUlqs0>7{R_J^m>ZVK^t8dQH41|Q)`e}P5|EeB#tbVVrfs0TtTZG9oMb)?!B zMz(e^axk*Bt7~6~wxc~=$J^Dup254O8+sORPdD`(-gP~{DOw9}FuQ2ULf-69uliFM ze1s=mLKBI$)S|7l)C$^`wxDen_C}(kj)cJJkNTu}7f<>@*rYe=SS{ivRif z-4C{(q>)LtL(}Oc+m8=BJE7ToY?9rmlcn36ud;*At2hjLaTX1F-6-zthC$Z^@Be7~ zSuftcI|$P>O4DuH%&q;y!V4hU%Ywk8O;97GCtdts&9clXf8(`H!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om3 zRJo65+2w~+cs&QAXbmgZP7BHxj#_L3iYt_|>YCv)&T``>smj}ielSOXl!`TE1 zQDkdh)Q6N|eM+G)Z8$fj*-F)3ti%-ika(t??KYcG)>8Evh?$0lFb~M+rU z=Rmpvx`0(Dy0K0DU(ETJ_+1{{eAWNNfNA diff --git a/bin/Classess/__pycache__/Player.cpython-38.pyc b/bin/Classess/__pycache__/Player.cpython-38.pyc index 98cddaa584dd6d5631aaae4a5e40cd600aa5d04a..da481bae1d9481ebf928feb28ce4621a96948728 100644 GIT binary patch delta 200 zcmey)cao1cl$V!_0SLqO0CG|oq8L&bqZm_|qL_e~IfXfj#hoFAC55$x zA%!)SwV64JErl(ZL6bf6C>sMq<~C*^A@6v zone%oT+FxKl$V!_0SH#>_Dtkn3;-!A1cm?r delta 19 ZcmZ3-xQ>xKl$V!_0SF3gS|)NY1^_4X1X2J1 diff --git a/bin/Main/__pycache__/main.cpython-38.pyc b/bin/Main/__pycache__/main.cpython-38.pyc index af7cdba6228d39c13d498f8ef1a35611583056d8..1e5d3a06e9a02536a9375f19f5251eb5fb0ff917 100644 GIT binary patch literal 8484 zcmai3Pi!35d7u9~yIk&)OG>0DS*B%0)~Yro$3{{JiX&MfZ8j1mNE9R!O2(^wqvbAl zcgQzGQ6y%IqI8NDhzg?#nuA-E1d1XCilE4;=(X1zdwPdndSVYnZUuaCf8Y0Jmt0Co zNzD8IX5ah%{=RP>j*b=#`~^S%<>$Zoz%c%cI!FI(bgtuxFPMfQ3}Lp76q9{gDPl=K!qn;LHVjT4;Q4tfUXT+p9 zf%>#KDW*`L5!2!n>Nmo(Vn&?)!q_!e-V|rV8yK4vXT_VS-x9OpE!5}4Iq^2?x5at! z9n|N=1@R8*?}&?{iu!`MB>o8XJK;s~?wa+bDbI!P?BYhkd|*`HJ0J=!RZV4HLg6kn z!?r-fxzp^1sJ(mb+IA@Gpy=SwLd(H(6HojYg)n<&3c9XYaxyVm=ym7Nx6wb3zJ>l- z^d0m+MBhfgguaXZ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jXXZUOxX8$HoN3x&aV~Cq1(Dec( zP+J;qK?QI^Ws{u()vmEu0VDBNrEV~Dm)70{p;0RKOxJ9KH^p?v4DK?Fr6^(h2K8L)P_vO@QFaa8*^4&|YwkCm}f1577wt<3_hUa)JN?4B7hLazaH*wi=oGX@ZH(e8* z`NMEEGez!%w=?C7*I@m~8C0eRqz|SClb_@~aa(1Vo*Do3Kn$doOyxZhW@O@C_<82! zu#QSd%%YLfWR~UD6m}6<{Dv7`aqPHDK-CDlgp9GX@)%cFd6@kUhI|YMAvOeHPGmoa zegos<@DI|IfZt{Ke1{ALArJx*h%IR^Mo=)2DLLfriC2Vo=E0){n4|2gII~aYgahv1 z_l^aS-MQ~4_O%0HAO=ETY$aPMj%mOQeAzw7`9WeoH-J9Py4Gq7H{Ra)g00>?>Rt zEZrvTYc7Iw0)0l{90j*Qv7_-KtN_k)-6e)LjmTz19G=;FGdFCD z?fN~l+VNm*%RFEG#Q^?$`VHQ+Zeeo`qzaf2LezyhP=`8Eb%l(Aeo?m=Q` z8l!xEBrYa4ydB@V?AVR%tC-aO05bg(08qn-PG)(2TAU{(NLeaTMXV~bvM%Z{d=WS~ z!u;@d@lRwSOz0O-s6x0XeK4exU1fNA}fj>;xN7u>HS;pX&m@k{P6ze1VI;t@pUxs$sIK}OPSu%b*V92mC zz)h%#s_8cFdW>IPPkCeA>Rt%HEiWf|36pkhH!Lld)rYv`arooK(r^pOv3a>=@!i3C z2)yDJkeWc4M93pxWsWkVXB{th>?ZPWAz$3Q&7Uig{GJUih*_QaIH0vn+jTq-3%&-* z7`|fnEY=UdTs-*-FQYOR%}4?#iLHOcTV)jRUm-kKsfP7RsjTL(Y<$9H8wL&kd-Sj>R5g z_c6kuCio063~*bRbkupZH`*TEajXkyLjODfe^rYacq?Y$!74*!!%vb$S%OHHv goal_all[i].priority: + elem_min = goal_all[i] + index = fringe.index(elem_min) + fringe = fringe[:index + 1] create_action_list(states, -1) # for i in range(0, len(fringe)): - # print('Node{} = State: {} {}, Parent: {} {}, Action: {}'.format(i + 1, fringe[i].state.coord, fringe[i].state.direction, fringe[i].parent.coord, fringe[i].parent.direction, fringe[i].action)) + # print('Node{} = State: {} {}, Parent: {} {} {}, Action: {}'.format(i + 1, fringe[i].state.coord, fringe[i].state.direction, fringe[i].parent[0], fringe[i].parent[1], fringe[i].parent[2], fringe[i].action)) print(action_list) @@ -310,25 +325,26 @@ def DrawRectangle(): y = 4 color = None - # Chose color for rectangle for i in range(len(field.cell_expense)): if field.cell_expense[i] == 10: color = "None" elif field.cell_expense[i] == 20: color = "yellow" - elif field.cell_expense[i] == 30: - color = "dodger blue" elif field.cell_expense[i] == 40: + color = "dodger blue" + elif field.cell_expense[i] == 80: color = "green4" if color != "None": field.small_field_canvas.create_rectangle(x, y, x + IMAGE_SIZE + 2, y + IMAGE_SIZE + 2, width=2, outline=color) x += player.step - if i > 0 and i % 10 == 0: + if x + IMAGE_SIZE + 2 > field.width: x = 4 y += player.step + + def AddCostCellsToArray(amount, cost): counter = 0 while counter < amount: diff --git a/resources/Globals.py b/resources/Globals.py index f8cc7ff..f3167a8 100644 --- a/resources/Globals.py +++ b/resources/Globals.py @@ -19,12 +19,10 @@ amount_of_sand_cells = 10 sand_cell_cost = 20 amount_of_water_cells = 10 -water_cell_cost = 30 +water_cell_cost = 40 amount_of_swamp_cells = 10 -swamp_cell_cost = 40 - - +swamp_cell_cost = 80 x_start = 5 y_start = 5 diff --git a/resources/__pycache__/Globals.cpython-38.pyc b/resources/__pycache__/Globals.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e0de283ec4cbeec5ce6aa903bda67a7594e9d6e9 GIT binary patch literal 579 zcmZWn!A{#i5M4W)#5jZ$1meoE2&q!rTUF6UjY%xwB*KmYD@)t0cN>fx8|^xR@FVaG z+&FRJPnHW3r~CpZ#-xx+%<8?FH}j+&t#(ka+X&+B{_^*gfzV?i{tpwxPk`zJaYPCj z0&!y#5tEyw#7hKoOv=1WDgyHg^sAsPz!I+#8*+_XWEpauFOd~qAq~I>Zu@Av7Vp3X z@eKyLEg>}f0=LYHjYa^7haa;tq}h5w9}6n>=x(p-+TKCabLh}*1s%OS7ahlKcLHq< z-EONlq=#?Sk+xm0*>KFfhhRT&`g%>}Eagmc z8i^#KQKoXe&c@j!&1v?RDj2>@lwNtO=dO)~>x|_>{OvGM7vZz1Ns>N$m7 zWUi~zd2x;8CcME5J@tNl3kOO_6*3vcS=gUO$4rjF2MZ6e^p@NT{%#WPezqKAldr^?jW2Ng{UPGa$7Egbi$31}XS>PE8 CKc^`G literal 0 HcmV?d00001 diff --git a/resources/__pycache__/__init__.cpython-38.pyc b/resources/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..42e211579fc38f769960ffba2c3777f46dab5802 GIT binary patch literal 171 zcmWIL<>g`k0a%6 nYH@yPQF3Z=OgvCJvm`!Vub}c4hfQvNN@-529muB7K+FID%VjLF literal 0 HcmV?d00001