Author 
Message 

woodswolf
Advanced Newbie
Joined: 26 Feb 2009 Posts: 53

Posted: 18 Apr 2009 02:55:58 pm Post subject: 


For a game I'm making, I have a list {21.14,21.11,4.11,4.07}
For calculations however, I need to convert the List into {21.14,21.13,21.12,21.11,20.11,19.11,18.11,17.11,16.11,15.11,14.11,13.11,12.11,1
1.11,10.11,9.11,8.11,7.11,6.11,5.11.4.11,4.10,4.09,4.08,4,07}. I'm sure you can spot the logic in it! However, If I want to make such a thing, I need to make lots of For('s and it gets hard to read after a while.
Who can write a code that does this as fast as possible? I would like to see some results. 

Back to top 


simplethinker snjwffl
Active Member
Joined: 25 Jul 2006 Posts: 700

Posted: 18 Apr 2009 03:55:42 pm Post subject: 


It looks like the logic is: Start with the first element and decrement (by .01) until it equals the second, then decrement (by 1) until it equals the third element, and from there decrement (by .01) until it equals the fourth. Is that right?
Now some questions:
1) Will it always be four elements, or does it need to be generalized to multiple pairs?
1) Do the first two elements always have the same integral part, the second and third elements have the same fractional part, and the last two elements always have the same integral part?
3) Will it always be a descending sequence?
4) What is this for? (Knowing where these numbers come from and their use would be can help)
For a list exactly of the form you gave above, this should work (assuming the input list is in Ans):
Code: :augment(seq(I,I,Ans(1),Ans(2),.01),augment(seq(I,I,Ans(2)1,Ans(3),1),seq(I,I,Ans(3).01,Ans(4),.01


Back to top 


darkstone knight
Advanced Member
Joined: 07 Sep 2008 Posts: 438

Posted: 18 Apr 2009 04:01:12 pm Post subject: 


sub({2114,2111,411,407>L1
{L1(1
for(A,2,dim(L1
repeat L1(A)=ans(dim(ans
augment(ans,{ans(dim(ans))+tanh(E9(L1(A)L1(A1)))(1.99not(not(fpart(L1(A)L1(A1
end
end
tested it, it works
edit: it does this list in .3 seconds :roll:
edit: AAARGH, got beaten :(
edit: @ above, he is making a tower defence game, the list is alowed to increment
edit: just saying hi...
Last edited by Guest on 18 Apr 2009 04:10:52 pm; edited 1 time in total 

Back to top 


woodswolf
Advanced Newbie
Joined: 26 Feb 2009 Posts: 53

Posted: 18 Apr 2009 04:10:38 pm Post subject: 


simplethinker wrote: Now some questions:
1) Will it always be four elements, or does it need to be generalized to multiple pairs?
2) Do the first two elements always have the same integral part, the second and third elements have the same fractional part, and the last two elements always have the same integral part?
3) Will it always be a descending sequence?
4) What is this for? (Knowing where these numbers come from and their use would be can help)
Maybe my lack of mathematical english sometimes makes me unable to clearify things, Guess I need to use translate.google more.
1) No, It can be anything. I believe maximum could be 336
2) No, it depends on what is changing. If the integer changing, add or substract 1 to the number untill you get to the next number.
3) No
4) Tower Defence. I'm great at basic, if I may say so myself. Got some nifty ideas for this one :ninja:
Last edited by Guest on 18 Apr 2009 04:13:14 pm; edited 1 time in total 

Back to top 


woodswolf
Advanced Newbie
Joined: 26 Feb 2009 Posts: 53

Posted: 18 Apr 2009 04:24:38 pm Post subject: 


darkstone knight wrote: sub({2114,2111,411,407>L1
{L1(1
for(A,2,dim(L1
repeat L1(A)=ans(dim(ans
augment(ans,{ans(dim(ans))+tanh(E9(L1(A)L1(A1)))(1.99not(not(fpart(L1(A)L1(A1
end
end
tested it, it works
edit: it does this list in .3 seconds :roll:
edit: AAARGH, got beaten :(
edit: @ above, he is making a tower defence game, the list is alowed to increment
edit: just saying hi...
despite the edits, thanks! I will be thinking of a code too.
Well, sorry but the code is rather slow to generate. I think thats because of the tanh function.
This is what I got.
ΔList(LTOWER>L1
{LTOWER(1>L2
For(A,1,dim(L1
(2(0<L1(A))1)/(1+99(1>abs(L1(A
augment(L2,seq(LTOWER(A)+B,B,Ans,L1(A),Ans>L2
End
Last edited by Guest on 19 Apr 2009 07:54:43 am; edited 1 time in total 

Back to top 


thebetter1
Advanced Newbie
Joined: 09 Jul 2008 Posts: 86

Posted: 22 Apr 2009 09:21:40 pm Post subject: 


woodswolf wrote: simplethinker wrote: Now some questions:
1) Will it always be four elements, or does it need to be generalized to multiple pairs?
2) Do the first two elements always have the same integral part, the second and third elements have the same fractional part, and the last two elements always have the same integral part?
3) Will it always be a descending sequence?
4) What is this for? (Knowing where these numbers come from and their use would be can help)
Maybe my lack of mathematical english sometimes makes me unable to clearify things, Guess I need to use translate.google more.
1) No, It can be anything. I believe maximum could be 336
2) No, it depends on what is changing. If the integer changing, add or substract 1 to the number untill you get to the next number.
3) No
4) Tower Defence. I'm great at basic, if I may say so myself. Got some nifty ideas for this one :ninja:
I wanted to make a tower defense game a while ago. I never got around to it though, since I've been a bit busy with Calculus homework and my RPG. It will be interesting to see what you're doing with that list. 

Back to top 


woodswolf
Advanced Newbie
Joined: 26 Feb 2009 Posts: 53

Posted: 23 Apr 2009 09:09:49 am Post subject: 


It's pretty simple. It turns the "path" into a "tilebytile". 

Back to top 


