Author Topic: The best list compression method?  (Read 8354 times)

0 Members and 1 Guest are viewing this topic.

Offline Raylin

  • Godslayer
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1392
  • Rating: +83/-25
  • I am a certifiable squirrel ninja.
    • View Profile
    • Ray M. Perry
The best list compression method?
« on: November 27, 2009, 07:17:41 pm »
SO.
I have a list of exactly 384 elements.
Said list is ~3900 bytes.
Compressed into complex numbers is ~1950 bytes.

Is there any easily implementable way to make that smaller?

To get said 384 element list:
Code: [Select]
99binomcdf(127,0->L1
augment(L1,L1
augment(Ans,L1->L1
0
« Last Edit: November 27, 2009, 07:29:14 pm by ProphetsDementia »
Bug me about my book.

Sarah: TI-83 Plus Silver Edition [OS 1.19]
Cassie: TI-86 [OS 1.XX]
Elizabeth: TI-81 [OS 1.XX]
Jehuty: TI-83 Plus Silver Edition [OS 1.19]
Tesla: CASIO Prizm







Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: The best list compression method?
« Reply #1 on: November 27, 2009, 07:30:38 pm »
or
:99binomcdf(127,0
:augment(Ans,augment(Ans,Ans->L1
:0

Edit: Right number of augments now.
« Last Edit: November 27, 2009, 09:20:36 pm by ztrumpet »

Offline Raylin

  • Godslayer
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1392
  • Rating: +83/-25
  • I am a certifiable squirrel ninja.
    • View Profile
    • Ray M. Perry
Re: The best list compression method?
« Reply #2 on: November 27, 2009, 07:36:26 pm »
Oooh.
You can double augment?
Cool.

BTW, too many augments.
Bug me about my book.

Sarah: TI-83 Plus Silver Edition [OS 1.19]
Cassie: TI-86 [OS 1.XX]
Elizabeth: TI-81 [OS 1.XX]
Jehuty: TI-83 Plus Silver Edition [OS 1.19]
Tesla: CASIO Prizm







Offline Geekboy1011

  • The Oneironaut
  • Donator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2031
  • Rating: +119/-2
  • Dream that Awakening dream
    • View Profile
Re: The best list compression method?
« Reply #3 on: November 27, 2009, 08:28:19 pm »
can someone explainthis in detail; so i can use id XD

it seems to be very use full and how do you go about compressing it??


Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: The best list compression method?
« Reply #4 on: November 27, 2009, 09:20:09 pm »
It's just getting a list of 99s that is 384 elements long.

:99binomcdf(127,0
99 times a list of 1s 127+1 (128) long.
:augment(Ans,augment(Ans,Ans
Takes the list and appends itself on it's end twice. It is now 384 elements long.

Offline Raylin

  • Godslayer
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1392
  • Rating: +83/-25
  • I am a certifiable squirrel ninja.
    • View Profile
    • Ray M. Perry
Re: The best list compression method?
« Reply #5 on: November 27, 2009, 09:41:21 pm »
I was playing around with some of the other variables.
A matrix (32*3) is exactly 875 bytes.
Now, is there a way to store complex numbers to said matrix?
Bug me about my book.

Sarah: TI-83 Plus Silver Edition [OS 1.19]
Cassie: TI-86 [OS 1.XX]
Elizabeth: TI-81 [OS 1.XX]
Jehuty: TI-83 Plus Silver Edition [OS 1.19]
Tesla: CASIO Prizm







Offline Galandros

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1140
  • Rating: +42/-10
    • View Profile
Re: The best list compression method?
« Reply #6 on: November 28, 2009, 03:50:41 am »
I was playing around with some of the other variables.
A matrix (32*3) is exactly 875 bytes.
Now, is there a way to store complex numbers to said matrix?
I don't think it is possible. Also multiply an entire matrix by a number doesn't work too. This gives an error.
Hobbing in calculator projects.

Offline Raylin

  • Godslayer
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1392
  • Rating: +83/-25
  • I am a certifiable squirrel ninja.
    • View Profile
    • Ray M. Perry
Re: The best list compression method?
« Reply #7 on: November 28, 2009, 10:09:52 am »
Found a pretty good compression trick.
(Remember, I'm trying to do this all in TI-BASIC. Don't want all my games to require external APPS.)

If you store your list as a string to one of the sequence variables, u, v, w, you can half the size of the entire thing.
Then, if you need to evaluate it, run 'u' and Ans(X where X is the list element.

The only issue with this is the lack of editability if that's a word.
Bug me about my book.

Sarah: TI-83 Plus Silver Edition [OS 1.19]
Cassie: TI-86 [OS 1.XX]
Elizabeth: TI-81 [OS 1.XX]
Jehuty: TI-83 Plus Silver Edition [OS 1.19]
Tesla: CASIO Prizm







Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: The best list compression method?
« Reply #8 on: November 28, 2009, 11:09:52 am »
I was playing around with some of the other variables.
A matrix (32*3) is exactly 875 bytes.
Now, is there a way to store complex numbers to said matrix?
I don't think it is possible. Also multiply an entire matrix by a number doesn't work too. This gives an error.
I remember multiplying by a number worked. I don't think adding by a number did though.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline simplethinker

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 695
  • Rating: +16/-5
  • snjwffl
    • View Profile
Re: The best list compression method?
« Reply #9 on: November 28, 2009, 11:34:12 am »
I have a list of exactly 384 elements.
Said list is ~3900 bytes.
Compressed into complex numbers is ~1950 bytes.
What kind of elements are you saving (integers, decimals)?  The most efficient type of compression to use will rely on that.

In general, to get the most out of list compression it helps to understand how the calculator stores certain things:
1) Real numbers are always exactly 9† bytes, and store exactly 14† digits.
2) Complex numbers are nothing but two real numbers put together; they're 18† bytes and can store two 14-digit numbers.
3) Lists are just a bunch of real/complex numbers stored sequentially.  A four-element real list will be 4*9=36† bytes; a two-element complex list (basically four numbers) will be 2*18=36† bytes.
3b) There is no such thing as a list with real and complex elements; if a list has one complex element, then every other element is treated as such and takes up 18 bytes, even if they have no imaginary part.
4) Matrices are basically lists.  An NxM matrix is just an N*M element list of real numbers, so a 4x5 matrix is 4*5*9=180† bytes.
4b) The OS doesn't support complex values in matrices, only real numbers.  The reason for this is probably that matrices can quickly grow to over 10KB without the user realizing it, so doubling the size to allow for complex numbers would kind of suck.

Considering (3) and (3b), how did you use complex numbers to halve the size of the list?  By adding complex list elements, you'll halve the number of elements, but the remaining ones will double in size.

†This is for the data itself.  For an actual variable (e.g. L1 or A), there are a few extra bytes containing the variable name and some other stuff.


To get said 384 element list:
Code: [Select]
99binomcdf(127,0->L1
augment(L1,L1
augment(Ans,L1->L1
0

If you want a 384 element list of all 99's, you could just use (assuming you want L1):
Code: [Select]
:384→dim(L1
:Fill(99,L1
This also has the nice effect of not storing the result in Ans, so you don't need double the spare RAM :)(however, storing the dimensions of the list does modify Ans).


Matrices can be multiplied by a (real) number, but you can't add number to one.
« Last Edit: November 28, 2009, 11:40:09 am by simplethinker »
"We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare. Now, thanks to the Internet, we know this is not true." -- Professor Robert Silensky



Chip's Challenge: ħ%

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: The best list compression method?
« Reply #10 on: November 28, 2009, 12:06:13 pm »
To add a number to a matrix, you need to create another matrix of the same size, fill it with the number you want to add/subtract, and then you can add/subtract those matrixes.  I use this in Shift, ans so i had a dedicated addition matrix :)

Offline Galandros

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1140
  • Rating: +42/-10
    • View Profile
Re: The best list compression method?
« Reply #11 on: November 28, 2009, 03:26:50 pm »
I remember multiplying by a number worked. I don't think adding by a number did though.
Oh, you are right.

To add a number to a matrix, you need to create another matrix of the same size, fill it with the number you want to add/subtract, and then you can add/subtract those matrixes.  I use this in Shift, ans so i had a dedicated addition matrix :)
TI-BASIC turns quite fun with all these works around. Still a nice technique.

I haven't found in real games any usefulness of row+( and row*( commands... It would be curious to see one.
Hobbing in calculator projects.

Offline Raylin

  • Godslayer
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1392
  • Rating: +83/-25
  • I am a certifiable squirrel ninja.
    • View Profile
    • Ray M. Perry
Re: The best list compression method?
« Reply #12 on: November 28, 2009, 06:47:35 pm »
Dedicated... addition... matrix...

FFFFFFFFFFF... IDEA.

EDIT: Okay. What if the HP for each army unit was stored in a 8*4 matrix?
Then, the ATK minus DEF of each corresponding unit was stored to another 8*4 matrix?
So, now you have 4 matrices.
If it's the enemy's turn, subtract matrix (A).
If it's your turn, subtract matrix (B).

Bulky, but implementable?
« Last Edit: November 28, 2009, 06:52:24 pm by ProphetsDementia »
Bug me about my book.

Sarah: TI-83 Plus Silver Edition [OS 1.19]
Cassie: TI-86 [OS 1.XX]
Elizabeth: TI-81 [OS 1.XX]
Jehuty: TI-83 Plus Silver Edition [OS 1.19]
Tesla: CASIO Prizm







Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: The best list compression method?
« Reply #13 on: November 28, 2009, 06:52:54 pm »
If you store your list as a string to one of the sequence variables, u, v, w, you can half the size of the entire thing.
Then, if you need to evaluate it, run 'u' and Ans(X where X is the list element.

The only issue with this is the lack of editability if that's a word.
That's neat.

I don't use complex numbers for compression because I don't see anyway to make things smaller with them. :)

Offline Raylin

  • Godslayer
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1392
  • Rating: +83/-25
  • I am a certifiable squirrel ninja.
    • View Profile
    • Ray M. Perry
Re: The best list compression method?
« Reply #14 on: November 28, 2009, 06:56:57 pm »
This is true, unfortunately.
In my other game, Shin Megami Tensei, I made a list considerably smaller with complex numbers.
Guess I'm just using what used to work.
Bug me about my book.

Sarah: TI-83 Plus Silver Edition [OS 1.19]
Cassie: TI-86 [OS 1.XX]
Elizabeth: TI-81 [OS 1.XX]
Jehuty: TI-83 Plus Silver Edition [OS 1.19]
Tesla: CASIO Prizm