6,]']>S}Wup8d%qy)6o;]AsVl333>>>>>3333?BBB?$$$?BBB?$$$?BBB?$$$?BBB?$$$TTTEEETTTEEE^TT$$$$TTTTEEEETTTTEEEETTTT$$$$TTTEEETTTEEETTM$$$$BBB$$$BBB$$$BBB$$$BBB$$$""",,""" """,,,,""" DD 33 33DD4C4C4C4C@3@3@3@3  >>>>>>>>BBBB$$$$BBBB$$$$BBBB$$$$BBBB$$$$$$$$펁큁큁M݁ށށ큁큁펁$$$$ށށM$$$$0333C43CDD4CI4DDDDDDDD@$BDD ffww DD33 "" 4CDD 33 33DD@3$##DDDD333333333333D44DDDD333333333333D44DDD433433433$##DDD33#33#33# !BC !f`C@"B0D4`f`UUUUUUUeUVUUUeUUUeUVUUeUUUeUUUUUUUUeUUUUUeUUUUVUUUUUUUUUUUUUUUUUUUVUUUeUUUUUUUUUUUUUUUUUVUUUUUVUUUUUUUUUeUUUUVUeeUUVUUUVUUUUUUUUODDDODDDDOtOwwwwww'ODDDDDDttwwwww'w'ODDODDDDDtOww'""""#######""""4444444"""4444444"""#######펁큁큁M݁ށށVUUUeUUUUUVUUUVUUUUeUUUVUUUUUeUUUeUUUVUUUVUUUUUeUUUeUUUeUUUUUeUUUeUUUUUUUUUUUUUUUUeUUUVUUUVUUUUeUUUUeUUUUUUUUeUUUeUeUUUVUUUUUUUU"/"/"""/""/""""/"""/""#####DDDD3333333344444DDDD3333333344444DDD433433#####DD$33#33#`VeUV`VfUVUUUUUUUUUUUUUUUUeUeUVUVUVUeUUUUUUUUUeVUVUUUUUUUUUUUUUeUUUVUUUVUUUVUeUUUUUUUUeUUUVUVUUUUUUUUUUUUUUUUUUUUUUUUUUUeUeUUUfUUUUUUUUUUUODODDtww'OOOODDtwtww'w'3333""""#####`#fVU3333""""4444`4VeU4433"""4444`4UV433#"""######ff`PV`UVU`eeffVVUUUUUUVUVUUUUUUUUUUUUVUVUVUeUUUUUUUUVUUUVUVUUUeUUUVUUUUUUUUUUUUUUUVUUeUUUUUVUUeUeUUUUVUVUUUUVUUUUUUUUeUUUeUUUUUUUUUeUUeUeUUUUVUU"/"/"""////!""""!!"!"""!"!!""!!""!"!!!!?BBB?$$$?BBB?$$$?BBB?$$$?333BBBB$$$$BBBB$$$$BBBB$$$$3333BBB$$$BBB$$$BBB$$$333?333?BBB?$$$?BBB?$$$?BBB?$$$3333BBBB$$$$BBBB$$$$BBBB$$$$333BBB$$$BBB$$$BBB$$$?2?4?2?4?2?4?2?4C#C#C#C#BBB$$$BBB$$$BBB$$$33C#?BBB?$$$?BBB?$$$?BBB?$$$?233?4?2?433?BBB?$$$?BBB?$$$?BBB?$$$C33#BBB$$$BBB$$$BBB$$$Z"222222222222222222'"22222222'"22222222'$%%%%%%&"222222222222222222'"'"'T5"222222222222222222'"'"'63333337"222222222222222222'"22222222'"22222222'"222222222222222222'"22222222'"22222222'"222222222222222222'"222222222222222222' "222222222222222222' "222222222222222222' "222222222222222222'"222222222222222222'"22222222'"22222222'"222222222222222222'"22222222'"22222222'"222222222222222222'"'"'"222222222222222222'"'"'"222222222222222222'"22222222'"22222222' Fu9  FFI IKL OO /o  %gy %gy?DDDD𪪪wwwwwwwwwwwwwwwwwODDDD𪪪wwwwwwwwwwwwwwwww?33333333333333333333333333333333333333ODDDDD𪪪wwwwwwwwwwwwwwwww?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBDDDDDD𪪪wwwwwwwwwwwwwwwww?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$DDDDDD𪪪wwwwwwwwwwwwwwwwww?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB3ODDDDDwwwwwwwwwwwwwwwwww?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$33ODDDDfffwwwwwwwwwwwwwwwwww?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB33DDDDffffwwwwwwwwwwwwwwwwww?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$333DDDffffffOwwwwwwwwwwwwwwwwww?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB333DDDofffffffOD3𪪪wwwwwwwwwwwwwwwwww?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$3333DDfffffffffODD?33𪪪wwwwwwwwwwwwwwwwww?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB3333ODffffffffffffDDDDD3333wwwwwwwwwwwwwwwwww?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$33333ODffffffffffffffffDDDDD?33333wwwwwwwwwwwwwwwwww?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB33333ODofffffffffffffffffODDDD?333333𪪪wwwwwwwwwwwwwwwww?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$33333OffffffffffffffffffDDDD?333333𯪪wwwwwwwwwwwwwwwww?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB33333OofffffffffffffffffffODDD?3333333wwwwwwwwwwwwwwwww?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$333333OofffffffffffffffffffODDD?3333333wwwwwwwwwwwwwwwww?BBB"""""""""""""""""""""""""""""""BBBB333333ffffffffffffffffffffDDD?33333333wwwwwwwwwwwwwwwww?$$$""$$$333333ffffffffffffffffffffDDD?33333333wwwwwwwwwwwwwwwww?BBB^TTTTTTTTTTTTTTTTTTTTTTTTTTTT.BBB333333fofffffffffffffffffffffODD?33333333wwwwwwwwwwwwwwww?$$$EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE.$$$333333ffofffffffffffffffffffffOD333333333wwwwwwwwwwwwwwww?BBBTTT433STTTTTTTTTTTTTTTTTTTTTTT.BBB333333fffofffffffffffffffffffffOD3333333333wwwwwwwwwwwwwwww?$$$EEE3C43EE33E5C5CEE53E53E5CEEEE.$$$3333333offfofffffffffffffffffffffOD3333333333wwwwwwwwwwwwwwww?BBBTTTCDD4TT3TS3S4STT34S34S3STTTT.BBB3333333offfwwwwwwwwwww?$$$EEECI4EE3EC5CEEEE3CC3CC5CEEEE.$$$3333333off|wwwwwwwwww?BBBTTTDDDDTT33T4S4STT3TS3TS4STTTT.BBB3333333offffffffffffffffffffffffffffffffffffffffffffffffffffffffffffwwwwwwwwww?$$$EEEDDDDEE3EE335CEE53E53E33EEEE.$$$3333333ofmffffffffffffffffffffffffffffffffffffffffffffffffffffffffff|wwwwwwwww?BBBTTTD$BTTTTTTTTTTTTTTTTTTTTTTTT.BBB3333333ofmlfflfflfflfflfflfflfflfflfflfflfflfflff,""l|wwwwwwwww?$$$EEEEDDEEEEEEEEEEEEEEEEEEEEEEEE.$$$3333333ofmlfflfflfflfflfflfflfflfflfflfflfflfflff,""l|wwwwwwwww?BBB^TTTTTTTTTTTTTTTTTTTTTTTTTTTT.BBB3333333ofmffffffffffffffffffffffffffffffffffffffffffffffffffffffffff|wwwwwwwww?$$$""$$$3333333ofmffffffffffffffffffffffffffffffffffffffffffffffffffffffffff|wwwwwwww?BBB"""""""""""""""""""""""""""""""BBBB333333ffmffffffffffffffffffffffffffffffffffffffffffffffffffffffffff|wwwwwww?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$333333ffmffffffffffffffffffffffffffffffffffffffffffffffffffffffffffwwww?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB333333ffmffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$333333ffmffffffffffffffffffffffffffffffffffffffffffffffffffffffffff?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB333333offmlfflfflfflfflfflfflfflfflffƬlfflfflfflffl ?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$333333offmlfflfflfflfflfflfflfflfflffƬlfflfflfflffl ?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB33333fffmffffffff&bffffffffffffffffffffffffffffffffff&bffffffffffff ?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$33333fffmffffffff&bffffffffffffffffffffffffffffffffff&bffffffffffff?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB33333offfmffffffff&bffffffffffffffffffffffffffffffffff&bffffffffffff ?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$33333offfmffffffff&bffffffffffffffffffffffffffffffffff&bffffffffffff ?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB3333ffffmffffffff&bffffffffffffffffffffffffffffffffff&bffffffffffff ?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$3333offffmffffffff&bffffffffffffffffffffffffffffffffff&bffffffffffff?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB333fffffmlfflfflfflfflfflfflfflfflfflfflfflfflfflffl ?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$333offfffmlfflfflfflfflfflfflfflfflfflfflfflfflfflffl ?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB33ffffffmffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$33offffffmffffffffffffffffffffffffffffffffffffffffffffffffffffffffff?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB3fffffffmffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ffffffffmffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBfffffffffmffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$fffffffffmffffffffffffffffffffffffffffffffffffffffffffffffffffffffff?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBfffffffffmlfflfflfflfflfflffƬlfflfflfflfflfflfflffl ?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$fffffffffmlfflfflfflfflfflffƬlfflfflfflfflfflfflffl ?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBfffffffffmffffffffffffffffffffffffffff&bffffffffffffffffffffffffffff ?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$fffffffffmfffffffffffffffffffoffffffff&bffffffffffffffffffffffffffff?2333333333333333333333333333333333333Cfffffffffmffffffffffffffffffffffffff&bffffffffffffffffffffffffffff ?4#fffffffffmffffffffffffffffffofffffff&bffffffffffffffffffffffffffff ?2Cfffffffffmfffffffffffffffffmffffffff&bffffffffffffffffffffffffffff ?4#fffffffffmffffffffffffffffffboffffff&bffffffffffffffffffffffffffff?2CofffffffmlfflfflfflffmflfflfflffƬlfflfflfflfflffl ?4#ffffmlfflfflfflffllfflfflffƬlfflfflfflfflffl ?2Cmffffffffffffffffffffffffffffffffffffffffffffffffffffffff ?4#mfffffffffffffffffffoffffffffffffffffffffffffffffffffffffff?2Cmffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ?4DDDDDDDDDDDDDDD#mffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ?2DDDDODDDDDDDDDDDDC󪪪mffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ?4ODOOOODOODOOO#󪪪mffffffffffffffffffffffffffffffffffffffffffffffffffffffffff?2OtOOOtOtOOwGC󪪪mlfflfflfflfflfflfflfflfflfflfflff,""lfflffl ?4wwwwwww#󪪪mlfflfflfflfflfflfflfflfflfflfflff,""lfflffl ?2wwwwwwwwC󪪪mffffffffffffjffffffffffffffffffjffffffjffjffjffffffff ?4rw''rw#󪪪mffffffffffffjffffffffffffffffffjffffffjffjffjffffffff?2/򿺺////"//"///C󪪪mffffffffffffjffffffffffffffffffjffffffjffjjjffffffff ?4"""/"""""""""""#mffffffffffffjffffffffffffffffffjffffffjffjjjffffffff ?2"""/"""""""""""C333mffffffffffffjffffffffffffffffffjffffffjffjffjffffffff ?4#33333mffffffffffffjffffffffffffffffffjffffffjffjffjffffffff?2C333333mlfflfflfflfflff,""lfflfflfflffƬ,""lfflffl ?4#3333333mlfflfflfflfflff,""lfflfflfflffƬ,""lfflffl ?2C33333333mffffffffffffffffffffffffffffffffffff&bff&bffjffffffffffff ?4#33333333mffffffffffffffffffffffffffffffffffff&bff&bffjffffffffffff?2C333333333mffffffffffffffffffffffffffffffffffff&bff&b&bjffffffffffff ?4#333333333mffffffffffffffffffffffffffffffffffff&bff&b&bjffffffffffff ?2C333333333mffffffffffffffffffffffffffffffffffff&bff&bffjffffffffffff ?4333333333333333333333333333333333333#333333333mffffffffffffffffffffffffffffffffffff&bff&bffjffffffffffff?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB333333333mlfflfflfflffƬlffƬlfflfflff,""lfflfflffl ?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$333333333mlfflfflfflffƬlffƬlfflfflff,""lfflfflffl ?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB333333333mffffffffffff&bffffffffffffffffffffffffff&bffffffffffffffff ?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$333333333mffffffffffff&bffffffffffffffffffffffffff&bffffffffffffffff?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB333333333mffffffffffff&bffffffffffffffffffffffffff&bffffffffffffffff ?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$333333333mffffffffffff&bffffffffffffffffffffffffff&bffffffffffffffff ?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB333333333mffffffffffff&bffffffffffffffffffffffffff&bffffffffffffffff ?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$333333333mffffffffffff&bffffffffffffffffffffffffff&bffffffffffffffff?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB3333mlfflfflfflfflfflfflfflfflfflfflfflfflfflffl ?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$33mlfflfflfflfflfflfflfflfflfflfflfflfflfflffl ?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB3󟙙mffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$󟙙mffffffffffffffffffffffffffffffffffffffffffffffffffffffffff?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB󟙙mffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$󙙙mffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB󙙙mffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$󙙙mffffffffffffffffffffffffffffffffffffffffffffffffffffffffff?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB󙙙mlfflfflfflfflfflfflfflfflfflfflfflfflfflffl ?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$󙙙mlfflfflfflfflfflfflfflfflfflfflfflfflfflffl ?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB󙙙mffffffff&bffffffffffffffffffffffffffffffffffffffffffffffff ?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$󙙙mffffffff&bffffffffffffffffffffffffffffffffffffffffffffffff?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB󙙙mffffffff&bffffffffffffffffffffffffffffffffffffffffffffffff ?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$󙙙mffffffff&bffffffffffffffffffffffffffffffffffffffffffffffff ?BBBJBBB󙙙mffffffff&bffffffffffffffffffffffffffffffffffffffffffffffff ?$$$$$$󙙙mffffffff&bffffffffffffffffffffffffffffffffffffffffffffffff?BBBꎁBBB󙙙mlfflfflfflfflfflfflffƬlfflfflfflfflfflffl ?$$$$$$󙙙mlfflfflfflfflfflfflffƬlfflfflfflfflfflffl ?BBBꁁ133BBB󙙙mffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ?$$$3C43$$$󙙙ffffffffffffffffffffffffffffffffffffffffffffffffffffffffff?BBBꁁCDD4BBB󙙙 ?$$$CI4$$$󙙙?BBBꁁDDDDBBB󙙙wwwwwwwwwwwwwwwwwUUUU?$$$DDDD$$$󙙙wwwwwwwwwwwwwwwwUUUUUUUU?BBBꁁA$BBBB󙙙wwwwwwwwwwwwwUUUUUUUUU?$$$DD$$$󙙙wwwwwwwwwwwwUUUUUUUUU?BBBꎁBBB󙙙wwwwwwwwwwwUUUUUUUUU?$$$$$$󙙙wwwwwwwwwwUUUUUUUU?BBBJBBB󙙙wwwwwwwwww_UUUUUUUU?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$󙙙wwwwwwwwwUUUUUUUU?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB󙙙wwwwwwwww_UUUUUUUU?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$󙙙wwwwwwwwUUUUUUUU?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB󙙙wwwwwww_UUUUUUUU?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$󙙙wwwwwwUUUUUUUU?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB󙙙wwwww_UUUUUUU?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$󙙙wwwww_UUUUUUU?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB󙙙wwwUUUUUUUU?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$󙙙wwUUUUUUUU?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB󙙙w_UUUUUUU?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$󙙙_UUUUUUU?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB󙙙UUUUUUU?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$󙙙UUUUUUU?BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB󙙙UUUUUUU?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$󙙙UUUUUUU?33333333333333333333333333333333333333󙙙_UUUUUUm-- title: Paddix -- author: Brendos. -- desc: Pen/Paper Game Paddocks -- version: 0.1 -- script: lua ---------------- pico8 srand=math.randomseed sqrt=math.sqrt abs=math.abs min=math.min max=math.max flr=math.floor pi=math.pi count=table.getn add=table.insert function band(a,b) return flr(a)&flr(b) end function bor(a,b) return flr(a)|flr(b) end function bxor(a,b) return flr(a)^flr(b) end function bnot(a,b) return flr(a)~flr(b) end function shl(a,b) return a<>b end function all(list) local i=0 return function() i=i+1; return list[i] end end function del(t,a) for i,v in ipairs(t) do if v==a then t[i]=t[#t] t[#t]=nil return end end end function rnd(a) a=a or 1 return math.random()*a end function pal(c0,c1,type) c0=c0 or -1 c1=c1 or -1 type=type or 0 if c0<0 and c1<0 then if type==0 then for i=0,15 do poke4(0x7FE0+i,i) end else PICO8_PALETTE() end else c0=flr(c0%16) if c1<0 then c1=c0 end c1=flr(c1%16) if type==0 then poke4(0x7FE0+c0,c1) else local stri for i=0,5 do stri=#__p8_pal-(c1+1)*6+i poke4(0x3FC0*2+#__p8_pal-(c0+1)*6+i,tonumber(__p8_pal:sub(stri,stri),16)) end end end end -- system menu stuff -- menu: Toggle Mouse Toggle Bubble-Effect End Current Game function ITEM1() mactive = not mactive end function ITEM2() bgbubbles=not bgbubbles end function ITEM3() destroy_board() clear_bubbles() cart_state=0 -- menuitem(3) -- music(0) end GameMenu={ITEM1,ITEM2, ITEM3} function MENU(index) GameMenu[index+1]() end function BOOT() cart_state=0 hpg=0 -- help page game_active=false mactive,mbtn,mposx,mposy=false,0,0,0 bgbubbles=true ai_init() init_menu() init_bubbles() -- system menu stuff -- menuitem(1,"mouse:"..(mactive==true and "on" or "off"),mouse_cb) -- menuitem(2,"bg effect:"..(bgbubbles==true and "on" or "off"), bubbles_cb) -- music(0) end function TIC() poke(0x3FFB,1) -- tun off mouse pointer UPDATE() DRAW() end function UPDATE() if cart_state==0 then update_menu() elseif cart_state==1 then if bgbubbles then update_bubbles() end if game_active then update_pointer() if(not ai_active) then update_player() else if cur_player==1 then update_player() else ai_makemove() end end update_board() else if btnp(4) or btnp(5) then destroy_board() clear_bubbles() cart_state=0 -- music(0) end end elseif cart_state==2 then if btnp(4) or btnp(5) then cart_state=0 hpg=0 elseif btnp(1) then if hpg<4 then hpg=hpg+1 end elseif btnp(0) then if hpg>0 then hpg=hpg-1 end end end end function DRAW() if cart_state==0 then cls(12) draw_menu() elseif cart_state==1 then cls(0) if bgbubbles then map(60,0,20,17) draw_bubbles() map(80,0,10,17,160,0) else map(30,0) end draw_board() draw_fences() draw_player() -- paddix logo in main play spr(74,167,62,0,1,0,0,2,2) spr(76,179,62,0,1,0,0,2,2) spr(78,191,62,0,1,0,0,2,2) spr(78,203,62,0,1,0,0,2,2) spr(106,215,62,0,1,0,0,2,2) spr(108,223,62,0,1,0,0,2,2) if game_active then draw_pointer() else draw_end_screen() end elseif cart_state==2 then draw_helpscreen() end end function set_mouse(x,y) poke(0x0FF84,x) poke(0x0FF85,y) end --------------- initers function init_game() init_board(board_selx, board_sely,bcol_sel) init_player() init_pointer() ai_setplayer(ai_level) -- menuitem(3,"end current game",end_cb) -- music(6) end function init_player() cur_player=1 plyr_cols={[0]=0,colors_p1[pcol_sel],colors_p2[pcol_sel]} plyr_scor={0,0} input_tmr=10 input_ctr=0 end function init_pointer() pntr={} -- start middle of board pntr.x=board.px+(board.sx/2)*8 pntr.y=board.py+(board.sy/2)*8 end function init_board(xsz, ysz, bgcol) board={} board.sx=xsz -- boardsize board.sy=ysz board.ox=81 -- boardoffset for user interface purposes board.oy=69 board.px=board.ox-((4+(board.sx*8))/2) -- board screen pos board.py=board.oy-((4+(board.sy*8))/2) board.cl=colors_bg[bgcol] board.co=board.sx*board.sy -- open cells game_active=true -- add blank cells to the board, -- these draw the fences and record player ownership cells={} for l=1,board.sx*board.sy do add_blank_cell() end end function init_menu() pcol_sel=0 bcol_sel=0 colors_p1={[0]=2, 1,4, 7, 9,4, 11,13} colors_p2={[0]=10,7,11,13,1,9,4, 9} colors_bg={[0]=6, 8,0, 15,5} board_selx=14 board_sely=12 --0=no a.i, 1=easy,2=normal,3=hard ai_level=0 icon_tmr_max=3 icon_tmr_cnt=icon_tmr_max icon_frm=0 menu={} menu.xpos=64 menu.ypos=40 menu.yspc=12 menu.max=7 menu.at=0 -- create 4 flowers for random placement on the main menu flowers={} for l=1,12 do add_flower() end end function ai_init() ai_active=false ai_errorlevel=20 loopsafety=0 --used in makemove, sanity check to ensure no lockups ai_checks={} end function init_bubbles() bubbles={} btmax=2 btctr=0 end ------------- adders function add_blank_cell() local cell={} cell.fn=0 -- fences, uses bit opperations cell.pl=0 -- what player owns it table.insert(cells,cell) end function add_flower() local flwr={} flwr.x=flr(rnd(24)) flwr.y=flr(rnd(9)) flwr.t=flr(rnd(2)) add(flowers, flwr) end function add_bubble() local bubble={} bubble.xpos=64 bubble.ypos=64 bubble.xvec=rnd(5)-2.5 bubble.yvec=rnd(5)-2.5 bubble.radi=rnd(5) bubble.radd=rnd(0.8)+0.2 bubble.colr=flr(rnd(14)) if abs(bubble.xvec) < 0.2 and abs(bubble.yvec) < 0.2 then local axis=flr(rnd(2)) if axis==0 then bubble.xvec=bubble.xvec+((bubble.xvec<0) and -1 or 1) else bubble.yvec=bubble.yvec+((bubble.yvec<0) and -1 or 1) end end add(bubbles,bubble) end function ai_addcheck(brdidx, fnccount) local chk={} chk.bindex=brdidx chk.fcount=fnccount add(ai_checks, chk) end ------------- updaters function update_pointer() if mactive then pntr.x,pntr.y,mbtn,_,_,_,_=mouse() -- get mouse end if not mactive then if btn(2) or btn(10) then if pntr.x>board.px-2 then pntr.x=pntr.x-0.5 else pntr.x=pntr.x+(board.sx*8)+5 end elseif btn(3) or btn(11) then if pntr.x<=board.px+(board.sx*8)+2 then pntr.x=pntr.x+0.5 else pntr.x=pntr.x-(board.sx*8)-4 end end if btn(0) or btn(8) then if pntr.y>board.py-2 then pntr.y=pntr.y-0.5 else pntr.y=pntr.y+(board.sy*8)+5 end elseif btn(1) or btn(9) then if pntr.y<=board.py+(board.sy*8)+2 then pntr.y=pntr.y+0.5 else pntr.y=pntr.y-(board.sy*8)-4 end end end end --mouse status, pos and button --collected in update_pointer() function update_player() if mactive then if mbtn==true then if (pntr.x>board.px-2 and pntr.xboard.py-2 and pntr.y0 then c2res=set_cell_fence(cur_cell-1,1) end elseif cur_fence==1 then c1res=set_cell_fence(cur_cell,1) sfx(0) if xmod0 then c2res=set_cell_fence(cur_cell-board.sx,3) end elseif cur_fence==3 then c1res=set_cell_fence(cur_cell,3) sfx(0) if ymod18 then board_selx=4 end elseif menu.at==1 then --board height board_sely=board_sely+1 sfx(3) if board_sely>15 then board_sely=4 end elseif menu.at==2 then ai_level=ai_level+1 sfx(3) if ai_level>3 then ai_level=0 end elseif menu.at==3 then pcol_sel=pcol_sel+1 sfx(3) if pcol_sel>7 then pcol_sel=0 end elseif menu.at==4 then bcol_sel=bcol_sel+1 sfx(3) if bcol_sel>5 then bcol_sel=0 end end elseif btnp(1) then menu.at=menu.at+1 if(menu.at>menu.max-1) then menu.at=menu.max-1 else sfx(2) end elseif btnp(0) then menu.at=menu.at-1 if(menu.at<0) then menu.at=0 else sfx(2) end end icon_tmr_cnt=icon_tmr_cnt-1 if icon_tmr_cnt==0 then icon_tmr_cnt=icon_tmr_max icon_frm=icon_frm+1 if icon_frm>3 then icon_frm=0 end end end function update_bubbles() for bubble in all(bubbles) do bubble.xpos=bubble.xpos+bubble.xvec bubble.ypos=bubble.ypos+bubble.yvec if bubble.xpos > 174 + bubble.radi then del(bubbles,bubble) elseif bubble.xpos < -bubble.radi then del(bubbles,bubble) end if bubble.ypos > 148 + bubble.radi then del(bubbles,bubble) elseif bubble.ypos< -bubble.radi then del(bubbles,bubble) end end if btctr==0 then btctr=btmax if flr(rnd(10))<3 then add_bubble() end add_bubble() else btctr=btctr-1 end end ------------- drawers function draw_menu_arrows(x,y,menupos,thispos) if menupos==thispos then pal(1,2) pal(2,1) else pal(1,13) pal(2,14) end spr(130,x,y,0) spr(138,x+6,y,0) spr(131,x+12,y,0) pal() end function draw_menu_buttons(x,y,menupos,thispos) if menupos==thispos then pal(1,2) pal(2,1) else pal(1,13) pal(2,14) end spr(133,x,y,0) spr(138,x+6,y,0) spr(132,x+12,y,0) pal() end function draw_pointer() local spridx=14 pal(4,cur_player==1 and colors_p1[pcol_sel] or colors_p2[pcol_sel]) if mactive then spridx = (pntr.x>board.px-2 and pntr.xboard.py-2 and pntr.y0 then rect(board.px+x*8-4, board.py+y*8-4, 2, 2, plyr_cols[cells[celladdr].pl]) end end end pal() end function draw_fences() for y=1,board.sy do for x=1,board.sx do cell_idx=((y-1)*board.sx)+(x-1) xmpm18=board.px+(x-1)*8 ympm18=board.py+(y-1)*8 --left fence fcol=get_cell_fence(cell_idx, 0) if fcol > 0 then line(xmpm18+1,ympm18+2,xmpm18+1,ympm18+7,plyr_cols[fcol]) if x==1 then line(xmpm18,ympm18+2,xmpm18,ympm18+7,plyr_cols[fcol]) end end --right fence fcol=get_cell_fence(cell_idx, 1) if fcol > 0 then line(xmpm18+8,ympm18+2,xmpm18+8,ympm18+7,plyr_cols[fcol]) if x==board.sx then line(xmpm18+9,ympm18+2,xmpm18+9,ympm18+7,plyr_cols[fcol]) end end --top fence fcol=get_cell_fence(cell_idx, 2) if fcol > 0 then line(xmpm18+2,ympm18+1,xmpm18+7,ympm18+1,plyr_cols[fcol]) if y==1 then line(xmpm18+2,ympm18,xmpm18+7,ympm18,plyr_cols[fcol]) end end --bottom fence fcol=get_cell_fence(cell_idx, 3) if fcol > 0 then line(xmpm18+2,ympm18+8,xmpm18+7,ympm18+8,plyr_cols[fcol]) if y==board.sy then line(xmpm18+2,ympm18+9,xmpm18+7,ympm18+9,plyr_cols[fcol]) end end end end end function draw_menu() cls(11) -- grass for k=0,3 do for l=0,7 do spr(70,l*32,32+(k*32),0,1,0,0,4,4) end end --fence spr(100,0,25,0,1) spr(101,120,25,0,1) for l = 0,15 do spr(64,(l*16)-8,1,0,1,0,0,2,4) end -- paddix banner spr(74,19+56,10,0,1,0,0,2,2) spr(76,35+56,10,0,1,0,0,2,2) spr(78,51+56,10,0,1,0,0,2,2) spr(78,67+56,10,0,1,0,0,2,2) spr(106,85+56,10,0,1,0,0,1,2) spr(108,99+56,10,0,1,0,0,2,2) -- flowers for flw in all(flowers) do spr(68+flw.t,flw.x*10,menu.ypos+(flw.y*10),0) end print("Board Width:", menu.xpos,menu.ypos,menu.at==0 and 2 or 14) print(board_selx, menu.xpos+(board_selx<10 and 78 or 73),menu.ypos,menu.at==0 and 2 or 14) draw_menu_arrows(menu.xpos+92,menu.ypos-1,menu.at,0) print("Board Height:", menu.xpos,menu.ypos + menu.yspc,menu.at==1 and 2 or 14) print(board_sely, menu.xpos+(board_sely<10 and 78 or 73),menu.ypos + menu.yspc,menu.at==1 and 2 or 14) draw_menu_arrows(menu.xpos+92,menu.ypos-1+menu.yspc,menu.at,1) print("Player 2:", menu.xpos,menu.ypos + menu.yspc*2,menu.at==2 and 2 or 14) draw_menu_arrows(menu.xpos+92,menu.ypos-1+(menu.yspc*2),menu.at,2) print("Colors:", menu.xpos,menu.ypos + menu.yspc*3,menu.at==3 and 2 or 14) draw_menu_arrows(menu.xpos+92,menu.ypos-1+(menu.yspc*3),menu.at,3) print("Background:", menu.xpos,menu.ypos + menu.yspc*4,menu.at==4 and 2 or 14) draw_menu_arrows(menu.xpos+92,menu.ypos-1+(menu.yspc*4),menu.at,4) print("Help", menu.xpos,menu.ypos + menu.yspc*5,menu.at==5 and 2 or 14) draw_menu_buttons(menu.xpos+92,menu.ypos-1+(menu.yspc*5),menu.at,5) print("Start Game", menu.xpos,menu.ypos + menu.yspc*6,menu.at==6 and 2 or 14) draw_menu_buttons(menu.xpos+92,menu.ypos-1+(menu.yspc*6),menu.at,6) if menu.at==2 then pal(13,2) pal(14,1) end spr(40,menu.xpos+67,menu.ypos+menu.yspc*2-3,1,1,2,0,2,1,false,true) spr(40,menu.xpos+67,menu.ypos+menu.yspc*2+1,1,1,0,0,2,1) pal() if ai_level==0 then spr(56,menu.xpos+71,menu.ypos+menu.yspc*2-1,0) else spr(56+ai_level,menu.xpos+71,menu.ypos+menu.yspc*2-1,0) end spr(10+icon_frm, menu.xpos-11, menu.ypos+menu.yspc*menu.at-2,0) if menu.at==3 then pal(13, 2) pal(14, 1) end pal(2,colors_p1[pcol_sel]) pal(3,colors_p2[pcol_sel]) spr(26,menu.xpos+67, menu.ypos+menu.yspc*3-1,0,1,0,0,2,1) pal() if menu.at==4 then pal(13, 2) pal(14, 1) end pal(2,colors_bg[bcol_sel]) spr(42,menu.xpos+67, menu.ypos+menu.yspc*4-1,0,1,0,0,2,1) pal() end function draw_end_screen() rectb(42,27, 76, 29,13) rect(46,32,67,19,3) spr(32,45,30,0,1,0,0,2,2) spr(32,45,45,0,1,2,0,2,1) spr(32,99,30,0,1,1,0,2,2) spr(32,99,37,0,1,3,0,2,2) for l=2,6 do spr(33,45+l*8,30,0,1,0) spr(33,45+l*8,45,0,1,2,0) end if plyr_scor[1] > plyr_scor[2] then print("Plyr-1 Wins",52,34,7) elseif plyr_scor[1] < plyr_scor[2] then print("Plyr-2 Wins",51,34,7) else print("It's A Draw",51,34,7) end pal(1,7) pal(2,6) spr(148,68,43,0,1,0,0,3,1) spr(136,91,43,0) pal() --print("(A/Z)",68,44,7) end function draw_help_buttons(type,y) pal(1,9) pal(2,8) local x if type==0 then x=89 spr(135,x,y,0) spr(129,x+9,y,0) spr(138,x+15,y,0) spr(148,x+21,y,0,1,0,0,4,1) elseif type==4 then x=89 spr(135,x,y,0) spr(128,x+9,y,0) spr(138,x+15,y,0) spr(148,x+21,y,0,1,0,0,4,1) else x=82 spr(144,x,y,0,1,0,0,4,1) spr(138,x+27,y,0) spr(148,x+33,y,0,1,0,0,4,1) end pal() end function draw_helpscreen() cls(5) if hpg==0 then print("Paddix Help:",84,2,9) print("Players take turns building fences in the",8,12,7) print("field, when a new fence encloses a",8,22,7) print("paddock, a point is awarded to that",8,32,7) print("player and another turn is granted.",8,42,7) print("The game ends when all paddocks are",8,52,7) print("claimed.",8,62,7) print("The winner is the player with the most",8,80,7) print("paddocks at the end of the game.",8,90,7) elseif hpg==1 then print("Gamepad Controls:",68,2,9) pal(1,7) pal(2,13) spr(130,8,12,0) spr(138,14,12,0) spr(131,20,12,0) spr(138,26,12,0) spr(128,32,12,0) spr(138,38,12,0) spr(129,44,12,0) spr(132,8,22,0) spr(138,14,22,0) spr(133,20,22,0) pal() print(": Move Pointer", 54,13,7) print(": Build Fence", 54,23,7) print("Pad 1 and Pad 2 have the same effect.",8,33,7) print("Mouse Controls:",73,46,9) print("Mouse-Move: Move Pointer",8,56,7) print("Left-Click : Build Fence",8,66,7) print("Gamepad controls are set by default.",8,82,7) print("Toggle mouse controls in the system menu.",8,92,7) elseif hpg==2 then print("Placing Fences:",72,2,9) print("Move the pointer between the white fence",8,12,7) print("posts at the highlighted locations to",8,22,7) print("place a new fence, all other points are",8,32,7) print("ignored.",8,42,7) spr(14,64,56,0,1,0,0,2,2) spr(28,150,46,0,1,0,0,2,3) print("Pointer:",16,58,3) print(":Zones",172,58,3) print("Once all four sides are fenced, that",8,76,7) print("paddock gets a pin in the color of the",8,86,7,5) print("player that claimed it.",8,96,7) elseif hpg==3 then print("Player 2 Modes:",72,2,9) print("Paddix can be played by two humans or by",8,12,7) print("one human and the computer A.I player",8,22,7) print("The default mode for player 2 is human",8,32,7) print("player, displayed as a face in the menu.",8,42,7) print("The A.I player has three skills which",8,60,7) print("affect it's likelihood of making a bad move.",8,70,7) print("Easy: Normal: Hard:",2,90,7,5) spr(57,32,85,0,2) spr(58,128,85,0,2) spr(59,218,85,0,2) elseif hpg==4 then print("Paddix Credits:",74,2,9) print("Design:",56,22,7) print("Programming:",56,32,7) print("Artwork:",56,42,7) print("Sounds:",56,52,7) print("Brendos",129,22,6) print("Brendos",129,32,6) print("Brendos",129,42,6) print("Brendos",129,52,6) end draw_help_buttons(hpg,128) end function draw_bubbles() for bubble in all(bubbles) do circ(bubble.xpos, bubble.ypos, bubble.radi,bubble.colr) circb(bubble.xpos, bubble.ypos, bubble.radi,15) if bubble.radi < 25 then bubble.radi=bubble.radi+bubble.radd end end end function draw_player() draw_player_box(16,1) print("P1: "..get_score_label(1), 188, 21, cur_player==1 and 3 or 14) spr(56,176,20,0) draw_player_box(104,2) print("P2: "..get_score_label(2), 188,109, cur_player==2 and 3 or 14) spr(56+ai_level,176,108,0) end function draw_player_box(ypos, plyridx) if cur_player==plyridx then pal(13,plyridx==1 and colors_p1[pcol_sel] or colors_p2[pcol_sel]) map(90,0,8,2,168,ypos) -- pal() else pal(13,plyridx==2 and colors_p2[pcol_sel] or colors_p1[pcol_sel]) map(90,2,8,2,168,ypos) end pal() end ---------------- misc function set_cell_fence(cell_id, fence) if cell_id >= 0 and cell_id < board.sx*board.sy then local old_fcount=get_fence_count(cell_id) local cell=cells[cell_id+1].fn local mask=cur_player<<(fence*2) cell=cell|mask cells[cell_id+1].fn=cell if old_fcount==3 and get_fence_count(cell_id)==4 then cells[cell_id+1].pl=cur_player return true else return false end end end -- takes a linear array index, returns the board xy of that cell function get_cell_xy(cellid) return cellid%board.sx, flr(cellid/board.sx) end --returns player with that fence or 0 for none function get_cell_fence(cell_id, fence) local cell=cells[cell_id+1] return (cell.fn>>(fence*2))&0x03 end --returns number of fences set on this cell function get_fence_count(cell_id) local fc=0 local cell=cells[cell_id+1] if cell.fn&0x0003~=0 then fc=fc+1 end if cell.fn&0x000c~=0 then fc=fc+1 end if cell.fn&0x0030~=0 then fc=fc+1 end if cell.fn&0x00c0~=0 then fc=fc+1 end return fc end function count_open_cells() local oc=0 for l=1,board.sx*board.sy do if get_fence_count(l-1) < 4 then oc=oc+1 end end return oc end -- get the board array-address of the cell -- to the left of this one function get_index_left(boardx, boardy) if boardx-1 >= 0 then return ((boardy*board.sx)+boardx-1) else return -1 end end -- get the board array-address of the cell -- to the right of this one function get_index_right(boardx, boardy) if boardx+1 < board.sx then return ((boardy*board.sx)+boardx+1) else return -1 end end --get the board array-address of the cell below this one function get_index_above(boardx, boardy) if boardy-1 >= 0 then return (((boardy-1)*board.sx)+boardx) else return -1 end end --get the board array-address of --the cell above this one function get_index_below(boardx, boardy) if boardy+1 < board.sy then return (((boardy+1)*board.sx)+boardx) else return -1 end end function do_corner_protect() --inside top corners if (pntr.x<=(board.px)+1 and pntr.y<=(board.py)+1) or (pntr.x>board.px+(board.sx*8) and pntr.y<=(board.py)+1) then return true end --inside bottom corners if (pntr.x<=(board.px+1) and pntr.y>board.py+(board.sy*8)) or (pntr.x>board.px+(board.sx*8) and pntr.y>board.py+(board.sy*8)) then return true end return false end --returns what cell the pointer is in function get_pointer_cell() local x,y=0,0 x=flr((pntr.x-board.px-1)/8) y=flr((pntr.y-board.py-1)/8) return (y*board.sx)+x end function get_pointer_cell_xext(faredge) local y=flr((pntr.y-board.py-2)/8) if faredge==true then return y*board.sx+board.sx-1 else return y*board.sx end end function get_pointer_cell_yext(faredge) local x=flr((pntr.x-board.px-2)/8) if faredge==true then return ((board.sy-1)*board.sx)+x else return x end end --returns what fence in the current cell the pointer is on --0=left, 1=right,2=top,3=bottom -- -1=not on fence function get_pointer_fence() local x,y=0,0 x=((pntr.x-board.px-1)%8) y=((pntr.y-board.py-1)%8) -- is it above or below if x>=2 and x<=5 then if (y<=2) then return 2 end if (y>=5) then return 3 end elseif y>=2 and y<=5 then if (x<=2) then return 0 end if (x>=5) then return 1 end end return -1 end function pointer_to_board() local cell=0 local fence=get_pointer_fence() if pntr.y<=board.py+1 then cell=get_pointer_cell_yext(false) fence=2 elseif pntr.y>board.py+(board.sy*8) then cell=get_pointer_cell_yext(true) fence=3 elseif pntr.x<=board.px+1 then cell=get_pointer_cell_xext(false) fence=0 elseif pntr.x>board.px+(board.sx*8) then cell=get_pointer_cell_xext(true) fence=1 else cell=get_pointer_cell() end return cell,fence end function destroy_board() game_active=false for cell in all(cells) do del(cells, cell) end board.sx,board.sy,board.ox,board.oy=0,0,65,57 board.px,board.py,board.cl=0,0,0 board.co=0 end function clear_bubbles() for bbl in all(bubbles) do del(bubbles,bbl) end end function get_score_label(player_idx) local scrlbl if plyr_scor[player_idx]<10 then scrlbl="00"..plyr_scor[player_idx] elseif plyr_scor[player_idx]<100 then scrlbl="0"..plyr_scor[player_idx] else scrlbl=plyr_scor[player_idx] end return scrlbl end function ai_setplayer(menuskill) ai_errorlevel=0 ai_active=not(menuskill==0) if menuskill>0 then ai_errorlevel=((menuskill-1)*16)+8 end end function ai_clearchecks() for cchk in all(ai_checks) do del(ai_checks, cchk) end end function ai_createchecks(mode, val) ai_clearchecks() for lp=1,board.sx*board.sy do local fcount=get_fence_count(lp-1) if mode==0 then if fcountval then ai_addcheck(lp-1, fcount) end end end end function ai_makemove() -- input delay if input_ctr==0 then -- find cells with 3 set, -- if found, end turn here -- else keep going if ai_pickany_of3() == true then return end -- sanity check to ensure no -- runaway loop loopsafety=0 -- go through the board and -- collect cells with 0 or 1 -- fences set ai_createchecks(0,2) -- find cells with less than 2 fences set if #ai_checks>0 then -- pick a cell from checks-list repeat loopsafety=loopsafety+1 local error=flr(rnd(ai_errorlevel))--it's chance of making an error move local cc=flr(rnd(#ai_checks)) local cl=ai_checks[cc+1].bindex local brk=false if error==0 then for lb=0,3 do brk=ai_placefence(cl,lb) if brk==true then -- break out of this loop, it will also break main loop break end end else local neighbors={[0]=true,true,true,true} -- find out how many lines -- are set in the neighbors -- paddocks local px,py=get_cell_xy(cl) local freen=4 for nl=0,3 do neighbors[nl]=ai_checkneighbor_count(px,py,nl) if(not neighbors[nl]) then freen=freen-1 end end if freen>0 then local fn=0 repeat fn=flr(rnd(4)) until(neighbors[fn]==true) brk=ai_placefence(cl,fn) else brk=false end end if loopsafety==150 then ai_pickany_to3() end until(brk==true) else ai_pickany_to3() end else input_ctr=input_ctr-1 end end -- pick any random cell with 3 -- fences set function ai_pickany_of3() local ret=false ai_createchecks(1,3) if #ai_checks > 0 then local cc=flr(rnd(#ai_checks)) local cl=ai_checks[cc+1].bindex for lp=0,3 do if get_cell_fence(cl, lp)==0 then ret=ai_placefence(cl,lp) break end end end return ret end -- pick any random cell with 3 -- or less fences and set first -- available fence function ai_pickany_to3() ai_createchecks(0,4) -- find cells with less than 2 fences set if #ai_checks>0 then local cc=flr(rnd(#ai_checks)) local cl=ai_checks[cc+1].bindex for lp=0,3 do if get_cell_fence(cl,lp)==0 then ai_placefence(cl,lp) return end end end end -- reads each cell data into array -- for processing called "checks" function ai_getchecks() for l=1,#cells do local fcount=get_fence_count(l-1) ai_addcheck(l,fcount) end end -- returns true if neighbor has -- less than 2 fences function ai_checkneighbor_count(curx,cury,curfence) local curncell if curfence==0 then curncell=get_index_left(curx,cury) elseif curfence==1 then curncell=get_index_right(curx,cury) elseif curfence==2 then curncell=get_index_above(curx,cury) else curncell=get_index_below(curx,cury) end if curncell>=0 then return get_fence_count(curncell)<2 else return true end end function ai_placefence(cell,fence) if get_cell_fence(cell, fence)==0 then local px,py=get_cell_xy(cell) pntr.x=board.px+(px*8)+1 pntr.y=board.py+(py*8)+1 if fence==0 then pntr.y=pntr.y+3 elseif fence==1 then pntr.y=pntr.y+3 pntr.x=pntr.x+6 elseif fence==2 then pntr.x=pntr.x+4 else pntr.x=pntr.x+4 pntr.y=pntr.y+6 end -- place_fence does the player -- changeover place_fence() return true end return false end