Well, my social studies teacher (Mr. Weidman) gave us the following, open ended speech: "For extra credit, talk to me about any idea you have," so I asked about programming a simulation. So, now I have two weeks to beat out something that works. And I credit in Health for it too (long story). So, in pure 68k TI-Basic, a war simulator is about to be built.
Hey, good idea.
I myself did an assignment through my calculator program, and I think that it is what bought me the full marks I got! It was SOSE and the topic was all about money in the world (start of year 9, by the way, so two years ago). A lot of people did a remake of Monopoly, but I went further and integrated an Automatic Teller Machine into my remake of Monopoly, including each user having their own password, Cheque, Savings and Credit accounts. With the Cheque account, you would get a unique cheque code to write on a cheque, you would give the person a cheque, and for them to claim the money, they would log into their account, click on "Deposit Cheque", they would need to type in the unique cheque code and the money would go into their bank account, after confirming that the person indeed gave them the right ammount (in which case if s/he didn't, you would return the cheque). You also had a limit of $500 from the cheque account, and a dollar would be taken from one of your accounts each time you log in (from Savings, unless there is no money, then Cheque, unless there is no money, or Credit, unless you are out of credit, in which you are refused banking privelages).
Anyway, it was the best game in the class, and it was the only one with full marks. So I reckon that if you do the assignment, you are as good as gold with marks.
Cheers ~ James Kanjo
Yeah, I'm working on beating out the plan for the flow right now then onto pictures so my brain doesn't go boom. Working to long on that screen can do that.
Assuming you mean the tiny calculator screen, I can totally understand ;) ! That little thing is just so small, and dark!
Do you have any ideas of how ur going to create the program? If not, here are some right now:
-Use randInt(<IDK>,<IDK> and then assign each number a purpose, such as attack, buy weapons, retreat, etc..
-Make a cashflow income per enemies destroyed
-Make territories to fight at
BTW, that's the coolest asignment evr…
Well, this is a simulation, not a game. The idea is that the user can enter some variables (such as no. of planes, tanks, whatnot) or let the calculator do it randomly. It would move the soldiers around (each having a range of 25 or so pixels, depending) and then have shots fired, and lethal shots remove soldiers, and non-lethal ones/misses don't (duh). I'm thinking of getting my teacher to install an emulator on his computer so we can have the calculator screen blown up 50 times onto his widescreen TV.
When the program is done, I'll post it on BlackCat Software (blackcatsoft.wikkidot.com)
And I definitely agree it is cool… Although coolest may go to my tech teacher, who tells us "Make anything. I'll grade it." This is in the robotics unit. So I get to build any robot I like. </off-topic>
That's awesome! Man, if I ever got that assignment…Oh, and by the way, is it also for health because of like bacteria invasion?
So far, so good.
Status update (Because I can!)
Pictures all work, and lists do too. Working on routine to get rid of soldiers. Each unit has health in the list, and each not dead unit (Units w/ more than 0 health) can attack once. This should simulate both the enemy being overrun by the huge amounts of Germans, and give a chance for enough misses that the defender could win.
Setup is quicker than expected, which always rocks.
Stay tuned for the next update, who knows when.
- randNorm(X,S) will give you a random number that's centered on X, but can vary from there in either direction (how much it varies scales with S). Good for a situation in which, say, X soldiers should make X/2 attacks on average. Plus, you can use S to vary the randomness of the battle (higher S means "more random").
- randBin(N,P) would model the situation in which each of N soldiers has a P chance of making an attack. Which is probably a good model, but for large N, randBin( becomes two things: slow and approximately equal to the much faster randNorm(.
Do the randNorm( and randBin( commands work the same way on the 68k calculators as they do on the TI-83 calculators?
Would the number generated always be whole, or would I have to set the rounding?
Both of them give floating-point results (even randBin(), which returns whole numbers).
OK, that's good.
Also, I've been fussing with a routine to check each element of a list until it comes to one that isn't zero. It so far looks something like this:
1->y NewList(a,5) For x,1,5 1->a[x] EndFor Loop If sum(a)≠0 Then While a[y]=0 y+1->y EndWhile If sum(a)=0 Exit a[y]-1->a[y] EndLoop
But that returned an error. Unfortunatley, I lost the original code while at school, and so I can't remember the exact error, but it was something along the lines of "Missing Start or End of Block Syntax," though I got it to a point where it looped endlessly without doing anything.
Well, the obvious error with that is that you have If - Then without a matching EndIf. Try this:
Define firstnz(a)=Func Local i For i,1,dim(a) If a[i]≠0 Return i EndFor 0 © or other value that indicates "no nonzero elements found" EndFunc
Thanks! That makes it easier. I'll test it later - I don't feel like getting my calc right now :D.
EDIT: Is the Local i necessary? I thought all variables used in functions were local by default.
EDIT 2: Also, another question: Is there a way other than a For loop to fill a list with a constant variable?
First question: the Local is necessary. All variables in functions must be local, but aren't automatically defined that way.
Second question: if you already have a list variable, use the Fill command (e.g. Fill 5,list). If you want to create such a list, you can also do a+newList(b) to create a list filled with a of b elements.
The last technique does work for nonnumerical lists, since 0+"a" equals "a".
Erm, by the way, how exactly are you going to present this simulation? Like, are you just showing him, or like the whole class? Good luck if you have to present it to everyone…=p
If you do have to show it to everyone, you could borrow the teacher edition TI-83+ from a math teacher (if they have one). Those can be shown on an overhead.
I think (if you were not already thinking it) it would pay to have a storyline, maybe some history in it, and then the animation of a scene in history. For example, a screen displays some writing saying "in the year X, Hitler did blah, there were Y many soldiers who slaughtered Z number of innocent civilians…" instead of just a scene with people shooting people. Perhaps you can implement scale feature of the number of people, so say if there were 1000 civilians and 300 soldiers, there would be a screen just before the animation saying "Enter amount of civilians" and "Enter amount of soldiers", but in real life terms, and then have an algorithm under the bonnet that would reduce the number by a certain scale into the animation (1 person represents 100). You could also show statistics at the end of each level, saying something like "of the 1000 innocent civilians, only 239 survived, zero soldiers died", another history thing.
I think your assignment would be more interesting (more impressive, more marks) that way rather than just a screen asking "how many civilians", "how many soldiers" and "SCREEN OF PEOPLE KILLING PEOPLE" and "SIMULATION MADE BY SOCKS". It would also show your knowledge on the subject (which is the key purpose of extra credit), your interpretation of it, and your understanding (how you tell somebody who knows nothing about the subject and make them have an understanding, someone like me =D).
Don't you dare forget to post us your final product.
Cheers ~ James Kanjo
The idea of the project is to show how the Germans used large numbers of troops attacking a small number quickly to destroy them. We've got a pretty good understanding of WWII at this point.
The program is for my TI-89 Titanium, so I can't exactly port it to the TI-83, but I was thinking an emulator. I'm still hashing out the main loop, once that's done, I can add the extra stuff pretty easily.
Also, blitzkrieg wasn't used on civilians, it was used to destroy the enemy military before it could respond.
I could post what I've got right no, but that isn't much, and it doesn't quite work right yet, so I'll see about finishing it up, then posting it.
I'm creating a page on it on BlackCat Software, so you can check for updates there. I'll also post them here, when I get around to it.
I've come to a problem: This code doesn't work, and I'm not sure why. It doesn't give me an error, but after execution it looks like this:
gshot() Prgm if firstnz(dsh)≠0 then If firstnz(gsh)≠0 Then rand(20)->x If x≤5 Then dsh[firstnz9dsh0]-1->dsh[firstnz(dsh)] EndIf EndIf EndIf EndPrgm
The variables in the program:
Also, the program code given is after tokenization - all capitalization is the same in the program.
And, firstnz() is defined as:
firstnz(a) Func Local i For 1i,1,dim(a) If a[i]≠0 Return i EndFor 0 EndFunc
So, that should be everything. Can anybody see something I missed?
Well, it looks like you've made a few typos in posting the code, but apart from that it looks like it should work.
One minor point: if I were you, I'd store firstnz(dsh) to a variable before running that code. As it is, firstnz() is called three times on the same list, potentially going through most of the list each time. Knowing the value of this variable might also give us a clue to this problem.
I checked everything - the code is as it appears on the calculator, including the If statement that isn't tokenized. Any idea why it wasn't?
Also, the storage is a good idea.
EDIT: That worked! I'm not sure why, but it did. Maybe I was running dshot() instead of gshot() or something dumb like that.
I need help again - I'm running the final product (which works when I comment this code out), and it gives me a Domain Error for the following code:
For x,firstnz(dsh),dim(dsh) RclPic soldier, 78,4*x+60 EndFor
"soldier" is a 3x5 image.
Also, the code
For x,firstnz(gsh),dim(dsh) RclPic soldier,58,4*x=5 EndFor
So, it must be the pixel row coordinate (4*x+60), but I can't figure out why it won't work.
Keep in mind that the coordinates are (row, column).
Actually, I figured it out in school, I just mistyped a number.
The entire program works now, I'm so happy. All that's left is to allow for custom input.
It's done! I left out custom input due to a shortage of time, but that can be changed by changing the variable storages mentioned in the Readme