Author Topic: CIB  (Read 9215 times)

0 Members and 1 Guest are viewing this topic.

Offline kalan_vod

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2715
  • Rating: +10/-0
    • View Profile
    • kalanrock.us
CIB
« 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%.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
CIB
« Reply #1 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?

Offline kalan_vod

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2715
  • Rating: +10/-0
    • View Profile
    • kalanrock.us
CIB
« Reply #2 on: August 08, 2006, 12:58:00 pm »
Well, with the map of Tank it takes around 9 seconds.

Dragon__lance

  • Guest
CIB
« Reply #3 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

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
CIB
« Reply #4 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

Offline kalan_vod

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2715
  • Rating: +10/-0
    • View Profile
    • kalanrock.us
CIB
« Reply #5 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.

elfprince13

  • Guest
CIB
« Reply #6 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?

Offline kalan_vod

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2715
  • Rating: +10/-0
    • View Profile
    • kalanrock.us
CIB
« Reply #7 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.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
CIB
« Reply #8 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

Offline Spellshaper

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1690
  • Rating: +0/-0
  • This is me. Or maybe not.
    • View Profile
CIB
« Reply #9 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

Offline lolje

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 299
  • Rating: +2/-0
    • View Profile
CIB
« Reply #10 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!
83+/84+ xLIB projects
Age of culture II (~89%)

Contact: [email protected]

elfprince13

  • Guest
CIB
« Reply #11 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.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
CIB
« Reply #12 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

Dragon__lance

  • Guest
CIB
« Reply #13 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

Offline kalan_vod

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2715
  • Rating: +10/-0
    • View Profile
    • kalanrock.us
CIB
« Reply #14 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.