Page 1 of 1

CIB

Posted: Sun 20 Aug, 2006 6:59 am
by kalan_vod
After the last time I posted a new project I thought I wouldn't post a new one, but I am going to give it one more shot...
Some are aware of this but I thought I would share it a little more people.

[quote="Old Update"]About: Compression In Basic
I started playing around with compression with basic (no way :shock: ), this is atm just for my game Tank. It will only work with a closed area.

How it works:
It takes a Matrix and compresses it in a format of the number of times the number appears and decimal places of what the number is. The compressed matrix is in a form of list (L1), and the first two spots are the dimensions.

Example:

Code: Select all

/matrix data - 16x24
19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 
19.1 8 8 8 8 8 8 8 8 8 8 8 8 8 22.2 33.2 8 8 8 8 8 8 8 19.1 
19.1 8 8 8 8 8 8 19.1 8 8 8 8 8 8 8 8 8 8 8 34.2 21.2 8 8 19.1 
19.1 8 19.1 8 8 8 8 19.1 8 8 8 8 8 8 8 8 8 8 8 22.2 33.2 8 8 19.1 
19.1 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 19.1 
19.1 8 8 8 18.2 18.2 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 19.1 
19.1 8 8 8 8 8 8 8 34.2 15.2 15.2 15.2 15.2 15.2 15.2 21.2 8 8 8 8 8 8 8 19.1 
19.1 8 8 8 8 8 8 8 20.2 8 8 19.1 8 8 8 20.2 8 8 8 8 8 8 8 19.1 
19.1 8 8 8 8 8 8 8 20.2 8 8 8 19.1 8 8 20.2 8 8 8 8 8 8 8 19.1 
19.1 8 8 8 8 8 8 8 22.2 15.2 15.2 15.2 15.2 15.2 15.2 33.2 8 8 8 8 8 8 8 19.1 
19.1 8 8 8 8 18.2 8 8 8 8 8 8 8 8 8 8 8 8 13.2 8 8 8 8 19.1 
19.1 8 8 8 8 18.2 18.2 8 8 8 8 8 8 8 8 8 8 13.2 13.2 8 8 8 8 19.1 
19.1 8 18.2 18.2 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 13.2 13.2 8 8 19.1 
19.1 8 8 18.2 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 13.2 8 8 8 19.1 
19.1 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 19.1 
19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1 19.1→[A]

Code: Select all

/Once converted
{16,24,25.191,13.08,1.222,1.332,7.08,2.191,6.08,1.191,11.08,1.342,1.212
,2.08,2.191,1.08,1.191,4.08,1.191,11.08,1.222,1.332,2.08,2.191,22.08,2.191
,3.08,2.182,17.08,2.191,7.08,1.342,6.152,1.212,7.08,2.191,7.08,1.202,2.08
,1.191,3.08,1.202,7.08,2.191,7.08,1.202,3.08,1.191,2.08,1.202,7.08,2.191
,7.08,1.222,6.152,1.332,7.08,2.191,4.08,1.182,12.08,1.132,4.08,2.191,4.08
,2.182,10.08,2.132,4.08,2.191,1.08,2.182,15.08,2.132,2.08,2.191,2.08,1.182
,15.08,1.132,3.08,2.191,22.08,25.191→L1
The Matrix data is 3467b and the compressed list is 768b, which gives a compression rate of 77.8%. Now once inside a program you could do the Ans trick where you type a number that is used most often above the matrix and place Ans instead of that number inside the list.

Code: Select all

2.191
{16,24,25.191,13.08,1.222,1.332,7.08,Ans,6.08,1.191,11.08,1.342,1.212,2.08
,Ans,1.08,1.191,4.08,1.191,11.08,1.222,1.332,2.08,Ans,22.08,Ans,3.08,2.182
,17.08,Ans,7.08,1.342,6.152,1.212,7.08,Ans,7.08,1.202,2.08,1.191,3.08,1.202
,7.08,Ans,7.08,1.202,3.08,1.191,2.08,1.202,7.08,Ans,7.08,1.222,6.152,1.332
,7.08,Ans,4.08,1.182,12.08,1.132,4.08,Ans,4.08,2.182,10.08,2.132,4.08,Ans
,1.08,2.182,15.08,2.132,2.08,Ans,2.08,1.182,15.08,1.132,3.08,Ans,22.08,25.191→LÂÂÂ

Posted: Sun 20 Aug, 2006 7:05 am
by threefingeredguy
Would it not be much more space effecient to use strings instead of lists?

Posted: Sun 20 Aug, 2006 7:06 am
by kalan_vod
The strings would provide a greater compression ratio, and atm I am working on something of the such.

Posted: Sun 20 Aug, 2006 7:08 am
by threefingeredguy
Jolly good, jolly good.

Posted: Sun 20 Aug, 2006 4:28 pm
by dysfunction
Wouldn't strings be much slower though?

Posted: Sun 20 Aug, 2006 4:45 pm
by kalan_vod
dysfunction wrote:Wouldn't strings be much slower though?
Not totally sure, as you can store the string into Y1 and then that to L1. Which would allow for greater compression, but a little longer loading.