Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: meishe91 on September 18, 2010, 03:25:16 am

Title: Can't Figure Out Why This Doesn't Work :(
Post 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:

Code: [Select]
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*
Title: Re: Can't Figure Out Why This Doesn't Work :(
Post by: Builderboy on September 18, 2010, 04:19:16 am
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
Title: Re: Can't Figure Out Why This Doesn't Work :(
Post by: meishe91 on September 18, 2010, 04:25:58 am
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.
Title: Re: Can't Figure Out Why This Doesn't Work :(
Post by: Builderboy on September 18, 2010, 04:31:01 am
Hmmmm now that i think about it that might just work, clever!  Now to see why it doesnt work...
Title: Re: Can't Figure Out Why This Doesn't Work :(
Post by: meishe91 on September 18, 2010, 04:32:29 am
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.
Title: Re: Can't Figure Out Why This Doesn't Work :(
Post by: Builderboy on September 18, 2010, 04:35:19 am
What is IX=YZ for?
Title: Re: Can't Figure Out Why This Doesn't Work :(
Post by: meishe91 on September 18, 2010, 04:38:42 am
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.
Title: Re: Can't Figure Out Why This Doesn't Work :(
Post by: Builderboy on September 18, 2010, 04:40:47 am
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
Title: Re: Can't Figure Out Why This Doesn't Work :(
Post by: meishe91 on September 18, 2010, 04:44:33 am
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?
Title: Re: Can't Figure Out Why This Doesn't Work :(
Post by: Builderboy on September 18, 2010, 04:46:38 am
yep, you dont even need to make it a then statement :)
Title: Re: Can't Figure Out Why This Doesn't Work :(
Post by: meishe91 on September 18, 2010, 04:48:40 am
Woo! Thanks, that seemed to have worked :)
Title: Re: Can't Figure Out Why This Doesn't Work :(
Post by: Builderboy on September 18, 2010, 04:49:33 am
Yayy! Glad to have helped :)
Title: Re: Can't Figure Out Why This Doesn't Work :(
Post by: meishe91 on September 18, 2010, 04:53:41 am
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?
Title: Re: Can't Figure Out Why This Doesn't Work :(
Post by: Builderboy on September 18, 2010, 05:02:02 am
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.
Title: Re: Can't Figure Out Why This Doesn't Work :(
Post by: meishe91 on September 18, 2010, 05:04:27 am
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...
Title: Re: Can't Figure Out Why This Doesn't Work :(
Post by: DJ Omnimaga on September 18, 2010, 12:29:14 pm
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.
Title: Re: Can't Figure Out Why This Doesn't Work :(
Post by: meishe91 on September 18, 2010, 03:31:00 pm
Ya, we need someone who fully understands the glitch to explain it to everyone.
Title: Re: Can't Figure Out Why This Doesn't Work :(
Post by: Builderboy on September 18, 2010, 03:46:32 pm
Somebody somewhere fixed it so i imagine they know how it works :D Who was that again?
Title: Re: Can't Figure Out Why This Doesn't Work :(
Post by: FinaleTI on September 18, 2010, 04:00:05 pm
BrandonW did. http://ourl.ca/5923 (http://ourl.ca/5923)
Title: Re: Can't Figure Out Why This Doesn't Work :(
Post by: meishe91 on September 18, 2010, 04:10:23 pm
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
Title: Re: Can't Figure Out Why This Doesn't Work :(
Post by: DJ Omnimaga on September 18, 2010, 11:35:43 pm
It would probably not be very legal, though. I don't recall softwares that installs without the user permission being very legal
Title: Re: Can't Figure Out Why This Doesn't Work :(
Post by: meishe91 on September 18, 2010, 11:37:17 pm
I was just kidding :P
Title: Re: Can't Figure Out Why This Doesn't Work :(
Post by: DJ Omnimaga on September 18, 2010, 11:39:38 pm
Oh ok lol :P

I wonder if his patch conflicts with the OS 2.53MP xLIB patch?
Title: Re: Can't Figure Out Why This Doesn't Work :(
Post by: meishe91 on September 18, 2010, 11:56:58 pm
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.