6,]']up8d%}$)6o;],sVl3p?p?p4p4p4p5 8::<<==>>>????????????????,?wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww}w}w}w}wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww}wwww}}wwww}}wwww}}wwww}wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww}wwwwww}wwwwww}wwwwww}wwwwwwwwwwwwwwww}wwwwww}wwwwww}wwwwww}wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww}wwwwww}wwwwww}wwwwww}wwwwwwwwwwwwwwww}wwwwww}wwwwww}wwwwww}wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww}wwwwww}wwwwww}wwwwww}wwwwwwwwwwwwwwww}wwwwww}wwwwww}wwwwww}wwwwww|wwwwwwww|wwwwwww|||wwwwwwwwwwwwwwwwwww}wwwwww}wwwwww}wwwwww}wwwwwwwwwwwwwwww}wwwwww}wwwwww}wwwwww}wwwwww|wp||| w|w|w|p| | | wwwwwwwwwwwwwwwwwww}wwwwww}wwwwww}wwwwww}wwwwwwwwwwwwwwww}wwwwww}wwwwww}wwwwww}wwwwwww||p | | wwp wwwwwwwwwwwwwwwwwww}wwwwww}wwwwww}wwwwww}wwwwwwwwwwwwwwww}wwwwww}wwwwww}wwwwww}wwwwwww| p  w|ww||pp wwwwwwwwwwwwwwwwwww}wwwwww}wwwwww}wwwwww}wwwwwwwwwwwwwwww}wwwwww}wwwwww}wwwwww}wwwwww|| www|wwwwwwwwwwwwwwwwwww}wwwwww}wwwwww}wwwwww}wwwwwwwwwwwwwwww}www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4"]=12, ["h5"]=32, ["h6"]=34, ["h7"]=36, ["h8"]=38, ["h9"]=40, ["h10"]=42, ["d13"]=64, ["d12"]=66, ["d11"]=68, ["d1"]=70, ["d2"]=72, ["d3"]=74, ["d4"]=76, ["d5"]=96, ["d6"]=98, ["d7"]=100, ["d8"]=102, ["d9"]=104, ["d10"]=106, ["s13"]=128, ["s12"]=130, ["s11"]=132, ["s1"]=134, ["s2"]=136, ["s3"]=138, ["s4"]=140, ["s5"]=160, ["s6"]=162, ["s7"]=164, ["s8"]=166, ["s9"]=168, ["s10"]=170, ["c13"]=192, ["c12"]=194, ["c11"]=196, ["c1"]=198, ["c2"]=200, ["c3"]=202, ["c4"]=204, ["c5"]=224, ["c6"]=226, ["c7"]=228, ["c8"]=230, ["c9"]=232, ["c10"]=234, } game_sel_pos=172 board_top_row=1 function draw() rect(0,0,240,136,7) print("Solved : "..solved_count().."/1000",165,6,0,false,1,true) print("Solved : "..solved_count().."/1000",164,5,12,false,1,true) -- cell for x=1,4 do local card = cell[x][1] if card then spr(card_spr[card_name(card)],x*16,board_top_row,5,1,0,0,2,2) else spr(44,x*16,board_top_row,5,1,0,0,2,2) end -- draw selection if card and selection and card_name(card)==card_name(selection) then spr(62,x*16-1,board_top_row-1,5,1,0,0,2,3) end end -- home for x=1,4 do if home[x][1] then spr(card_spr[card_name(home[x][1])],x*16+73,board_top_row,5,1,0,0,2,2) else spr(44,x*16+73,board_top_row,5,1,0,0,2,2) end end -- draw cascades for i=1,#cascade do for y=1,#cascade[i] do local card = cascade[i][y] spr(card_spr[card_name(card)], i*17,board_top_row+y*6+12,5,1,0,0,2,2) if y~=1 then spr(124, i*17,board_top_row+y*6+11,5,1,0,0,2,1) end -- draw selection if selection and card_name(card)==card_name(selection) then spr(62,i*17-1,board_top_row+cascade_top_y(i)-1,5,1,0,0,2,3) end end end -- draw focus -- local cellidx = mouse_pos_to_cell_no() local cellidx=focused_cell_no if cellidx then if selection==nil or cell[cellidx][1]==nil or card_name(cell[cellidx][1])~=card_name(selection) then if cell[cellidx][1]==nil then -- empty cell focus spr(172,cell[cellidx].x,board_top_row,5,1,0,0,2,2) else -- non empty home focus (large) spr(14,cell[cellidx].x-1,board_top_row-1,5,1,0,0,2,3) end end end local homeidx=focused_home_no --mouse_pos_to_home_no() if homeidx then if home[homeidx][1]==nil then -- empty home focus spr(172,home[homeidx].x,board_top_row,5,1,0,0,2,2) else -- non empty home focus (large) spr(14,home[homeidx].x-1,board_top_row-1,5,1,0,0,2,3) end end local cidx=focused_cascade_no --mouse_pos_to_cascade_no() if cidx then if selection==nil or top_card(cascade[cidx])==nil or card_name(top_card(cascade[cidx])) ~= card_name(selection) then if top_card(cascade[cidx])==nil then -- empty home focus spr(172,cascade[cidx].x,board_top_row+cascade_top_y(cidx),5,1,0,0,2,2) else spr(14,cascade[cidx].x-1, board_top_row+cascade_top_y(cidx)-1,5,1,0,0,2,3) end end end -- restart button if focused_restart_btn then round_rect(game_sel_pos,34,35,9,10) else round_rect(game_sel_pos,34,35,9,15) end round_rect(game_sel_pos+1,35,33,7,9) print("RESTART",game_sel_pos+4,36,12,false,1,true) -- game# selector if get_pmem_bit(game_no) then spr(108,game_sel_pos+34,17,5,1,0,0,1,1) end rect(game_sel_pos+8,19,24,7,8) print("#",game_sel_pos+1,21,0,false,1,false) print("#",game_sel_pos,20,12,false,1,false) local game_no_str=string.format("%03d",game_no) for i=1,3 do local adjustment=0 local n=string.sub(game_no_str,i,i) if n=="1" then adjustment=1 end print(n,game_sel_pos+1+(i*8)+adjustment,20,0) end rectb(game_sel_pos-1+8*3,18,9,9,15) rectb(game_sel_pos-1+8*2,18,9,9,15) rectb(game_sel_pos-1+8*1,18,9,9,15) if focused_game_sel_digit==3 then rectb(game_sel_pos-1+8*3,18,9,9,10) elseif focused_game_sel_digit==2 then rectb(game_sel_pos-1+8*2,18,9,9,10) elseif focused_game_sel_digit==1 then rectb(game_sel_pos-1+8*1,18,9,9,10) end end function card_name(card) -- card:{type="h",num=1},etc. return card.type .. card.num end function top_card(t) return t[#t] end last_mbtn_l = false last_mbtn_r = false last_mbtn_down_time = -10000 last_mbtn_click_time = -10000 last_click_is_gamepad = false -- false:mouse,true:gamepad function btn_a() return (btn(4) or btn(12) or btn(20) or btn(28)) end function btn_b() return (btn(5) or btn(13) or btn(21) or btn(29)) end function click_p() local x,y,bl,bm,br=mouse() if bl or br or btn_a() or btn_b() then if not last_mbtn then last_mbtn_l=(bl or btn_a()) last_mbtn_r=(br or btn_b()) last_mbtn_down_time = time() last_click_is_gamepad=(btn_a() or btn_b()) end else -- not (b1 r br) if last_mbtn_l or last_mbtn_r then local ret_mr = last_mbtn_r last_mbtn_l=false last_mbtn_r=false if time()-last_mbtn_down_time<1000 then local dbl = false if time()-last_mbtn_click_time<400 then dbl = true last_mbtn_click_time = -10000 else last_mbtn_click_time = time() end return true,dbl,ret_mr,last_click_is_gamepad end end end return false,false,false,last_click_is_gamepad end last_mx,last_my=mouse() focused_cascade_no=nil focused_cell_no=nil focused_home_no=nil focused_game_sel_digit=nil focused_restart_btn=nil last_focus={"cascade",8} debug="debug" function check_mouse_move() local mx,my=mouse() if last_mx~=mx or last_my~=my then last_mx,last_my=mx,my --debug="mouse move" focused_cascade_no=mouse_pos_to_cascade_no() if focused_cascade_no~=nil then last_focus={"cascade",focused_cascade_no} end focused_cell_no=mouse_pos_to_cell_no() if focused_cell_no~=nil then last_focus={"cell",focused_cell_no} end focused_home_no=mouse_pos_to_home_no() if focused_home_no~=nil then last_focus={"home",focused_home_no} end focused_game_sel_digit=nil for i=1,3 do if mouse_on_game_selector(i) then focused_game_sel_digit=i break end end if focused_game_sel_digit~=nil then last_focus={"game#",focused_game_sel_digit} end focused_restart_btn=mouse_on_restart_btn() if focused_restart_btn then last_focus={"restart",1} end else --debug="no mouse move" end end function _if(cond,true_value,false_value) if cond then return true_value else return false_value end end function check_arrow_keys() if btn(0) then -- up last_mbtn_click_time = -10000 if last_focus[1]=="cascade" then if last_focus[2]<=4 then focused_cell_no=last_focus[2] focused_home_no=nil focused_cascade_no=nil last_focus={"cell",focused_cell_no} else focused_home_no=last_focus[2]-4 focused_cell_no=nil focused_cascade_no=nil last_focus={"home",focused_home_no} end elseif last_focus[1]=="restart" then focused_game_sel_digit=1 focused_restart_btn=nil last_focus={"game#",1} end elseif btn(1) then -- down last_mbtn_click_time = -10000 if last_focus[1]=="home" then focused_cascade_no=last_focus[2]+4 focused_cell_no=nil focused_home_no=nil last_focus={"cascade",focused_cascade_no} elseif last_focus[1]=="cell" then focused_cascade_no=last_focus[2] focused_cell_no=nil focused_cell_no=nil --focused_game_sel_digit=nil last_focus={"cascade",focused_cascade_no} elseif last_focus[1]=="game#" then focused_restart_btn=true focused_game_sel_digit=nil last_focus={"restart",1} end elseif btnp(2,12,6) then -- left last_mbtn_click_time = -10000 if last_focus[1]=="cascade" then focused_cascade_no=_if(last_focus[2]==1, 1, last_focus[2]-1) last_focus={"cascade",focused_cascade_no} elseif last_focus[1]=="home" then focused_home_no=_if(last_focus[2]==1, nil, last_focus[2]-1) last_focus=_if(focused_home_no, {"home",focused_home_no}, {"cell",#cell}) focused_cell_no=_if(focused_home_no,nil,#cell) elseif last_focus[1]=="cell" then focused_cell_no=_if(last_focus[2]==1, 1, last_focus[2]-1) last_focus={"cell",focused_cell_no} elseif last_focus[1]=="restart" then focused_restart_btn=nil focused_cascade_no=#cascade last_focus={"cascade",#cascade} elseif last_focus[1]=="game#" then focused_game_sel_digit=_if(last_focus[2]==1, nil, last_focus[2]-1) focused_home_no=_if(focused_game_sel_digit, nil, #home) last_focus=_if(focused_game_sel_digit, {"game#",focused_game_sel_digit}, {"home",#home}) end elseif btnp(3,12,6) then -- right last_mbtn_click_time = -10000 if last_focus[1]=="cascade" then focused_cascade_no=_if(last_focus[2]==#cascade, nil, last_focus[2]+1) focused_restart_btn=_if(focused_cascade_no,nil,true) last_focus=_if(focused_cascade_no, {"cascade",focused_cascade_no}, {"restart",1}) elseif last_focus[1]=="home" then focused_home_no=_if(last_focus[2]==#home, nil, last_focus[2]+1) focused_game_sel_digit=_if(focused_home_no, nil, 1) last_focus=_if(focused_home_no, {"home",focused_home_no}, {"game#",1}) elseif last_focus[1]=="cell" then focused_cell_no=_if(last_focus[2]==#cell, nil, last_focus[2]+1) focused_home_no=_if(focused_cell_no, nil, 1) last_focus=_if(focused_cell_no, {"cell",focused_cell_no}, {"home",1}) elseif last_focus[1]=="restart" then -- elseif last_focus[1]=="game#" then focused_game_sel_digit=_if(last_focus[2]==3, 3, last_focus[2]+1) last_focus={"game#",focused_game_sel_digit} end end end function mouse_pos_to_cascade_no() local mx,my=mouse() local cascade_no=mx//17 if my#cascade then return nil else return cascade_no end end function mouse_pos_to_cell_no() local mx,my=mouse() local cell_no=mx//16 if my>=cascade[1].y or cell_no<1 or cell_no>#cell then return nil else return cell_no end end function mouse_pos_to_home_no() local mx,my=mouse() local home_no=(mx-73)//16 if my>=cascade[1].y or home_no<1 or home_no>#home then return nil else return home_no end end function mouse_on_restart_btn() local mx,my=mouse() return mx>=172 and mx<207 and my>=34 and my<34+9 end function mouse_on_game_selector(pos) -- pos:1-3 local mx,my=mouse() return mx>=game_sel_pos-1+pos*8 and mx=18 and my<18+9 end function cascade_top_y(cascade_no) return math.max(#cascade[cascade_no]*6+12,18) end function shuffle(t) math.randomseed(game_no) local n = #t for i = n, 2, -1 do local j = math.random(i) t[i], t[j] = t[j], t[i] end return t end function pop_count(int32) local n=0 while int32>0 do int32=int32&(int32-1) n=n+1 end return n end function solved_count() local n=0 for i=0,31 do n=n+pop_count(pmem(i)) end return n end function find_card_in_home(card) local cname=card_name(card) for i=1,#home do if home[i][1] and home[i][1].type==card.type and home[i][1].num>=card.num then return true end end return false end sfx_start_time=0 function auto() -- A card at the top of a cascade will -- automatically move to the home as a -- trivial case if both cards of a -- different color with one less number -- are in the home. for i=1,#cascade do local c=top_card(cascade[i]) if c and c.num>1 then if c.type=="h" or c.type=="d" then local c1={type="s",num=c.num-1} local c2={type="c",num=c.num-1} if find_card_in_home(c1) and find_card_in_home(c2) then for i=1,#home do if move_card_to_home(c,i) then sfx_start_time=time() sfx(0) save_solved() return end end end else local c1={type="h",num=c.num-1} local c2={type="d",num=c.num-1} if find_card_in_home(c1) and find_card_in_home(c2) then for i=1,#home do if move_card_to_home(c,i) then sfx_start_time=time() sfx(0) save_solved() return end end end end end end for i=1,#cell do local c=top_card(cell[i]) if c and c.num>1 then if c.type=="h" or c.type=="d" then local c1={type="s",num=c.num-1} local c2={type="c",num=c.num-1} if find_card_in_home(c1) and find_card_in_home(c2) then for i=1,#home do if move_card_to_home(c,i) then sfx_start_time=time() sfx(0) save_solved() return end end end else local c1={type="h",num=c.num-1} local c2={type="d",num=c.num-1} if find_card_in_home(c1) and find_card_in_home(c2) then for i=1,#home do if move_card_to_home(c,i) then sfx_start_time=time() sfx(0) save_solved() return end end end end end end end function TIC() if time()-sfx_start_time<100 then return end cls() if t%4==0 then cycle_selection_color() end auto() draw() if dialog then show_dialog() return end check_mouse_move() check_arrow_keys() --print(string.format("%s",debug),1,70,12,false,1,true) local click,double_click,right_click,is_gamepad=click_p() local cidx=focused_cascade_no if click and not double_click then if focused_restart_btn then if is_gamepad then dialog=true else init() end end for p=1,3 do if focused_game_sel_digit==p then -- mouse_on_game_selector(p) then local s=string.format("%03d",game_no) local d=string.sub(s,p,p) local dn=tonumber(d) local up=1 if right_click then up=up*-1 end game_no=game_no-dn*10^(3-p)+(dn+up)%10*10^(3-p) init() end end local cellidx=focused_cell_no local homeidx=focused_home_no if selection==nil then if cidx then selection=top_card(cascade[cidx]) end if cellidx then selection=cell[cellidx][1] end else if cidx then if not move_card_to_cascade(selection,cidx) then --sfx(1) end selection=nil end if cellidx then move_card_to_cell(selection,cellidx) end if homeidx then move_card_to_home(selection,homeidx) selection=nil end end save_solved() end if double_click then if cidx then local tc=top_card(cascade[cidx]) if tc and tc.num==1 then local empty_home_idx=nil for i=1,#home do if home[i][1]==nil then empty_home_idx=i break end end if empty_home_idx then move_card_to_home(tc,empty_home_idx) selection=nil end elseif tc then local empty_cell_idx=nil for i=1,#cell do if cell[i][1]==nil then empty_cell_idx=i break end end if empty_cell_idx then move_card_to_cell(tc,empty_cell_idx) end end end save_solved() end t=t+1 end function round_rect(x,y,w,h,c) rect(x+1,y,w-2,h,c) rect(x,y+1,w,h-2,c) end function set_color(color_no,r,g,b) local palette=0x3fc0 local color_addr = palette+3*color_no poke(color_addr,r) poke(color_addr+1,g) poke(color_addr+2,b) end function BDR(row) if row>=23 and row<=29 then -- game# selector color set_color(8,255-(row-23)*10, 255-(row-23)*10, 255-(row-23)*10) elseif row>=35 and row<=42 then -- restart color local i=row-35+2 set_color(9,200, 200-(i/9)^3*200, 200-(i/9)^3*200) end end function empty_cell_count() local ret=0 for i=1,#cell do if cell[i][1]==nil then ret=ret+1 end end return ret end function empty_cascade_count() local ret=0 for i=1,#cascade do if cascade[i][1]==nil then ret=ret+1 end end return ret end function find_cascade(card) local cname=card_name(card) for i=1,#cascade do if top_card(cascade[i]) and card_name(top_card(cascade[i]))==cname then return cascade[i] end end return nil end function stack_move(card,cidx) -- trace("stack_move("..card_name(card)..", "..cidx..")",12) local n=empty_cell_count()+empty_cascade_count() local src_cas=find_cascade(card) if src_cas==nil then -- when the card is from the cells return false end local dst_card=top_card(cascade[cidx]) local dst_card_red=dst_card.type=="h" or dst_card.type=="d" for i=#src_cas,math.max(2,#src_cas-n+1),-1 do local c0=src_cas[i] local c0_red=c0.type=="h" or c0.type=="d" local c1=src_cas[i-1] local c1_red=c1.type=="h" or c1.type=="d" -- trace("i="..i,12) if ((not (c0.num==c1.num-1 and c0_red~=c1_red)) or (c0.num==dst_card.num-1 and c0_red~=dst_card_red) or (c1.num==dst_card.num-1 and c1_red~=dst_card_red) ) then local cond1 = (c0.num==c1.num-1 and c0_red~=c1_red) local cond2 = (c1.num==dst_card.num-1 and c1_red~=dst_card_red) local cond3 = (c0.num==dst_card.num-1 and c0_red~=dst_card_red) local cx= _if(cond1 , c1 , c0) local cx_red=_if(cond1 , c1_red , c0_red) local j= _if(cond1 , i-1 , i) local cond4 = cx.num==dst_card.num-1 local cond5 = cx_red~=dst_card_red --[[ debug=string.format("c01 and home[homeidx][1] and card.num-1 == home[homeidx][1].num and card.type == home[homeidx][1].type) then remove_card(card) home[homeidx][1]=card return true end return false -- not moved end function remove_card(card) local cname = card_name(card) -- cell for i=1,#cell do if cell[i][1] and card_name(cell[i][1])==cname then table.remove(cell[i],1) break end end -- cascade for i=1,#cascade do for j=1,#cascade[i] do if cascade[i][j] and card_name(cascade[i][j])==cname then table.remove(cascade[i],j) break end end end end color_11 = true function cycle_selection_color() if color_11 then set_color(11,255,0,0) else set_color(11,0,0,255) end color_11 = not color_11 end function make_card_set() local ret={} local type={"c","h","s","d"} for j=1,4 do for i=1,13 do table.insert(ret,{type=({"c","h","s","d"})[j],num=i}) end end return ret end function set_pmem_bit(n) pmem(n//32,pmem(n//32)|1<0 then local selected_game_no=0 repeat local n=math.floor((math.random(1,1000)+time()*10000))%unsolved+1 for i=0,999 do if not get_pmem_bit(i) then n=n-1 if n==0 then selected_game_no=i break end end end until selected_game_no~=game_no or unsolved==1 return selected_game_no else return math.floor((math.random(1,1000)+time()*10000))%1000 end end -- game_no=math.floor((tstamp()*time())%1000) game_no=random_unsolved() function reverse(t) rev = {} for i=#t, 1, -1 do rev[#rev+1] = t[i] end return rev end function save_solved() local t1=top_card(home[1]) local t2=top_card(home[2]) local t3=top_card(home[3]) local t4=top_card(home[4]) if t1 and t1.num==13 and t2 and t2.num==13 and t3 and t3.num==13 and t4 and t4.num==13 then set_pmem_bit(game_no) end end function init() cell = {{},{},{},{}} home = {{},{},{},{}} cascade = {{},{},{},{},{},{},{},{}} selection = nil --local cs = reverse(make_card_set()) -- debug local cs = shuffle(make_card_set()) cascade[1]=take(7,cs); drop(7,cs) cascade[2]=take(7,cs); drop(7,cs) cascade[3]=take(7,cs); drop(7,cs) cascade[4]=take(7,cs); drop(7,cs) cascade[5]=take(6,cs); drop(6,cs) cascade[6]=take(6,cs); drop(6,cs) cascade[7]=take(6,cs); drop(6,cs) cascade[8]=take(6,cs); for i=1,#cascade do cascade[i].x=17*i cascade[i].y=17 end for i=1,4 do cell[i].x=16*i home[i].x=73+16*i end end function take(n,a) local ret = {} for i=1,n do table.insert(ret,a[i]) end return ret end function drop(n,a) for i=1,n do table.remove(a,1) end return a end cell = {{},{},{},{}} home = {{},{},{},{}} cascade = {{},{},{},{},{},{},{},{}} selection = nil init() dialog=false focus_dialog_restart=false focus_dialog_cancel=true function show_dialog() local w=100 local h=21 local bw=35 local bh=9 -- dialog box round_rect(120-w/2,68-h/2-20,w,h+20,0) round_rect(120-(w-2)/2,68-(h-2)/2-20,w-2,h-2+20,12) -- restart if focus_dialog_restart then round_rect(120-bw/2-bw/1.5-1,68-bh/2-1,bw+2,bh+2,10) end round_rect(120-bw/2-bw/1.5,68-bh/2,bw,bh,0) round_rect(120-(bw-2)/2-bw/1.5,68-(bh-2)/2,bw-2,bh-2,12) -- cancel if focus_dialog_cancel then round_rect(120-bw/2+bw/1.5-1,68-bh/2-1,bw+2,bh+2,10) end round_rect(120-bw/2+bw/1.5,68-bh/2,bw,bh,0) round_rect(240/2-(bw-2)/2+bw/1.5,68-(bh-2)/2,bw-2,bh-2,12) spr(110,80,42,5,1,0,0,2,2) print("Are you sure?",100,47,0,true,1,true) print("RESTART CANCEL",83,65,0,true,1,true) if btn(2) then focus_dialog_restart=true focus_dialog_cancel=false elseif btn(3) then focus_dialog_restart=false focus_dialog_cancel=true end local click=click_p() if click then if focus_dialog_restart then init() dialog=false elseif focus_dialog_cancel then dialog=false end focus_dialog_cancel=true focus_dialog_restart=false end end