Unnamed Fossil Project

Check-in [66d925fa2f]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:i think i finally got everything in the encoding working.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:66d925fa2f80ccc3739393e470b0980500d99dd5
User & Date: Derek 2013-02-27 02:16:33
Context
2013-02-27
16:46
decode written and tested. check-in: bd7e1086e7 user: Derek tags: trunk
02:16
i think i finally got everything in the encoding working. check-in: 66d925fa2f user: Derek tags: trunk
2013-02-26
19:01
fixed some boundary problems with the encode line function. check-in: d78910d918 user: Derek tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to maze.html.

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
..
47
48
49
50
51
52
53
54
55
56
57
58

59
60
61
62
63
64
65
66
67
68
69
var w=o.w,h=o.h,s=o.start,e=o.end,arr=o.arr.slice(0),i=0,j,k,v,min,l=w*h,r=[],//retval
lines=[[[],[]],[[],[]]];//pos,neg*horiz,vert
arr[s[0]+w*s[1]]=0;//assure start empty
for(v=0;v<2;++v){//pos,neg
for(min=(w+h)/4;min>0;min/=2){
for(i=0;i<l;++i){if(arr[i]==2)continue;j=i;k=i;
while((i==j||j%w)&&(arr[j]==v||arr[j]==2)){if(arr[j]==v)k=j+1;++j;}//2 means already encoded
if(k-i>=min){lines[v][0].push([i,k-i]);alert("horizontal: "+i+","+k);for(j=i;j<k;++j)arr[j]=2;continue;}
j=i;k=i;
while(j<l&&(arr[j]==v||arr[j]==2)){if(arr[j]==v)k=j+w;j+=w;}
if((k-i)/w>=min){lines[v][1].push([i,(k-i)/w]);alert("vertical: "+i+","+k);for(j=i;j<k;j+=w)arr[j]=2;}}}
for(j=0;j<l;++j)if(arr[j]==2)arr[j]=v;}//reset 2s
i=0;
r[i++]=w;r[i++]=h;
r[i++]=1;r[i++]=s[0];r[i++]=s[1];
r[i++]=1;r[i++]=e[0];r[i++]=e[1];
r[i++]=0;
alert(JSON.stringify(lines));
................................................................................
var nl=lines[0][0].length+lines[0][1].length,pl=lines[1][0].length+lines[1][1].length;
lines=lines[nl<pl?0:1];//use shorter lineset
var a=lines[0],b=lines[1],lastk=0;
k=0;
function _sort(s,t){return s[0]-t[0];}
a.sort(_sort);b.sort(_sort);
alert(JSON.stringify({"horizontal":a,"vertical":b}));
for(j=0;j<a.length;j+=2){
k=a[j];r[i++]=a[j];r[i++]=a[j+1];lastk=k;}
k=0;lastk=0;
for(j=0;j<b.length;j+=2){
k=b[j];r[i++]=(k-lastk)/w;r[i++]=b[j+1];lastk=k;}

return r;}

//alert()
setTimeout(function(){alert('here');encodelines({w:width,h:height,start:[0,0],end:[10,100],arr:arr});}, 1000);

function decodelines(str){
}

function encodearrayhex(arr){
}








|


|







 







|
|
|
|
|
>



|







29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
..
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
var w=o.w,h=o.h,s=o.start,e=o.end,arr=o.arr.slice(0),i=0,j,k,v,min,l=w*h,r=[],//retval
lines=[[[],[]],[[],[]]];//pos,neg*horiz,vert
arr[s[0]+w*s[1]]=0;//assure start empty
for(v=0;v<2;++v){//pos,neg
for(min=(w+h)/4;min>0;min/=2){
for(i=0;i<l;++i){if(arr[i]==2)continue;j=i;k=i;
while((i==j||j%w)&&(arr[j]==v||arr[j]==2)){if(arr[j]==v)k=j+1;++j;}//2 means already encoded
if(k-i>=min){lines[v][0].push([i,k-i]);for(j=i;j<k;++j)arr[j]=2;continue;}
j=i;k=i;
while(j<l&&(arr[j]==v||arr[j]==2)){if(arr[j]==v)k=j+w;j+=w;}
if((k-i)/w>=min){lines[v][1].push([i,(k-i)/w]);for(j=i;j<k;j+=w)arr[j]=2;}}}
for(j=0;j<l;++j)if(arr[j]==2)arr[j]=v;}//reset 2s
i=0;
r[i++]=w;r[i++]=h;
r[i++]=1;r[i++]=s[0];r[i++]=s[1];
r[i++]=1;r[i++]=e[0];r[i++]=e[1];
r[i++]=0;
alert(JSON.stringify(lines));
................................................................................
var nl=lines[0][0].length+lines[0][1].length,pl=lines[1][0].length+lines[1][1].length;
lines=lines[nl<pl?0:1];//use shorter lineset
var a=lines[0],b=lines[1],lastk=0;
k=0;
function _sort(s,t){return s[0]-t[0];}
a.sort(_sort);b.sort(_sort);
alert(JSON.stringify({"horizontal":a,"vertical":b}));
for(j=0;j<a.length;++j){
k=a[j][0];r[i++]=k-lastk;r[i++]=a[j][1];lastk=k;}
lastk=lastk-l;k=0;
for(j=0;j<b.length;++j){
k=b[j][0];r[i++]=k-lastk;r[i++]=b[j][1];lastk=k;}
alert(r.join(","));
return r;}

//alert()
setTimeout(function(){alert('here');encodelines({w:width,h:height,start:[startx,starty],end:[goalx,goaly],arr:arr});}, 1000);

function decodelines(str){
}

function encodearrayhex(arr){
}