I don't think I ever seen a game specifically like this before. I like it that the movement for the user and the COM is fast. I could say you *could* make the COM faster, so that instead of `If C>1`, change it to `If C`, but it would make it too fast to the point where neither of you could attack each other. You could try Battlesquid's CEmu suggestion, to see if it works for the CE and CSE as well. There can be some optimizations in the code. Also, try making the code a little shorter, and the computer smarter to attack you. I get the idea of the `If randInt(0,1`, but I think you could make it better than that. Anyways, I got a college test tomorrow, so wish me luck!

I notice that a few logic optimizations could be made. Any "and" statements could be changed to multiplication, and "or" statements could be changed to addition; both of which are faster than the boolean logic.

randInt(0,1) can be rand<.5, since rand is faster than randInt. This also makes the probability a bit more clear. For example, randInt(0,3) corresponds to a 25% probability of a 0, or a 75% probability of success. This would be the same thing as rand<.75; See how the second one is more readable? Since rand is from 0 to 1, there is a 75% chance that it will be less than .75 or a 25% chance that it will be greater. We can also ignore less than or equal to, since it will never be exact to the tenths digit

```
If Y=B and randInt(0,1) and max(A={X-1,X+1
- could be -
If (Y=B)(rand<.5)*max(A={X-1,X+1
If A=Ans or X=A:Then
- could be -
If (A=Ans)+(X=A):Then
- or -
If sum(A={Ans,X:Then
Repeat E or max(K={45,21,105
- could be -
Repeat E+max(K={45,21,105
```

I actually got rid of the "X=A" part, since is currently serves no use.

Refer to:

`If A=Ans or X=A`

πΉππ _βππ«ππ£ππππ π

So I decided to actually copy the code from the .txt and try the game, but I was surprised that the com didn't move even though there was code for it to. Anyways, since I had free time I decided to try and fix it. Anyways, I looked at it and I was able to completely get rid of the labels (Good job on not having memory leaks in the original code, but labels still can be messy). I also made it so the computer movement speed and attack speed are adjustable. I made it so that the variables E, C, O, and N are not used at all, and I got it down to 550 bytes instead of 604. In addition, you had a bug where you couldn't attack unless the player was at the same spot as the com, and also where the com would never attack the player. I'll post the code when I get home from travelling, which should be in a day or two. In the meantime maybe you should try and fix those few bugs

Some of those "bugs" are actually typos in the code. I will fix these, so the game actually works. I have made a full version game, which I will soon upload the .8xp or .8xg file here. This current program is just a sample (demo) of the actuall game.

The released game is supposed to be 4,145 bytes with 358 lines of code. This will be in a GROUP file, containing the original sample program, and the full program.

πΉππ _βππ«ππ£ππππ π

Well, I'm willing to bet that those 4145 bytes have quite a few optimizations. Once the full version is released I might take a look at optimizing it

I'll try to release it today, since I could have access to TI-Connect CE

If I can find the darn USB…

πΉππ _βππ«ππ£ππππ π

Repeat E or max(K={45,21,105

- could be -

Repeat E+max(K={45,21,105

These are the same size and speed; no advantage to changing it. When adding 1s and 0s `or` and `+` are equally fast.

For all intents and purposes, yes they are the same. However, the logical `or` is slower due to how it functions, although it is negligibly slower in most cases. Here is how the code would function:

```
E or max(K={45,21,105 functions like this:
Check if E; put result it in "bit" 1
Check if max(K={45,21,105; put result in "bit" 2
If either "bit" is 1, return 1; else return 0;
E+max(K={45,21,105 functions like this:
Take the value of E and add it to max(K={45,21,105; store the result in "register" 1
If the value in register 1 is 0, return 0; else return 1;
```

Obviously that's not exactly how it functions, but its generally how the logic is implemented on a bit-wise level. Note also that some processors will skip checking further arguments to or as soon as it finds that one is true, but I don't believe any of the TI's do this. Now, when running 1, 10, or even 1000 comparisons there is a difference which is negligible. However, when I ran 10,000 checks in a for loop with the timer on a TI-84+SE emulated in WabbitEmu, the times were slightly different. Using `E or max(K={45,21,105` it took 106 seconds. When using `E+max(K={45,21,105` my test only took 103 seconds.

So yes, you are right. There is no **practical** difference. But there is still a difference. I will also make note that the larger the comparands, the slower addition becomes. Again though, the difference is almost nonexistent.

I am done with the .zip folder. It somehow took me almost a class period to complete. Man, time really flies.

πΉππ _βππ«ππ£ππππ π

The gameplay portion has a few optimizations, but I had a few things come up at work that greatly reduce the amount of time I have to optimize it. However, here is the code I came up with for the original demo you had uploaded. Its a bit shorter, and as I said earlier, contains no labels and is fairly adjustable as for com attack rate and movement rate.

```
ClrHome
Disp " P1:100-COM:100
100βH:AnsβP
4βY:2βX
randInt(2,8βB
15βA
Output(4,6,"Ready?
Pause
Output(4,6,"
DelVar E
Lbl 0
Repeat max({0,0,45}={P,H,K
Output(Y,X,"Ο
getKeyβK
Output(B,A,"*
rand
If Ans<.3:Then
Output(B,A,"
A-(A>X+1)+(A<X-1βA
B-(B>Y)+(B<YβB
Output(B,A,"*
End
If max(K={21,105,24,25,26,34:Then
Output(Y,X,"
max(2,min(15,X+(K=26)-(K=24βX
max(2,min(8,Y+(K=34)-(K=25βY
If (Y=B)(abs(X-A)=1)max(K={21,105:Then
Output(Y,X,"Ο
X+1-2(X>A)
Output(Y,Ans,"-
For(I,1,40:End
Output(Y,Ans,"
If max(A={Ans,X:Then
P-5βP
Output(1,13,"
Output(1,13,Ans
End
End
End
If (Y=B)(rand<.25)max(A={X-1,X+1:Then
Output(B,A,"*
A+1-2(A>X)
Output(B,Ans,"-
For(I,1,40:End
Output(B,Ans,"
Output(1,5,"
H-5βH
Output(1,5,Ans
End
End
ClrHome
Disp "You "+sub("LostWon!Tied",1+4(H>P)+8(H=P),4
Return
```

I would like to mention that there was a fair bit of optimization in the peicewise statements. You may have noticed I was able to get rid of N, and O simply by putting what sets N and O into what changes A and B.