Tesi Robotica Analisi, progettazione e implementazione... | Page 138

i i “LP_Tesi” — 2013/10/17 — 18:27 — page 138 — #138 i 138 i 6. SECONDA RELEASE Algoritmo 6.12 Regole per il calcolo delle direzioni Pt.1 1 2 3 4 5 6 7 8 9 rule r1 (step==0 && addr==0); delta .deq(); top<=top+egap; left <=left+egap; result .enq(BitScoreDir{dir:WEST,score:gap∗2}); north<=gap∗2; ramNorth.enq(BitScoreDir{dir:WEST,score:0}); maxu <= maxnwn(delta.first+left,gap∗2+egap); endrule 10 11 12 rule r2 (step==0 && addr!=0 && col==0); delta .deq(); ramNorth.deq(); 13 14 15 16 17 BitScore cWest = left + gap; BitScore cond; if (ramNorth.first() . dir!=NORTH) cond=gap; else cond=egap; 18 19 20 21 22 23 24 25 26 let maxi = maxuw(maxu,cWest); maxu <= maxnwn(delta.first+north,ramNorth.first().score+cond); result .enq(maxi); north<=ramNorth.first().score; ramNorth.enq(maxi); gapWest<=maxi.dir; west<=maxi.score; endrule 27 28 29 30 rule r3 (step==0 && addr>size && addr==row && col!=0); delta .deq(); ramNorth.deq(); BitScore cWest,cond; 31 32 33 34 35 36 left <=left+egap; if (gapWest!=WEST) cWest = west + gap; else cWest = west + egap; if (ramNorth.first() . dir!=NORTH) cond=gap; else cond=egap; 37 38 39 40 41 42 43 let maxi = maxuw(maxu,cWest); maxu <= maxnwn(delta.first+left,ramNorth.first().score+cond); north<=ramNorth.first().score; result .enq(maxi); ramNorth.enq(maxi); endrule i i i i