For some reason,
Code:
:Lbl L
:∟WALL(J)-1→∟WALL(J
:G+1→G
:Z-1→Z
:If ‾1=Z
:Then
:DelVar ∟WATER
:1→dim(∟WATER
:If 270>J
:Then
:If ‾2=∟WALL(J+27
:1→∟WATER(1
:End
:If 54<J
:Then
:If ‾2=∟WALL(J-27
:1→∟WATER(1
:End
:If (J+1)/27≠int((J+1)/27
:Then
:If ‾2=∟WALL(J+1
:1→∟WATER(1
:End
:If (J-1)/27≠int((J-1)/27
:Then
:If ‾2=∟WALL(J-1
:1→∟WATER(1
:End
:If ∟WATER(1
:Then
:DelVar L
:J→∟WATER(1
:‾2→Z
:Repeat L=dim(∟WATER
:L+1→L
:∟WATER(L→R
:If 270>R
:Then
:If ‾1=∟WALL(R+27) and 0=max(∟WATER=R+27
:Then
:1+dim(∟WATER→dim(∟WATER
:R+27→∟WATER(dim(∟WATER
:End
:End
:If 54<R
:Then
:If ‾1=∟WALL(R-27) and 0=max(∟WATER=R-27
:Then
:1+dim(∟WATER→dim(∟WATER
:R-27→∟WATER(dim(∟WATER
:End
:End
:If (R+1)/27≠int((R+1)/27
:Then
:If ‾1=∟WALL(R+1) and 0=max(∟WATER=R+1
:Then
:1+dim(∟WATER→dim(∟WATER
:R+1→∟WATER(dim(∟WATER
:End
:End
:If (R-1)/27≠int((R-1)/27
:Then
:If ‾1=∟WALL(R-1) and 0=max(∟WATER=R-1
:Then
:1+dim(∟WATER→dim(∟WATER
:R-1→∟WATER(dim(∟WATER
:End
:End
:‾2→∟WALL(R
:int(R/27→T
:R-27T→U
:If R=∟PLACE(1
:Then
:det(12,GREEN,LTBLUE
:Else
:det(12,RED,LTBLUE
:End
:For(I,1,F
:If R=∟PLACE(I
:Then
:If 10≤∟LIVES(I
:Then
:Output(T,U,"θ
:Else
:Output(T,U,int(∟LIVES(I
:End
:‾2→∟LEVEL(I
:End
:End
:If 0=max(∟PLACE=R
:Output(T,U,"
:End
:End
:End
:Goto A
exits this loop
Code:
:Repeat ∟LIVES(1)≤0 or sum(0≥∟LIVES)=F-1
:For(E,1,F
:If 0≥∟LIVES(E
:Then
:Else
:Goto L
:Lbl A
:End
:End
:End
And I don't know why it exits the loop, because at the end of it, I have this, which checks the two conditions needed to exit the Repeat
Code:
:If 0≥∟LIVES(1
:Disp "You Lose!
:If sum(0≥∟LIVES)=F-1 and 0<∟LIVES(1
:Disp "You Win!
:Pause
What happened?
Well, a Repeat is checked at the end of the loop, and is checked to see if it is false to run again. You should check and verify values are correct.

Also, very very bad idea to have a Goto inside a loop of any kind.
As far as I can tell, all the values are correct, and the LIVES list needed to exit the Repeat isn't changed at all in the Goto.
I've resorted to removing the Goto/Lbl.

This particular loop is running painfully slow. I've optimized it some, and I could optimize it more, but I've only got about 3-4kb more that I can use before the calculator runs out of memory. Any speed improvement is wanted.
Code:
:Repeat L=B
:L+1→L
:int(∟WATER(L)/27→T
:∟WATER(L)-27T→U
:rand(4→∟RAND2
:SortA ∟RAND2,∟RAND1
:For(I,1,4
:T-(T>1 and 1=∟RAND1(I))+(T<10 and 2=∟RAND1(I→M
:U-(U>1 and 3=∟RAND1(I))+(U<26 and 4=∟RAND1(I→C
:27M+C→R
:If ‾1=∟WALL(R) and 0=max(R=∟WATER
:Then
:B+1→B
:R→∟WATER(B
:End
:End
:‾2→∟WALL(∟WATER(L
:Output(T,U,"
:End
Also, how would I split X values 3 evenly and randomly ways? For example, if X was 5, some of the 21 total combinations could be 3,1,1; 2,1,2; 0,5,0; 2,0,3. If I wanted to split it 2 ways, I could do
Code:
:randInt(0,X→A
:X-A→B
but the problem occurs when I try to split 3 ways, and I get a 50,25,25 ratio.
Here's my solution, which produces the three values as a three-element list:


Code:
:augment({0,5},randInt(0,5,2→L₁
:SortA(L₁
:ΔList(L₁
I see how that would work, thanks.

As some of you know, I'm adding potions and enchantments in the next PvP Craft update. The problem that I've occurred is when adding the values for the slowness and swiftness potions. Being that all the potions and enchantments will be the same price, I want the potions to be as equal as possible, with any number of enemies. Below is a chart showing the number of 'turns' the player gets over total number of 'turns' per 'round' for the swiftness potions.
Code:
Enemies|None|Swift 1|Swift 2|Swift 3|Swift 4|Swift 5
1      |1/2 |2/3    |3/4    |4/5    |5/6    |6/7
2      |1/3 |2/4    |3/5    |4/6    |5/7    |6/8
3      |1/4 |2/5    |3/6    |4/7    |5/8    |6/9
4      |1/5 |2/6    |3/7    |4/8    |5/9    |6/10
5      |1/6 |2/7    |3/8    |4/9    |5/10   |6/11
The values in the table may not look constant, but you get, for example, twice the number of turns as each enemy if you use a swiftness 2 potion. The way I will have it set up is that it repeats the player's turn per level on the swiftness potion and repeat that the length that the potion lasts. The problem with the slowness potions is that there is only one turn to lose per round and I don't want the effect of the potion carrying over into other rounds, making the strength of the potion and the length of the potion the same thing. I could make the potion have a chance of skipping the enemy's turn that its used on, but then there's a chance that it won't occur at all, making the potion a waste. Also, I would like the swiftness and slowness balanced where if there is one enemy, the enemy looses 1 turn, and if there are five enemies, they lose 5 turns.

Hopefully any of that makes sense. I need suggestions, and from there I can figure out the code.

Edit:
What I've decided to do was this: Pause the targeted enemy for a certain number of rounds, based the number of enemies and the strength of the potion.Then it lets the enemy move and it repeats a number of times based of the length of the potion.
Sounds like a reasonable solution to me, FrozenFire. Just to make sure, are there any pending questions here that haven't been answered yet? I realized that I made a note to myself to address this topic and then promptly forgot.
KermMartian wrote:
Sounds like a reasonable solution to me, FrozenFire. Just to make sure, are there any pending questions here that haven't been answered yet? I realized that I made a note to myself to address this topic and then promptly forgot.
The only problem I'm having now is trying to get PVP Craft to run with the limited RAM available. I'm trying to reduce the size of the program and its list, but I doubt I can compact it enough that after I finish the update, it would still be playable. The second option I have is creating separate programs, which I might be forced to do. I have 1 major reason against multiple programs: More things for me and other people to keep track of. I also have these questions:

-Does a program rearchive itself after handing control to the other program (if opened by Doors initially)?
-Can an archived program be ran by another program?
-Is there a way to hide the secondary program so it is neither seen by Doors or the OS?
FrozenFire49 wrote:
The second option I have is creating separate programs, which I might be forced to do. I have 1 major reason against multiple programs: More things for me and other people to keep track of. I also have these questions:

-Does a program rearchive itself after handing control to the other program (if opened by Doors initially)?
-Can an archived program be ran by another program?
-Is there a way to hide the secondary program so it is neither seen by Doors or the OS?
- No, if you call a TI-BASIC program from another TI-BASIC program, Doors CSE won't rearchive the original until it's completely done. There's no way to tell when you might Return from the child program into the parent program again and suddenly die from it being archived.
- I recommend you look at the ExecArcPrgm function in Doors CSE. If you break up your program into several relatively long-running subprograms, if possible, you can copy them into RAM, run them, then delete the temporary copies with this function.
- Yes. Putting either "rand" or "Ans" as the first token in a TI-BASIC program makes Doors CSE hide it from the desktop. To hide it from the OS, you could use Doors CSE's Hide function, then edit it from Doors CSE and add the Ans/rand to hide it from Doors CSE as well.
KermMartian wrote:
- Yes. Putting either "rand" or "Ans" as the first token in a TI-BASIC program makes Doors CSE hide it from the desktop. To hide it from the OS, you could use Doors CSE's Hide function, then edit it from Doors CSE and add the Ans/rand to hide it from Doors CSE as well.
So with the Doors header, would the first 3 lines look like this?
Code:
::DCS
:"...............................
:Ans
No, the Ans or rand is the very first token; because it's going to be hidden from Doors CSE, there's no point in putting an icon. Therefore the ::DCS and :"ICON are both omitted. See http://dcs.cemetech.net/index.php/BASIC_Header_%28Color%29#Ignore_Program .
I'm thinking of having at least 2 main programs, one for loading and the other for game play, and I don't want both programs or their copies to be in the RAM at the same time, so would I need a 3rd, smaller program in between the two programs?
FrozenFire49 wrote:
I'm thinking of having at least 2 main programs, one for loading and the other for game play, and I don't want both programs or their copies to be in the RAM at the same time, so would I need a 3rd, smaller program in between the two programs?
Yes, that small program would be like a "launcher" of sorts that copies one or the other program to RAM and runs it.
What an I doing wrong? It keeps giving me an undefined error.
Code:
"PVPGAME
det(11,0,2
prgmXTEMP002
And there's definitely a program named "PVPGAME" on your calculator? The undefined error is at prgmXTEMP002?
1. Yep (I remember manually changing the name from "c-PGAME" to "PVPGAME" on jsTIfied)
2. Correct

Also, when Doors opens a program, does it create temporary file "0"?
FrozenFire49 wrote:
1. Yep (I remember manually changing the name from "c-PGAME" to "PVPGAME" on jsTIfied)
2. Correct

Also, when Doors opens a program, does it create temporary file "0"?
(1) We've solved that from the SourceCoder 3 end.
(2) No, Doors CSE/CS do not create a temporary file "0".
How would I clean up all temporary programs if it runs on temporary programs the entire time (det(11,2 would cause the program to delete itself). Would I have to open up a non-temporary program in RAM to delete the other files? Then how would I re-archive that program?
Bump on the above.


How should I deal with random memory errors? I say they're random because the errors occur randomly across the entire code. Should I try to make the program and lists smaller, or is there a better way to solve this?
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 2
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement