Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: Halifax on August 05, 2006, 02:44:00 pm

Title: [83+ BASIC] Compressors
Post by: Halifax on August 05, 2006, 02:44:00 pm
Wow im rele in need of some Matrix,list, and string compressors. Because seriously I have this game that would be a lot easier to play if I could put a loading screen in and have all the things decompressed.
Title: [83+ BASIC] Compressors
Post by: rivereye on August 05, 2006, 02:45:00 pm
I don't know if there are, and it may not really be worth it.
Title: [83+ BASIC] Compressors
Post by: Halifax on August 05, 2006, 02:53:00 pm
No like say there was a matrix
[4,2,5,7]
[2,4,76,5]
[10,1,5,6]
[24,2,6,1]
155 Bytes

Then compressed into a list it is

{4257,24,1,5,1,156,1,261,761024}
90 Bytes

1 is a token to double numbers which a listed at the end
Title: [83+ BASIC] Compressors
Post by: Dragon__lance on August 05, 2006, 04:06:00 pm
it shouldn't be that hard to make one yourself in BASIC.Here's my idea.I'd recommend compressing to string.For isntance:
[1,2,3]
[4,5,6]
[7,8,9]
(92 bytes)
becomes "100200300400500" (the 00's represent empty spaces so you can fit 3 digit numbers)
(38 bytes)
Then when you decompress,use
:expr(sub(str,X,3->[A](A,B

just run that command through a loop,and it should work :Dbiggrin.gif
Title: [83+ BASIC] Compressors
Post by: Halifax on August 06, 2006, 04:10:00 am
That's a great idea but then you can only transfer ten compressed levels, but that helped me because the list form of that which is {100200300,400500600,700800900} and that is 41 bytes and you can transfer many compressed levels like that.
Title: [83+ BASIC] Compressors
Post by: Demon on August 06, 2006, 04:23:00 am
I have a String to List converter I made that converts Strings to Lists and compresses them...  I could take that and just leave the compression part and have a list compressor right there...
Title: [83+ BASIC] Compressors
Post by: Halifax on August 06, 2006, 04:34:00 am
That's cool and if you want to you could post the code.
Title: [83+ BASIC] Compressors
Post by: Dragon__lance on August 06, 2006, 06:12:00 am
i'd still recomend using string compression,if your worried about number of levels it can compress.Just fit all your levels into 1 string.Then use a character like '-' to mark where one level ends and another begins.Then use-
:instring(str,'-',1

to find the location and start compressing from there.But if you want to use list compression,heres an idea.
:{100200300,400500600,700800900}->L1
:int(E-6L1(1->[A](1,3


basically use decimels to divide up the data ;)wink.gif
Title: [83+ BASIC] Compressors
Post by: Halifax on August 06, 2006, 06:16:00 am
Your actually right i think string compression would be better
Title: [83+ BASIC] Compressors
Post by: kalan_vod on August 06, 2006, 08:28:00 am
Well I made something like this for my Tank game, which compressed one of my maps data 84%. The code allows for decimals, for actions in game.
Title: [83+ BASIC] Compressors
Post by: DJ Omnimaga on August 06, 2006, 08:57:00 am
how fast did it ran?
Title: [83+ BASIC] Compressors
Post by: Demon on August 06, 2006, 09:49:00 am
Here are my string to list and list to string converters.
Results are stored in Ans.
Imported from Graphlink (which is why you see all that odd slashed stuff.

String to List
c1-->
CODE
ec1\start83P\
\comment=Single file dated Sun Aug 06 15:43:20 20
\protected=FALSE
\name=ZS2L
\file=D:\TISTUF~1\0PROGR~1\ZS2L.TXT
Ans\->\Str1
{0\->\L\6\:0\->\X:1\->\Y
ClrHome
Output(1,1,"Str1NG->\L\IST:
For(W,2,length(Str1
Output(1,14,int(W/length(Str1)*100
inString("ABCDEFGHIJKLMNOPQRSTUVWXYZ\theta\ :?\^-1\^\^2\,()/789*456-123+0.\(-54125+)\\^3\!=\!=\>\>=\<\<=\\o\'\r\\pi\\EE\{}\e\[]\i\\dot\\cross\\box\\T\",sub(Str1,W,1
If Ans:Then
X+(Ans*.01^Y\->\X
Y+1\->\Y
If Y=6:Then
X\->\L\6\(1+dim(L\6\
DelVar X1\->\Y
End:End:End
If X:X\->\L\6\(1+dim(L\6\:ClrHome:L\6\
DelVar XDelVar YDelVar ZDelVar L\6\
\stop83P\c2
ec2

List to String
c1
-->
CODE
ec1\start83P\
\comment=Single file dated Sun Aug 06 15:43:19 20
\protected=FALSE
\name=ZL2S
\file=D:\TISTUF~1\0PROGR~1\ZL2S.TXT
Ans\->\L\6\:" \->\Str1
If dim(L\6\:Goto R
Menu("ERR:LIST EMPTY","QUIT",X
Lbl X:0:Return
Lbl R
ClrHome
Output(1,1,"\L\IST->Str1NG:
For(W,2,dim(L\6\
Output(1,12,int(W/dim(L\6\)*100
L\6\(W\->\X
Repeat not(fPart(X
100fPart(round(X,2\->\Y
100X\->\X
If fPart(Y) or Y<1 or Y>75:DelVar X
If not(X:Then
.02\->\L\6\(W:2\->\Y
End
Str1+sub("ABCDEFGHIJKLMNOPQRSTUVWXYZ\theta\ :?\^-1\^\^2\,()/789*456-123+0.\(-54125+)\\^3\!=\!=\>\>=\<\<=\\o\'\r\\pi\\EE\{}\e\[]\i\\dot\\cross\\box\\T\",Y,1\->\Str1
End:End:0\->\L\6\(1
ClrHome
":
prgmZSTAT:Str1
DelVar Str1DelVar VDelVar W
\stop83P\c2
ec2
Title: [83+ BASIC] Compressors
Post by: kalan_vod on August 06, 2006, 10:42:00 am
@kevin: It depends on the size, but for my 24x16 (WxH) it took 10 seconds on average.

@pyro_xp2k: Looks like it could be simpler, but it looks like it would work. And you may want to look at not using lbls.
Title: [83+ BASIC] Compressors
Post by: Demon on August 06, 2006, 10:58:00 am
Yeah, they could be simpler.  They both error-correct so that's one reason they're a bit larger.
Title: [83+ BASIC] Compressors
Post by: Dragon__lance on August 06, 2006, 11:04:00 am
oooooo,i'd love to see the code for that kalan_vod :Dbiggrin.gif
Title: [83+ BASIC] Compressors
Post by: kalan_vod on August 06, 2006, 11:14:00 am
I have one bug to iron out though, well...I made it so it compresses a closed area, where it's like an arena that you can't exit. I can simply correct/add support for regular type of levels, where you can exit etc.
Title: [83+ BASIC] Compressors
Post by: Demon on August 06, 2006, 11:41:00 am
Another idea for matrix compression would be sort of like the list compressor I posted does:  It would concatecate (did I spell that right) the values of the element.  But since matrixes are 2d, it would first combine each row of numbers together like this:

[[0,1,2,3,4]
[5,6,7,8,9,10]
[11,12,13,14]]

[[.35] //dimensions
[.001020304]
[.0506070809]
[.11121314]]

And maybe try to combine the rows together...
Title: [83+ BASIC] Compressors
Post by: kalan_vod on August 06, 2006, 12:02:00 pm
I will post mine sometime this week, if I get a chance.
Title: [83+ BASIC] Compressors
Post by: Zeromus on August 07, 2006, 11:41:00 am
I have a REALLY REALLY old Matrix zipper that can take an 8x16 matrix, and make it a 1x16 matrix (which then can be put into a list) it's a really good compresson rate, and none to slow either. Talk to DarkAuron on efnet (#tcpa) he can compress things like you wouldn't belive (or instead of IRC, you can drop him a line at http://kvince83.tengun.net/maxboard )
Title: [83+ BASIC] Compressors
Post by: DJ Omnimaga on August 08, 2006, 12:08:00 pm
i never attempted compression before, does yours and the ones above are any fast?
Title: [83+ BASIC] Compressors
Post by: Demon on August 08, 2006, 12:20:00 pm
Mine "zipped" a 20-char string to a list in about 10 or 20 seconds.  If you make it just only zip the list (no string conversion or stuff like that) it would go really realyl fast.
Title: [83+ BASIC] Compressors
Post by: DJ Omnimaga on August 08, 2006, 12:37:00 pm
i c, I'l stick to uncompressed then I think O_Oshocked2.gif
Title: [83+ BASIC] Compressors
Post by: kalan_vod on August 08, 2006, 12:51:00 pm
http://omnimaga.dyndns.org/index.php?showtopic=524
Title: [83+ BASIC] Compressors
Post by: DJ Omnimaga on August 08, 2006, 12:57:00 pm
YAYs
Title: [83+ BASIC] Compressors
Post by: Dragon__lance on August 08, 2006, 01:04:00 pm
code! code! code! :Ptongue.gif
Title: [83+ BASIC] Compressors
Post by: kalan_vod on August 08, 2006, 01:11:00 pm
QuoteBegin-Dragon__lance+Aug 8 2006, 07:04 PM-->
QUOTE (Dragon__lance @ Aug 8 2006, 07:04 PM)
code! code! code! :Ptongue.gif

 I will release the code/demo once I iron out a few more things.
Title: [83+ BASIC] Compressors
Post by: Zeromus on August 09, 2006, 11:36:00 am
http://www.calcgames.org/cgi-bin/files/files.cgi?ID=689 if you don't mind 100% unoptimized code, this does the trick pretty fast, but it is VERY limited, in that it can only handle 1 digit, and no decimals... (It's like my 4th or 5th program, give me a break)
Title: [83+ BASIC] Compressors
Post by: Halifax on August 09, 2006, 01:13:00 pm
I actually made my own compressor and decompressor which compresses a 12x8 matrix in 10 seconds and cuts it down 4 times its size. The decompressor decompresses it in like 12 seconds.
Title: [83+ BASIC] Compressors
Post by: kalan_vod on August 09, 2006, 05:09:00 pm
To each his own, mine does a quicker job for a matrix 4 times larger..Congrats.
Title: [83+ BASIC] Compressors
Post by: DJ Omnimaga on August 10, 2006, 02:18:00 am
we should have a compression contest for 83+ BASIC
Title: [83+ BASIC] Compressors
Post by: Dragon__lance on August 10, 2006, 04:37:00 am
that's a great idea! i'm gonna try my own at compression now XDsmiley.gif I have a theory about strings......
Title: [83+ BASIC] Compressors
Post by: Halifax on August 10, 2006, 10:57:00 am
lol that would be awesome but i hate make compressors it is so tedious
Title: [83+ BASIC] Compressors
Post by: Dragon__lance on August 10, 2006, 01:43:00 pm
@kalan_vod: well i actually made a working version of a RLE string compressor XDsmiley.gif .I think i get a slightly better compression ratio than with lists,but as far as run time goes......... (damn,howd u make yours go so fast :Dbiggrin.gif)

All i did was every 5 characters in the string is an element.So:
[1.4,0,0]
[11.4,2,2]

Becomes:

"101.420000111.420002"

I prefix the digits with 0's,and then leave the decimel.Then i put the RunLength of the data as a prefix to everything.I"m pretty sure it could be done to run very fast...but i'm not the person to do it.I'm having problems getting a stable version up.But i have a beta compressor and decompressor :)smile.gif

Decompressing is easy....but here's my theory for compressing.The only way to get a matrix into a list is via "Y="
Thus,all the user has to do is to recall the matrix in "Y1".Then via "equ->str",you can store it to a string.Then from there,just have to remove all the useless characters and reformat the elements :Dbiggrin.gif

If someone could help me make a decompresor(suprisingly having some difficulties to make it go faster),that'd be great.I'll release my compressor as soon as i work out the bugs.
Title: [83+ BASIC] Compressors
Post by: kalan_vod on August 10, 2006, 03:01:00 pm
Sounds great, but it seems it would have lots of wasted bytes due to the fact of having it sucluded to 5 numeric values, a better way IMO would be to have a charactor that is the divider of each value.
Title: [83+ BASIC] Compressors
Post by: Dragon__lance on August 10, 2006, 03:12:00 pm
The extra character could be good or bad.If your matrix data doesn't have a lot of 2 digit numbers,then the extra character would work well and save some space.However if you use 2 digit decimal numbers constantly.......it'd be the other way around.It'd be cool if we could combine our 2 methods Kalan_vod.I'd like to see how fast a string can decompress XDsmiley.gif
Title: [83+ BASIC] Compressors
Post by: Demon on August 12, 2006, 06:26:00 am
Last night  (after crashing and wiping out the RAM again) I decided to make a simple matrix compressor.  It's not that fast (on an 83+ anyway), but A 6x9  (659 byte) Matrix was compressed down to 64 bytes.  A 16x16 (2315 bytes)  265 bytes.  It's not finished yet, because I'm gonna try to make it do things like pattern matching to get even smaller than that.  Hopefully I remember to /back /this/ up/.
Title: [83+ BASIC] Compressors
Post by: DJ Omnimaga on August 13, 2006, 12:14:00 pm
ugh I hope you didnbt lost all progress on the image/sprite editor again >.<
Title: [83+ BASIC] Compressors
Post by: kalan_vod on August 13, 2006, 01:22:00 pm
QuoteBegin-pyro_xp2k+Aug 12 2006, 12:26 PM-->
QUOTE (pyro_xp2k @ Aug 12 2006, 12:26 PM)
Last night  (after crashing and wiping out the RAM again) I decided to make a simple matrix compressor.  It's not that fast (on an 83+ anyway), but A 6x9  (659 byte) Matrix was compressed down to 64 bytes.  A 16x16 (2315 bytes)  265 bytes.  It's not finished yet, because I'm gonna try to make it do things like pattern matching to get even smaller than that.  Hopefully I remember to /back /this/ up/.  

 What would the matric contain? (dont say numbers or digits :Ptongue.gif)
Title: [83+ BASIC] Compressors
Post by: Halifax on August 13, 2006, 03:31:00 pm
Dude with my matrix compressor i did some RLE compression with it and had a 90% ratio!! But the sad thing is I can't write and RLE compressor with mines and make it go fast. So i will realese the source code and anyone who wants to edit can and use it whatever I don't care.
Title: [83+ BASIC] Compressors
Post by: DJ Omnimaga on August 14, 2006, 03:25:00 am
O_Oshocked2.gif wow thats big compression
Title: [83+ BASIC] Compressors
Post by: Demon on August 14, 2006, 11:21:00 am
QUOTE
QUOTE
Last night (after crashing and wiping out the RAM again) I decided to make a simple matrix compressor. It's not that fast (on an 83+ anyway), but A 6x9 (659 byte) Matrix was compressed down to 64 bytes. A 16x16 (2315 bytes) 265 bytes. It's not finished yet, because I'm gonna try to make it do things like pattern matching to get even smaller than that. Hopefully I remember to /back /this/ up/.


What would the matric contain? (dont say numbers or digits :Ptongue.gif)


Well, I guess it could be a map or something, but right now, the numbers can only be from 0 to 99 unless I find out what every single 1-byte token is that GraphLink will display and save.

But my compressor rocks now because it is no longer only a matrix compressor, it comresses lists, too, and then you have the option to  even compress the string the list or matrix is converted to. You you can take, say a 32x32 matrix with mostly zeros and some ones (maybe a map with a wall, but only a few obsticles in a middle), and compress it down to a 2- to 6-something byte string!  And the compressor/expander will automatically determine wheter a string you give it is just a normal string, is compressed data, or is "supercompressed", and will determine wheter it is a list or a matrix.
Title: [83+ BASIC] Compressors
Post by: kalan_vod on August 14, 2006, 12:22:00 pm
QuoteBegin-pyro_xp2k+Aug 14 2006, 05:21 PM-->
QUOTE (pyro_xp2k @ Aug 14 2006, 05:21 PM)
QUOTE
QUOTE
Last night (after crashing and wiping out the RAM again) I decided to make a simple matrix compressor. It's not that fast (on an 83+ anyway), but A 6x9 (659 byte) Matrix was compressed down to 64 bytes. A 16x16 (2315 bytes) 265 bytes. It's not finished yet, because I'm gonna try to make it do things like pattern matching to get even smaller than that. Hopefully I remember to /back /this/ up/.


What would the matric contain? (dont say numbers or digits :Ptongue.gif)


Well, I guess it could be a map or something, but right now, the numbers can only be from 0 to 99 unless I find out what every single 1-byte token is that GraphLink will display and save.

But my compressor rocks now because it is no longer only a matrix compressor, it comresses lists, too, and then you have the option to  even compress the string the list or matrix is converted to. You you can take, say a 32x32 matrix with mostly zeros and some ones (maybe a map with a wall, but only a few obsticles in a middle), and compress it down to a 2- to 6-something byte string!  And the compressor/expander will automatically determine wheter a string you give it is just a normal string, is compressed data, or is "supercompressed", and will determine wheter it is a list or a matrix.

Sounds nice, but I am unsure who your audience is? Also, I have targeted toward those who use xLIB. I am hoping you aren't taking this as a challenge....
Title: [83+ BASIC] Compressors
Post by: Demon on August 14, 2006, 12:43:00 pm
Shoot, I don't even know.  In my mind, there's some people out there clapping, then there are some guys going [imitates murmuring] and then there are some others shaking their heads negatively like, "Meh.  Not exactly enough for us."  "Not exacly what we need."

o.oblink.gif:lol:bounce2.gif:Ptongue.gif:Dbiggrin.gif

As for the challenge... maybe I subconsiously thought it was, but consiously, I just wanted to make something potentially useful for somebody (and myself).
Title: [83+ BASIC] Compressors
Post by: Dragon__lance on August 15, 2006, 03:53:00 am
ahhh,the compresion challenge begins :Dbiggrin.gif The one major thing that i would look for in the compression is Speed,not Size.Speed is more important for me,and i'd  like to see who can get out the fastest compressor! :Dbiggrin.gif
Title: [83+ BASIC] Compressors
Post by: DJ Omnimaga on August 15, 2006, 09:44:00 am
guys please keep things nice, kalan he's trying his best and he's new (he joined the forum, like, 2 months ago I think?) i think his compressor is not aimed toward xlib tho, more pure basic. Anyway what I mean is to not start arguments about "who's compressor is better than whom" and stuff like "mine is better than yours", maybe we should just start a contest and compete here  :Swacko.gif (uhm was this idea suggested a few page ago anyway?)
Title: [83+ BASIC] Compressors
Post by: Demon on August 15, 2006, 11:18:00 am
QUOTE
i think his compressor is not aimed toward xlib tho

Yep, its pure BASIC, but you can use it for what you want.

QuoteBegin
-->
QUOTE
maybe we should just start a contest and compete here

Or maybe we can all make our own compression methods, then have a program that lets someone choose what method to compress with (and then the program can determine itself what decompressor to use).  More peaceful.
Title: [83+ BASIC] Compressors
Post by: DJ Omnimaga on August 15, 2006, 11:33:00 am
yeah maybe, a contest would be cool anyway tho, just no arguments in this topic >.<
Title: [83+ BASIC] Compressors
Post by: Dragon__lance on August 15, 2006, 11:57:00 am
Well any compression is very impressive! BASIC sure has come a long ways! :Dbiggrin.gif
Title: [83+ BASIC] Compressors
Post by: Demon on August 15, 2006, 03:01:00 pm
QuoteBegin-from Cemetech+-->
QUOTE (from Cemetech)
...I need to find as many one-byte to[k]ens as I can find that can put put into a string, and add something that could let other people add their own compression/decompression methods/programs to it.

I'm think I'm gonna start trying to make that a key thing in my programs is that people can add their own things to it, because, after all, if one person made programs for everyone, that only they could control (like Windows for example), the world of computing would be very boring, and not to mention, buggy as hell (also like Windows).
Title: [83+ BASIC] Compressors
Post by: Halifax on August 15, 2006, 03:37:00 pm
yea a contest would be sweet as the compression trend moves on lol jk..jk