Adventure Game with text input
Moderator: MaxCoderz Staff
-
- Calc Wizard
- Posts: 526
- Joined: Tue 08 Mar, 2005 1:37 am
- Location: who wants to know?
- Contact:
Unless you found a way of compressing it. For example, replacing all zeroes with negative of the amount of zeroes. {4,3,2,0,0,0} would become {4,3,2,-3
To decompress it:
1->I
For(A,1,8
For(B,1,12 //A and B are row, column of the matrix, change the numbers accordingly
I+not(L1(I -> I
L1(I
If 0<Ans:Then
IS>(I,e3
Ans->[A](A,B
Else
Ans+1->L1(I
0->[A](A,B
End
End
End
To decompress it:
1->I
For(A,1,8
For(B,1,12 //A and B are row, column of the matrix, change the numbers accordingly
I+not(L1(I -> I
L1(I
If 0<Ans:Then
IS>(I,e3
Ans->[A](A,B
Else
Ans+1->L1(I
0->[A](A,B
End
End
End
So, I'd just put it into L1, then run this? Just so you know, the matrix will be 6x20.DarkerLine wrote:Unless you found a way of compressing it. For example, replacing all zeroes with negative of the amount of zeroes. {4,3,2,0,0,0} would become {4,3,2,-3
To decompress it:
1->I
For(A,1,8
For(B,1,12 //A and B are row, column of the matrix, change the numbers accordingly
I+not(L1(I -> I
L1(I
If 0<Ans:Then
IS>(I,e3
Ans->[A](A,B
Else
Ans+1->L1(I
0->[A](A,B
End
End
End
so would that make it
Code: Select all
1->I
For(A,1,6
For(B,1,20 //A and B are row, column of the matrix, change the numbers accordingly
I+not(L1(I -> I
L1(I
If 0<Ans:Then
IS>(I,e3
Ans->[A](A,B
Else
Ans+1->L1(I
0->[A](A,B
End
End
End
Also, when there is only 1 zero, should I put -1 or 0 in the compressed form?
compressed form:
Code: Select all
{4,3,2,-6,1,-2,1,-6,1,0,5,-4,4,-3,9,7,-4,6,-10,7,0,6,10,-3,11,-2,9,-3,10,0,12,-4,11,-9,15,-5,16,14,-4,128,15,-8,18,-6,17,-5,8->L1
In Memory of the Maxcoderz Trophy
For some reason, this is not working. It gives me an Invalid dim error on the line that saysBASIC Code wrote::{19,6}dim([A]
:{4,3,2,(-)6,1,(-)2,1,(-)6,1,0,5,(-)4,4,(-)3,9,7,(-)4,6,(-)10,7,0,6,10,(-)3,11,(-)2,9,(-)3,10,0,12,(-)4,11,(-)9,15,(-)5,16,14,(-)4,128,15,(-)8,18,(-)6,17,(-)5,8L1
:1I
:For(A,1,19
:For(B,1,6
:I+not(L1(II
:L1(I
:If 0<Ans:Then
:IS>(I,e3
:Ans[A](A,B
:Else
:Ans+1L1(I
:0[A](A,B
:End
:End
:End
Generated by SourceCoder, © 2005 Cemetech
Code: Select all
I+not(L1ÂÂÂ
In Memory of the Maxcoderz Trophy
INVALID DIM:
you tried to put data into a non-existant var,tried to put data into a var and put it out side of the data range it was made to hold, you tried to read data that is out side the bounds of the variable, or you tried to load data improperly from a var
you need to specify which list element: L1(Var) as opposed to L1
you tried to put data into a non-existant var,tried to put data into a var and put it out side of the data range it was made to hold, you tried to read data that is out side the bounds of the variable, or you tried to load data improperly from a var
you need to specify which list element: L1(Var) as opposed to L1
That code that DarkerLine posted seems to be wrong. I'm guessing the I value it is using is too high. Does anyone know why you are adding I and the value at position I of L1 and storing it as I? I don't follow what that's supposed to do. In any case, it's not working.
In Memory of the Maxcoderz Trophy
Ok I played with making a compression method today and this is what I got:
-prgm with the matrix
-prgm with the compressed list
saved 67 bytes with the compressed list
The way the code works here is
-L1(1) and L1(2) = the diminsions of the matrix
-Then on L1(3) is the first number, but since its a neg. number it is then interperated as a sign of how many times the following number will be used. So -3,1 would be 1,1,1. And if there isn't a neg. number then it will just list that number there in the appropiate [A](A,B.
-The only limitaion this routine has is, lets say the first row of a 8x12 matrix is all 1s, but the second rows first number is a 1 also. We can't make it -13,1. So we have to make it -12,1,1,etc...
Now this is with just one of my levels for Res, so the compression can be very space saving.
Just one thing you have to consider though. What is more important in your program:
-Size or Speed?
or
Let me know if you don't understand something or if you think this is good or bad . Also whats you opion of speed or size.
Edit: I realize there are a few ops. that can be added so if you have a addition let me know.
Edit Edit: If L1(X)abs(L1(X:Then
can be changed into
If not(L1(X
In regards to space save within a program:{L1(1),L1(2dim([A]:2X
:For(A,1,L1(1
:1B
:Repeat B>L1(2
+1X
:If L1(X)abs(L1(X:Then
:For(W,1,abs(L1(X
:L1(X+1[A](A,B
:B+1B
:End
+1X
:Else
:L1(X[A](A,B
:B+1B
:End
:End
:End
-prgm with the matrix
Code: Select all
[[1,1,1,10,10,10,10,10,10,1,1,1]
[1,40,1,1,1,1,1,10,10,1,40,1]
[1,40,40,40,40,40,1,1,1,1,40,1]
[1,40,40,38,40,7,40,40,7,40,40,1]
[1,40,40,40,7,40,40,40,7,40,40,1]
[1,40,1,1,1,40,1,1,1,1,40,1]
[1,1,1,10,1,1,1,10,10,1,40,1]
[10,10,10,10,10,10,10,10,10,1,39,1
Code: Select all
{8,12,(-)3,1,(-)6,10,(-)3,1,1,40,(-)5,1,(-)2,10,1,40,1,1,(-)5,40,(-)4,1,40,1,1,(-)2,40,38,40,7,(-)2,40,7,(-)2,40,1,1,(-)3,40,7,(-)3,40,7,(-)2,40,1,1,40,(-)3,1,40,(-)4,1,40,1,(-)3,1,10,(-)3,1,(-)2,10,1,40,1,(-)9,10,1,39,1
The way the code works here is
-L1(1) and L1(2) = the diminsions of the matrix
-Then on L1(3) is the first number, but since its a neg. number it is then interperated as a sign of how many times the following number will be used. So -3,1 would be 1,1,1. And if there isn't a neg. number then it will just list that number there in the appropiate [A](A,B.
-The only limitaion this routine has is, lets say the first row of a 8x12 matrix is all 1s, but the second rows first number is a 1 also. We can't make it -13,1. So we have to make it -12,1,1,etc...
Now this is with just one of my levels for Res, so the compression can be very space saving.
Just one thing you have to consider though. What is more important in your program:
-Size or Speed?
or
Let me know if you don't understand something or if you think this is good or bad . Also whats you opion of speed or size.
Edit: I realize there are a few ops. that can be added so if you have a addition let me know.
Edit Edit: If L1(X)abs(L1(X:Then
can be changed into
If not(L1(X
- L4E_WakaMol-King
- Maxcoderz Staff
- Posts: 342
- Joined: Tue 01 Nov, 2005 6:34 am
I agree with Spengo... go with speed over size. The only problem you might run into there is getting stuff from the archive. Will there be a routine to do this or will the user have to unarchive things? Or will the program just fit in ram?
Btw, nice BASIC compression routine.
Btw, nice BASIC compression routine.
- Now Under Development - [Progress]
For getting stuff out of ram, I was thinking about using Flash Gordon. And for these loading up the matrix things, I was actually hoping to optimize for size. They only run once, and as long as they only take a few seconds, that would be OK.
As for the compression routine, The data I am using has no repeating digits other than zero. However, there are alot of repeating zeros. Therefore, I think that the idea DarkerLine had to represent the amount of zeros with negative numbers is the best. For some reason, his code isn't working though.
His code with my data:
As for the compression routine, The data I am using has no repeating digits other than zero. However, there are alot of repeating zeros. Therefore, I think that the idea DarkerLine had to represent the amount of zeros with negative numbers is the best. For some reason, his code isn't working though.
His code with my data:
BASIC Code wrote::{19,6}dim([A]
:{4,3,2,(-)6,1,(-)2,1,(-)6,1,0,5,(-)4,4,(-)3,9,7,(-)4,6,(-)10,7,0,6,10,(-)3,11,(-)2,9,(-)3,10,0,12,(-)4,11,(-)9,15,(-)5,16,14,(-)4,128,15,(-)8,18,(-)6,17,(-)5,8L1
:1I
:For(A,1,19
:For(B,1,6
:I+not(L1(II
:L1(I
:If 0<Ans:Then
:IS>(I,e3
:Ans[A](A,B
:Else
:Ans+1L1(I
:0[A](A,B
:End
:End
:End
Generated by SourceCoder, © 2005 Cemetech
In Memory of the Maxcoderz Trophy
-
- Calc King
- Posts: 2195
- Joined: Sun 27 Mar, 2005 4:06 am
- Location: sleeping
- Contact:
Code: Select all
:{19,6}->dim([A]
:{4,3,2,(-)6,1,(-)2,1,(-)6,1,0,5,(-)4,4,(-)3,9,7,(-)4,6,(-)10,7,0,6,10,(-)3,11,(-)2,9,(-)3,10,0,12,(-)4,11,(-)9,15,(-)5,16,14,(-)4,128,15,(-)8,18,(-)6,17,(-)5,8}->L1
:For(A,1,dim(L1
:If L1(A)<0
:Then
:For(B,1,-L1(A)
:0->[A](int(A/6),A-int(A/6)
:End
:Else
:L1(A->[A](int(A/6),A-int(A/6)
:End
:End