Omnimaga
Calculator Community => TI Calculators => TI-BASIC => Topic started by: meishe91 on September 18, 2010, 03:25:16 am
-
I have been going over this code for like an hour and I can't figure out why it doesn't work properly :( I feel like the problem is something really dumb and simple but can't figure out what the issue is. To me it looks like it should work...but doesn't. Anywho, I'm rambling now...on to the code:
Prompt H,W,M
0→A
DelVar [A]
{H,W}→dim([A])
Repeat A=M-1
randInt(1,W)→X
randInt(1,H)→I
If [A](I,X)≠9
Then
For(Y,I-(I>1),I+(I<H)
For(Z,X-(X>1),X+(X<W)
If [A](Y,Z)=9 or IX=YZ \\I've tried all three Boolean Operations.
Then
9→[A](Y,Z)
Else
[A](Y,Z)+1→[A](Y,Z)
End
End
End
A+1→A
End
End
I realize it isn't optimized. I just am trying to get it working first.
I've tried almost everything I can think of but can't seem to track where the issue is :( Thanks everyone :)
Edit:
Guess it might help if I tell you actually what it is supposed to do :P
It is supposed to make a matrix that has nines as a center point with numbers surrounding it with no number value going above nine. Also, the number that surround the nines should equal the number of nines it is touching. *coughcough*
-
I take it this is for minesweeper? Try populating the matrix with a number of 9's in one step, then adding in the numbers in a different step. It will be a lot faster and i think it might eliminate some of your problems
-
Ya, I'm gonna make a homescreen one. I figured this way would be faster because each time a nine is placed down it is supposed to make the spots around it increase by one, unless that space is a nine. If I did it the other way wouldn't I have to fill it then scan the whole thing and fill them in as it goes? Which I'd have to check all the points for nines for each spot. Unless there is a simpler way.
-
Hmmmm now that i think about it that might just work, clever! Now to see why it doesnt work...
-
Thanks :) I thought it was the boolean operation that was causing the problem but could never seem to get it to work. Though I still feel the problem is something really simple or a dumb mistake.
-
What is IX=YZ for?
-
Well (X,I) is the coordinate of the center point and (Z,Y) is the double For( loop coordinate. So it's supposed to be the part that skips the center point. I might be going about that the wrong way though, I just have gotten that to work in other programs so thought it would work here too.
-
hmmm well that wouldn't really work all the time though, for instance if one coordinate was (1,2) and the other was (2,1). Wyy not just once you determine the coordinate for the new mine to be placed, put a 9 there before you even enter the loop, that way it will automatically skip it anyways
-
Wow, I must be tired. I knew something would be wrong with that earlier but couldn't figure it out...Thanks.
So what your saying is once coordinates are decided just put the nine there. Then for inside the loop just have a If [A](Y,Z)≠9 statement?
-
yep, you dont even need to make it a then statement :)
-
Woo! Thanks, that seemed to have worked :)
-
Yayy! Glad to have helped :)
-
Just one more quick question. Since the If statement is false (I believe?) is it the both For(s that I need to close the parentheses on or just the second one? Or am I completely misunderstanding that glitch?
-
huh you know that is an excellent question and i really don't know. Your best bet is probably to close them both just to be sure.
-
Ya, I hate that for the most part I can understand most of TIBD but the explanation of that glitch is so odd. If only TI could do something right...
-
Good question indeed. I never really thought about that one. I guess it might be best to close both, though, because in some rare occasions or program, the slow down continues during the entire duration of the program afterward. In my case, in Illusiat 13, after you unlock the Holy Sanctuary with the 4 keys the entire game slowed down by about half the normal speed all of a suddent. Closing the For() loop parhentesises in there fixed the problem. The slow down, otherwise, would only end when exiting the game.
-
Ya, we need someone who fully understands the glitch to explain it to everyone.
-
Somebody somewhere fixed it so i imagine they know how it works :D Who was that again?
-
BrandonW did. http://ourl.ca/5923 (http://ourl.ca/5923)
-
Ya, I remember that. I really wish somehow that was like a calculator virus and traveled automatically between calculators, would make this much easier :P
-
It would probably not be very legal, though. I don't recall softwares that installs without the user permission being very legal
-
I was just kidding :P
-
Oh ok lol :P
I wonder if his patch conflicts with the OS 2.53MP xLIB patch?
-
Well if I remember correctly he made both around the same time. So I feel like he would've adjusted them or they just don't conflict at all.