Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Simple Routine not working?

Author
Message
Irojo
15
Years of Service
User Offline
Joined: 21st May 2008
Location: Eating toast.
Posted: 26th Jun 2010 03:36 Edited at: 26th Jun 2010 05:36
EDIT2: Found the solution. Here's all that I had to change to the code. I still don't know why it didn't work in the first place, but this small change fixed it. Good old "oldx,oldy" ^.^

EDIT: Everyone else as stumped as I am? :\
Hey guys, you probably thought me dead.

Well every once in a while, I pop on and do some dark basic coding ^.^ Anyhow, I'm working on a secret program ( ) but I'm not sure why this little script isn't working. I'm sure a single glance at it will make sense what I'm trying to do. I want it to create a range between 1-4 in x, and 1-4 in y. increasing both, decreasing both, increasing one, decreasing one. It's relatively simple... but for some reason it just isn't working. I have it creating a visual, that should help solve the problem.
Thanks.
-Irojo



Time is money. I just ripped you off.
LBFN
16
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 26th Jun 2010 17:49
Hi Irojo,

Code that looks like this



is easier for me to understand and follow. I normally will re-hash my code so that it does not include any of (the dreaded) GOTOS. GOTOS make it harder to find bugs and problems in your code IMO.

Good luck.


Irojo
15
Years of Service
User Offline
Joined: 21st May 2008
Location: Eating toast.
Posted: 26th Jun 2010 18:48
I don't understand the dread surrounding GOTOS. It goes from point a to point b. It doesn't go back. If it is a feature in the program to script with, then why cannot it not be used? At some points, it suits me better than a gosub.


Time is money. I just ripped you off.
LBFN
16
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 26th Jun 2010 20:17
It is my view that GOTOS tend to create code that is hard to debug. I specifically remember a pacman game that I programmed years ago using gotos. It was awful. I worked and worked to try to find errors until I finally just gave up trying. I re-wrote it from scratch using GOSUBs and it worked great. I was able to find and fix the bugs much more easily.

It's a personal preference whether or not you use GOTOs; I would encourage you to avoid them if at all possible. Your code will tend to be more structured without them. I cannot recall anyone ever stating that they regretted not using GOTOs once they learn to code using subroutines or functions.


Silverman
17
Years of Service
User Offline
Joined: 18th Jan 2007
Location: France
Posted: 26th Jun 2010 22:17 Edited at: 26th Jun 2010 22:19
Hi,

you can do without the command "goto"!



AMD Athlon(tm)XP 3200+ (2.2GHz) / DDR pc3200 (1024Mo) / Nvidia 6800GT (driver 178.24 WHQL)/ XP Pro SP3 / DirectX 9.0c (February 2010)/ DBClassic v1.13 / DBPro v7.4
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 27th Jun 2010 02:16
Here is one reason I have grown to dislike goto's:

They tend to make program loops hard to program, since you can't go back to the call. Remember: Each program should only ever have 1 main loop. Using things like SELECT and IF->Thens you can control which subroutine is called in the loop (thus changing what happens with each iteration), but there is only one DO-LOOP (in fact some advocate using NO DO-LOOP's since it doesn't have a built in exit condition, but that's kind of beside the point).

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 28th Jun 2010 18:40
Yeah, Gotos do suck. Makes it pretty hard to find you some bugs. but they do have there uses.

Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 2nd Aug 2010 08:30
What is this code for Irojo? It is peculiar.

Those conditions where you check that x and y are still within your 1-4 boundary are strange; once they are false (causing a reset) they will always be false until another position is selected that brings the x/y back into range.

Irojo
15
Years of Service
User Offline
Joined: 21st May 2008
Location: Eating toast.
Posted: 6th Aug 2010 03:23
Actually I gave up on the program a while ago, the concept was to create a program that could auto-solve boggle.
I created an equation that could take the x,y coordinates of something and convert it into which number that is. That last sentence doesn't make sense, so take a visual:

If you place boxes and label them in increasing numbers from 1-16, you will have:
[1][2][3][4]
[5][6][7][8]
[9][10][11]12]
[13][14][15][16]

Now imagine that the columns are 1-4, and labeled x. And the rows are 1-4, and labeled y:
___(1)(2)(3)(4)
(1) [1][2][3][4]
(2) [5][6][7][8]
(3) [9][10][11]12]
(4) [13][14][15][16]

I think that's going to be a bit confusing but you can figure it out.

So anyways,
if you plug x and y into this equation:
4(y-1)+x=number
then the number that comes out will be one of the numbers (1-16). The equation is essentially for grid calculating.
So, for example:
if x=3 and y=2
4((2)-1)+(3)=number
Do the math...
4(1)+3=number
7=number
and the number was 7.
So if you can have a program scan through by increasing x and y, it can quickly identify the letter and decide if it is unsatisfactory, if not, it can easily find other letters by returning to the original position. If you're interested to see what I have, I can post the code. It might make more sense that way, but currently it doesn't function properly. I think the concept is too laggy.

Finally, I planned on once the script followed scanning patterns, you could "Teach" it to learn new words. For example, it would find "bap" which is a letter vowel letter pattern. The most common type of word. It would also find, coincidentally, real words, such as "car", etc. You could save the real words to a file, and it could "learn" to find only real words. Theoretically you could type in the whole dictionary but where's the fun in that?

So that's the concept!


Time is money. I just ripped you off.

Login to post a reply

Server time is: 2024-03-28 09:24:17
Your offset time is: 2024-03-28 09:24:17