Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => Topic started by: kalan_vod on August 08, 2006, 12:50:00 pm

Title: CIB
Post by: kalan_vod on August 08, 2006, 12:50:00 pm
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:
c1-->
CODE
ec1/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]c2
ec2
c1
-->
CODE
ec1/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→L1c2
ec2
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.
c1
-->
CODE
ec12.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1c2
ec2
The program with the matrix that isn't using the "trick" is 46b larger, with this it brings the compressed rate to 87.2%.
Title: CIB
Post by: DJ Omnimaga on August 08, 2006, 12:56:00 pm
wow I am quite confused but this sound cool, how fast do you think it will be?
Title: CIB
Post by: kalan_vod on August 08, 2006, 12:58:00 pm
Well, with the map of Tank it takes around 9 seconds.
Title: CIB
Post by: Dragon__lance on August 08, 2006, 01:02:00 pm
as i said on Revsoft,this looks completely sweet Kalan_vod! Awesome! :thumb:thumb.gif It would be really cool to see it integreted into Xlib :Ptongue.gif
Title: CIB
Post by: DJ Omnimaga on August 08, 2006, 01:03:00 pm
aah I c, maybe it could help tho, I had this idea: as you know some ppl like speed, and some like small size, so ppl could make 2 version of their games: one with compressed maps, which would take much less space (in games like metroid it would be signifiant cuz 80% of the program data is maps), and for those who prefer the game to run faster there could be an alternate version with uncompressed maps
Title: CIB
Post by: kalan_vod on August 08, 2006, 01:10:00 pm
Keeping a compressed data set would be more ideal for those whom want their game playable on a 83+ (if it became that large o.oblink.gif). Now, the main reason I am doing so in Tank, is for that being before each game it needs to generate certain things. Now while it is doing that, I can have it decompress the made or such, and it would provide the user with more space on their calc for other games.

This is just something I want to use, and until tr1p can add a compression routine to xLIB I will just use this. I first started this, wanting to make a ascii game (like metroid pure). I made it compress maps of metriod, and once I had it running (displaying the maps while being decompressed) it ran at the speed of what CDI had in the game.
Title: CIB
Post by: elfprince13 on August 08, 2006, 01:35:00 pm
I'd like to talk to you about implementing this in my uberfast scrolling routine. do you have AIM?
Title: CIB
Post by: kalan_vod on August 08, 2006, 03:21:00 pm
QuoteBegin-elfprince13+Aug 8 2006, 07:35 PM-->
QUOTE (elfprince13 @ Aug 8 2006, 07:35 PM)
I'd like to talk to you about implementing this in my uberfast scrolling routine. do you have AIM?  

 Yes I do, kalanvod for msn/aim.
Title: CIB
Post by: DJ Omnimaga on August 09, 2006, 01:24:00 am
QuoteBegin-kalan_vod+Aug 8 2006, 08:10 PM-->
QUOTE (kalan_vod @ Aug 8 2006, 08:10 PM)
Keeping a compressed data set would be more ideal for those whom want their game playable on a 83+ (if it became that large o.oblink.gif). Now, the main reason I am doing so in Tank, is for that being before each game it needs to generate certain things. Now while it is doing that, I can have it decompress the made or such, and it would provide the user with more space on their calc for other games.

This is just something I want to use, and until tr1p can add a compression routine to xLIB I will just use this. I first started this, wanting to make a ascii game (like metroid pure). I made it compress maps of metriod, and once I had it running (displaying the maps while being decompressed) it ran at the speed of what CDI had in the game.  

 sound cool, I really cant wait to see it finished, maybe you should make a tutorial coming with it? :)smile.gif
Title: CIB
Post by: Spellshaper on August 09, 2006, 02:52:00 am
Impressive compression ratio for an RLE routine. ^_^
sadly, other routines are too slow for BASIC, especially on a TI83+.
That's why I don't compress at all. A long loading time in RPGs discourages players... :(sad.gif
Title: CIB
Post by: lolje on August 09, 2006, 03:26:00 am
Yea - that would also be helpful in my Strategy-type-game 'Age of culture II' because I plan to integrate some more maps as the one in the demo. That would even allow to integrate much bigger maps...

I need the routines to (de-)compress...
Integrated in xLIB that would be totally owning - I just say speed %)rolleyes2.gif

kallan, you rock!
Title: CIB
Post by: elfprince13 on August 09, 2006, 04:05:00 am
QuoteBegin-kalan_vod+Aug 8 2006, 09:21 PM-->
QUOTE (kalan_vod @ Aug 8 2006, 09:21 PM)
QuoteBegin-elfprince13+Aug 8 2006, 07:35 PM-->
QUOTE (elfprince13 @ Aug 8 2006, 07:35 PM)
I'd like to talk to you about implementing this in my uberfast scrolling routine. do you have AIM?

Yes I do, kalanvod for msn/aim.  

 sweet, Ill be a-talkin to ya then.
Title: CIB
Post by: DJ Omnimaga on August 09, 2006, 04:07:00 am
good luck he comes once per 3 months on AIM %)rolleyes2.gif


j/k

I hope to see this in action soon :)smile.gif
Title: CIB
Post by: Dragon__lance on August 09, 2006, 04:38:00 am
it'd work very well for games that don't load maps that often,especially big maps! Are you going to write a compressor with it Kalan_vod? :Dbiggrin.gif
Title: CIB
Post by: kalan_vod on August 09, 2006, 05:14:00 pm
QuoteBegin-Dragon__lance+Aug 9 2006, 10:38 AM-->
QUOTE (Dragon__lance @ Aug 9 2006, 10:38 AM)
it'd work very well for games that don't load maps that often,especially big maps! Are you going to write a compressor with it Kalan_vod? :Dbiggrin.gif

 I have, the decompressor has been rewriten (by weregoose) and I feel like a newb....he improved the time by a second, but it is also half the size. The compressor has a problem, which I am trying to fix...Thanks guys, and yes it would be one load time for a large map.
Title: CIB
Post by: DJ Omnimaga on August 10, 2006, 02:21:00 am
o.oblink.gif wow I feel n00b too now... I never got able to wrote a compressor before :cryveryloud:pleure.gif
Title: CIB
Post by: Dragon__lance on August 10, 2006, 04:36:00 am
I'm still intrested in your whole technique.So if i understand correctly,the program takes Similar Run's lengths of data,and stores them into a list.Hmmmm...i wonder what the compression ration would be for a matrix with many different elements :Dbiggrin.gif
Title: CIB
Post by: Spellshaper on August 10, 2006, 05:28:00 am
QuoteBegin-Dragon__lance+Aug 10 2006, 05:36 PM-->
QUOTE (Dragon__lance @ Aug 10 2006, 05:36 PM)
I'm still intrested in your whole technique.So if i understand correctly,the program takes Similar Run's lengths of data,and stores them into a list.Hmmmm...i wonder what the compression ration would be for a matrix with many different elements :Dbiggrin.gif

 worst case scenario: it would get bigger.
Title: CIB
Post by: kalan_vod on August 10, 2006, 03:03:00 pm
QuoteBegin-Spellshaper+Aug 10 2006, 11:28 AM-->
QUOTE (Spellshaper @ Aug 10 2006, 11:28 AM)
QuoteBegin-Dragon__lance+Aug 10 2006, 05:36 PM-->
QUOTE (Dragon__lance @ Aug 10 2006, 05:36 PM)
I'm still intrested in your whole technique.So if i understand correctly,the program takes Similar Run's lengths of data,and stores them into a list.Hmmmm...i wonder what the compression ration would be for a matrix with many different elements :Dbiggrin.gif

worst case scenario: it would get bigger.  

 Which is not always a good thing having a compressor. For smaller maps it may not be ideal, but for larger maps you should be using more of the same tiles for quite some space. Also, I can have it where if the compression isn't worth it then it will skip and just use a matrix for the data.
Title: CIB
Post by: Dragon__lance on August 10, 2006, 03:49:00 pm
wow amazing! I can't wait for it's release :Dbiggrin.gif
Title: CIB
Post by: tifreak on August 11, 2006, 06:24:00 am
Nice. :)smile.gif

And Weregoose can have that effect on people... ;)wink.gif
Title: CIB
Post by: Halifax on August 15, 2006, 05:43:00 pm
That compressor looks soooooo sweeeet I want it so badly  :banghead:banghead.gif:paf:tripaf.gif
Title: CIB
Post by: kalan_vod on August 15, 2006, 07:07:00 pm
QuoteBegin-Killerplayer+Aug 15 2006, 11:43 PM-->
QUOTE (Killerplayer @ Aug 15 2006, 11:43 PM)
That compressor looks soooooo sweeeet I want it so badly  :banghead:banghead.gif:paf:tripaf.gif

 You will not have to wait much longer, I am writing the final parts XDsmiley.gif.
Title: CIB
Post by: DJ Omnimaga on August 16, 2006, 05:03:00 am
good to hear, I cant wait to try
Title: CIB
Post by: kalan_vod on August 17, 2006, 02:37:00 pm
Well I finished it on Tuesday, but I had to work a bit. So http://www.ticalc.org/archives/files/fileinfo/390/39015.html is the program, with four demos and explanations of all. I also included four SS of each, which are in the demos folder in each category.

Basic:
user posted image
Basic-decimals:
user posted image
xLIB:
user posted image
xLIB-decimals:
user posted image

The differences of these SS are explained in the read me, or should I say "Don't Readme!" ;)wink.gif, let me know if you would like to see anything add (info and what not) or if you find anything confusing/incorrect. Thanks!
Title: CIB
Post by: Demon on August 17, 2006, 02:51:00 pm
Dude, if we were having a contest right now, you win hands down!
That compressor just owned any BASIC compressor ever built in the history of compressors.  Even mine.
Title: CIB
Post by: kalan_vod on August 17, 2006, 03:05:00 pm
Thanks a lot man, I appreciate the enthusiasm and all but I think we all would win! :Ptongue.gif, I mostly did this to provoke tr1p1ea into adding compression into xLIB ;)wink.gif.
Title: CIB
Post by: Dragon__lance on August 17, 2006, 03:32:00 pm
oooo, would you mind if we add this to xlib guru! Those screenies rock, are they in 83+ speed? :thumbup:google.gif
Title: CIB
Post by: kalan_vod on August 17, 2006, 04:07:00 pm
Yes they are, and sure...I would write something more for that though, which explains it more (if you would like).
Title: CIB
Post by: Halifax on August 18, 2006, 08:44:00 am
YO that rocks Ooooooommmmmggggg dude
Title: CIB
Post by: DJ Omnimaga on August 18, 2006, 10:07:00 am
WOW kalan as usual you impress me a lot! The ASCII screenshot almost run as fast as my old BASIC tilemappers and the xlib ones are faster than the non xlib ones, very great job on this, I am wondering if I should rewrite a new version of metroid now just for 83+ users? O_Oshocked2.gif

thats gonna make it to the RPG archives (TI programming tools) as soon as I have the time

At least I hope the ppl will stop saying "you cant make good basic games if your name is not kevin_o" I knew there are other ppl who CAN do great basic stuff, and even better (mostly optimising wise) than me even *point to kalan's compressor*
Title: CIB
Post by: kalan_vod on August 18, 2006, 03:08:00 pm
Thank kevin, I appreciate it. I had the original code, and Weregoose optimized it quite a bit. I just thought of this when I was playing M Pure by CDI, as it ran about the speed of his map displayer. I just keep taking up side projects to cover for lack of progress on major projects ;)wink.gif...kinda like spencer XDsmiley.gif, not really.
Title: CIB
Post by: DJ Omnimaga on August 19, 2006, 01:56:00 am
hehe I understand the feeling, btw does pure use compression?
Title: CIB
Post by: kalan_vod on August 19, 2006, 06:59:00 am
QuoteBegin-xlibman+Aug 19 2006, 07:56 AM-->
QUOTE (xlibman @ Aug 19 2006, 07:56 AM)
hehe I understand the feeling, btw does pure use compression?  

 No, I was just making a comparison. Saying it ran close to the same speed.
Title: CIB
Post by: DJ Omnimaga on August 19, 2006, 07:26:00 am
aaah yeah i remember
Title: CIB
Post by: DJ Omnimaga on August 20, 2006, 01:42:00 pm
splutted pyro compressor project from this topic
Title: CIB
Post by: kalan_vod on August 20, 2006, 04:43:00 pm
Thanks.
Title: CIB
Post by: DJ Omnimaga on September 10, 2006, 01:07:00 pm
hkmm ugh... anyone's up to port metroid to this for me lol?
Title: CIB
Post by: Halifax on September 11, 2006, 10:08:00 am
you know I thought about porting in one day but I don't know how to use CIB
Title: CIB
Post by: DJ Omnimaga on September 12, 2006, 01:31:00 am
i doubt it is really that hard to use, but i dunno since i never played it. I think lolje should use it for AOCII maps :)smile.gif
Title: CIB
Post by: kalan_vod on September 12, 2006, 07:56:00 pm
QuoteBegin-xlibman+12 Sep, 2006, 7:31-->
QUOTE (xlibman @ 12 Sep, 2006, 7:31)
i doubt it is really that hard to use, but i dunno since i never played it. I think lolje should use it for AOCII maps :)smile.gif

 He did? I would love to see more of those who put this to use, I have been using it on Chips...I rewrote the engine too..maybe I should make a update o.oblink.gif .
Title: CIB
Post by: DJ Omnimaga on September 13, 2006, 01:28:00 am
no he didnt i just said he should ^^
Title: CIB
Post by: kalan_vod on September 13, 2006, 08:06:00 am
QuoteBegin-xlibman+13 Sep, 2006, 7:28-->
QUOTE (xlibman @ 13 Sep, 2006, 7:28)
no he didnt i just said he should ^^  

 Oh, well anyone can use it...I just wanted to see how others made use of it ;)wink.gif.