`ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÏüÿÿÏüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿDDÿODDôODDôODDôODDôÿDDÿÿÿÿÿ >u'DDDDDD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DDDDDDDDDDDDDD@DD@DD@DDÀ @DD@DD@DDÀ À @DD@DD@DDÀ @DD@DD@DDDDDDDDDDDDDDDDDDDDDD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DDDDDDDDDDDDDDDDDDDDDDDDDDDD@DD@DD@DD@DD@DD@DD@DD@DD@DDÀ @DD@DD@DD@DD@DD@DDÀ @DD@DD@DD@DD@DD@DD@DD@DD@DDDDDDDDDDDDDDDDDDDDDDDDDDDD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DDDDDDDDDDDDDDDDDDDDDD@DD@DD@DDÀ @DD@DD@DDÀ À @DD@DD@DDÀ @DD@DD@DDDDDDDDDDDDDD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DD@DDDDDDDDðÿðÿðÿÿðÿÿðÿÿÿÿÿÿÿÿÿÿÿÿÿððÿÿÿÿÿðÿðÿððÿðÿðÿÿÿÿÿðÿÿÿÿððÿððððÿðÿÿÿðÿðððððððððÿÿðððððððÿðÿðÿððððÿððÿ˜-- title: Potato game -- author: Newpson -- 7x7 initial_field = { {-1, -1, 1, 1, 1, -1, -1}, {-1, 0, 1, 1, 1, 0, -1}, { 1, 1, 1, 1, 1, 1, 1}, { 1, 1, 1, 0, 1, 1, 1}, { 1, 1, 1, 1, 1, 1, 1}, {-1, 0, 1, 1, 1, 0, -1}, {-1, -1, 1, 1, 1, -1, -1} } field = initial_field count = 32 turns = 0 history = "" x1, y1, x2, y2, selected = -1, -1, -1, -1, false click_thresh = false function TIC() mx, my, click = mouse() if (not click and click_thresh) then click_thresh = false end if (click and not click_thresh) then click_thresh = true if (mx > 8 and mx < 64 and my > 8 and my < 64) then if not selected then x1 = mx//8 y1 = my//8 selected = true else x2 = mx//8 y2 = my//8 if (x1 == x2 or y1 == y2) then x3, y3 = (x2+x1)//2, (y2+y1)//2 if ((math.abs(x2-x1) == 2 or math.abs(y2-y1) == 2) and field[y1][x1] == 1 and field[y2][x2] == 0 and field[y3][x3] == 1) then field[y1][x1] = 0 field[y2][x2] = 1 field[y3][x3] = 0 count = count-1 history = history.."("..x1..","..y1..")>("..x2..","..y2..")" if turns%4 == 3 then history = history.."\n" else history = history.." " end turns = turns+1 end end selected = false end else selected = false end -- draw field cls(0) for y = 1, 7 do for x = 1, 7 do spr(field[y][x]+1, x*8, y*8, 15) if (selected and x == x1 and y == y1) then rectb(x*8, y*8, 8, 8, 2) end end end -- draw stats print("Count: "..count, 2, 70) print("Turns: "..turns, 2, 80) print(history, 70, 2, 8, false, 1, true) end end