Author Topic: Can't Figure Out Why This Doesn't Work :(  (Read 6042 times)

0 Members and 2 Guests are viewing this topic.

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Can't Figure Out Why This Doesn't Work :(
« 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*
« Last Edit: September 18, 2010, 04:00:15 am by meishe91 »
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Can't Figure Out Why This Doesn't Work :(
« Reply #1 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

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Can't Figure Out Why This Doesn't Work :(
« Reply #2 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.
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Can't Figure Out Why This Doesn't Work :(
« Reply #3 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...

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Can't Figure Out Why This Doesn't Work :(
« Reply #4 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.
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Can't Figure Out Why This Doesn't Work :(
« Reply #5 on: September 18, 2010, 04:35:19 am »
What is IX=YZ for?

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Can't Figure Out Why This Doesn't Work :(
« Reply #6 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.
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Can't Figure Out Why This Doesn't Work :(
« Reply #7 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

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Can't Figure Out Why This Doesn't Work :(
« Reply #8 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?
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Can't Figure Out Why This Doesn't Work :(
« Reply #9 on: September 18, 2010, 04:46:38 am »
yep, you dont even need to make it a then statement :)

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Can't Figure Out Why This Doesn't Work :(
« Reply #10 on: September 18, 2010, 04:48:40 am »
Woo! Thanks, that seemed to have worked :)
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Can't Figure Out Why This Doesn't Work :(
« Reply #11 on: September 18, 2010, 04:49:33 am »
Yayy! Glad to have helped :)

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Can't Figure Out Why This Doesn't Work :(
« Reply #12 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?
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Can't Figure Out Why This Doesn't Work :(
« Reply #13 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.

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Can't Figure Out Why This Doesn't Work :(
« Reply #14 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...
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)