-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|590|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
SoCoder -> Snippet Home -> Variables


 
Jayenkai
Created : 27 April 2013
 
System : Cross Platform

JNKrunch v1.0

Compress postable ascii data to compressed postable ascii data..!

Spinal's currently pulling his hair out over JNKrunch, so I thought it best to go over the whole lot and get it fully working again.

I've taken the current Monkey version of the code, and rejigged it to work in both BlitzMax and Blitz2D/3D/Plus, too.

JNKrunch takes a string of letters/numbers, compresses it as much as it can in a very simple way, then spits out the (hopefully) smaller result.

You should find that the compressed result from all three are identical, so should be easily portable between the different versions.

Function

CompressedString=JNKrunch(MyString)
to compress a string, and
OriginalString=JuNKrunch(CompressedString)
to get it back again.
Couldn't really be any easier.

How?

JNKrunch uses bog standard piss-easy compression methods.
The basic output is "Number of Repeats, Letter, Number of Repeats, Letter" and so on, until the length of the string is reached.
Example, "HELLO" would be converted as 1 H, 1 E, 2 L, 1 O.
1H1E2L1O is longer than HELLO, so in this example you might as well not bother with JNKrunch.
Example 2 : "AAABBBCCCDDD" would be converted to 3 A, 3 B, 3 C, 3 D
3A3B3C3D is smaller than AAABBBCCCDDD, so would be marginally useful in this scenario.

Usage

Best used to compress level data, where you know things are vaguely similar.
For example, if you're making a level with lots of "1" floors, "0" sky, and "2" walls, you'll have a lot of repeating data. JNKrunch is fantastic for compressing things like that.

Monkey



BlitzMax



Blitz2D/3D/Plus



Let me know if you need any further conversions of this function.

 

Comments


Sunday, 21 August 2016, 07:34
spinal
I don't suppose there's a C version knocking about?
Sunday, 21 August 2016, 07:37
Jayenkai
Nope!
But feel free to post it when you're done
3 sources to choose from, should be easy enough.
Sunday, 21 August 2016, 08:13
spinal
Will do, not yet though, gotta play some Wii games!
Sunday, 21 August 2016, 08:26
Jayenkai
Needs to be done!!
Sunday, 21 August 2016, 12:02
spinal
Not fully tested, but it looks right, JuNKrunch only though (thats all I need)

c#