You can help CodeWalrus stay online by donating here. | New CodeWalrus | Old (dark mode) | Old (light) | Discord server

Your worst programming fails

b/PC, Mac & Vintage Computers Started by Dream of Omnimaga, February 17, 2015, 02:15:23 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

u/Yuki February 18, 2015, 01:07:44 AM
I think your worst nightmare would be variable collisions. That is, you decide to name a variable the same as another variable (maybe in a global-er scope) you forgot about. Sometimes it works because you no longer use the old variable (sometimes you'd actually want to do that), sometimes it just fails for apparently no reason. You rename it, woops it now magically works again.
u/Snektron February 18, 2015, 01:31:30 AM
Quote from: Juju on February 18, 2015, 01:07:44 AM
You rename it, woops it now magically works again.
Html is that you?
u/Adriweb February 18, 2015, 01:34:09 AM
Little things like writing '<' instead of '>' (or vice-versa), such that it breaks the whole project... (well, makes it do the opposite :P)

Here or here, I don't remember which, but it's the same thing, kinda.

For an OCR project, well, one is supposed to compare to known things and keep the best candidate every iteration, not the worst one....
It took a bit of time to debug... But oh boy did I facepalm.
u/Dream of Omnimaga February 18, 2015, 03:32:20 AM
Quote from: Juju on February 18, 2015, 01:07:44 AM
I think your worst nightmare would be variable collisions. That is, you decide to name a variable the same as another variable (maybe in a global-er scope) you forgot about. Sometimes it works because you no longer use the old variable (sometimes you'd actually want to do that), sometimes it just fails for apparently no reason. You rename it, woops it now magically works again.
Yeah that's why for complex programs I now write down what variables I have used so far or comment my code when possible. I had this happen sometimes to me.


EDIT: O.O

If R=1
Output(2,10,"Q
If R=2
Output(2,10,"*
If R=3
Output(2,10,"c
If R=4
Output(2,10,"x
If R=5
Output(2,10,"Z


Good thing I learned how to use the sub() command after making that game...
Last Edit: February 18, 2015, 07:10:56 AM by DJ Omnimaga
u/Travis February 19, 2015, 04:17:23 AM
Some stuff from my first TI-81 programs written in a notebook:


:Lbl A
[display a menu]
:Input θ
:If θ=1
:Goto A
:If θ=2
:Goto B
:If θ=3
:Goto C
[...]
:Lbl C
:0→H
:Goto A


And:


:Lbl B
[...]
:If M<1
:Goto 3
:Goto 4
:Lbl 3
:Disp "EMPTY FUEL TANK"
:Goto 5
:Lbl 4
:Disp M
:Lbl 5
[...]
:Goto B


Mmm, spaghetti.

From an 8-ball program:


:IPart(Rand*100)→R
:If R≥80
:Goto 1
:If R≥60
:Goto 2
[...]
:Lbl 1
:Disp "ASK AGAIN LATER"
:End
:Lbl 2
:Disp "YES, OF COURSE"
:End
[...]


Obviously could have gotten rid of all the End and eliminated Lbl/Goto altogether because each Disp is only one instruction. (The 81 didn't have If-Then so some Lbl/Goto were justified. But not here. :P)

Also, the notebook itself is sort of fail because I wrote one column of code per page, using only the left quarter of it and wasting the rest. And several programs had missing/wrong code, because of course I didn't bother double-checking that I copied them down correctly. Oops.

When I got the TI-82 and finally figured out the Goto memory leak, this was my first approach to working around it:


:For/While/Repeat/If-Then
[stuff]
:Goto A
:End
:Lbl B
[...]
:Lbl A
[more stuff]
:End
:Goto B


Hey, it worked. ;)
u/tr1p1ea February 19, 2015, 04:39:07 AM
Not finishing most of the projects that I started ... then losing all my info in a series of PC crashes.
u/Dream of Omnimaga February 19, 2015, 05:05:58 AM
tr1p1ea Well I really meant bad programming mistakes as in the code in this topic, but yeah I wish you had done backups of your stuff D: (especially since you lost stuff three times in 9 years). I have the issue of not finishing most of my projects as well since the last decade or so too, although in recent years when this happened I usually released what I had or even entire folders of projects.
Quote from: Travis on February 19, 2015, 04:17:23 AM
Some stuff from my first TI-81 programs written in a notebook:

To circumvent the lack of Then/Else/End limitation on the 81, I just used an extra sub-program :P
Last Edit: February 19, 2015, 05:25:26 AM by DJ Omnimaga
u/Travis February 19, 2015, 10:13:03 AM
Quote from: DJ Omnimaga on February 19, 2015, 05:05:58 AMTo circumvent the lack of Then/Else/End limitation on the 81, I just used an extra sub-program :P

Haha yeah, I tended to shy away from that because it didn't feel right cluttering up my programs list with programs that wouldn't be useful to run on their own. On the 82/85 I eventually started using subprograms but started their names with Greek letters so they would stay at the end of the list and out of the way.
u/Dream of Omnimaga February 19, 2015, 05:00:09 PM
I had no choice to use them because 2400 bytes of user RAM is just barely enough to store an RPG. O.O (unless maybe I decided to go with the Input command trick and made a point and click game?)
u/Dream of Omnimaga February 28, 2015, 04:32:10 AM
The return instruction at the end of this sub-program tops all of my programming fails >.<:

If R=108
randInt(1,2->theta
If R=1 or R=104
Goto 1
If R=2 or R=101
Then
If 1=randInt(1,2
Then
Return
Else
Goto 1
End
End
If R=3 or R=103 or R=105 or (R=108 and theta=1
Then
If 1=randInt(1,5
Then
Goto 2
Else
Goto 1
End
End
If R=4 or R=102
Then
If 1=randInt(1,3
Then
Goto 2
Else
Return
End
End
If R=5 or R=107 or (R=108 and theta=2
Then
If 1=randInt(1,5
Then
Goto 3
Else
Goto 1
End
End
Lbl 2
For(Z,0,40
Output(randInt(5,7),randInt(5,7),"W
End
ClrHome
9O->S
Goto D
Lbl 3
For(Z,0,50
Output(randInt(1,8),randInt(1,16),"theta
End
ClrHome
36O->S
Goto D
Lbl 1
ClrHome
prgmMFT
For(Z,6,9
Output(6,6,"/
For(Z,0,100
End
int((O/2)^^2->S
Goto D
Lbl D
If S>=9999
9999->S
B-S->B
For(Z,7,6,~1
Output(Z,5,S
For(theta,0,15
End
Output(Z,5,"   
prgmMFT
End
For(Z,5,7
Output(Z,5,S
For(theta,0,25
End
Output(Z,5,"   
prgmMFT
End
Return
u/aetios February 28, 2015, 07:35:18 PM
Needs more context really, I don't understand what the code does at all :P
u/Dream of Omnimaga February 28, 2015, 07:43:59 PM
Same :P, but more seriously this is the enemy attack code in Mana Force and First Fantasy: Mana Force.
u/Dream of Omnimaga March 24, 2015, 04:46:08 AM
Guess what this is:

{~1,0,1,0,~1,0,0,0,0,0,0,0,0,1->L5


Answer: This was used with Getkey for character movement. Element 1 and 3 were for getkey value 24 and 26 (left and right arrows) and -1 meant the character moved to the left while 1 meant it moved to the right. Element 5 and 14 were used for getkey values 25 and 34 (up and down arrow) Although some might consider this trick clever due to taking less space in the walking engine, I ended up wasting 90 bytes of RAM with 10 list elements that never were used and that I could have easily used for other things. It also makes the code hard to follow.
u/Snektron March 24, 2015, 03:23:41 PM
The least you can do is divide the key value by 2 :P
u/alexgt March 24, 2015, 11:55:14 PM
The worst fail that I remember happened today. I was bug squashing on Jarvis and I wonder why iit was not displaying text.... I was clearing that part of the screen in the next line of code <_< *sighs
Website statistics


MyCalcs | Ticalc.org | Cemetech | Omnimaga | TI-Basic Developer | MaxCoderz | TI-Story | Casiocalc.org | Casiopeia | The Museum of HP Calculators | HPCalc.org | CnCalc.org | Music 2000 Community | TI Education | Casio Education | HP Calcs | NumWorks | SwissMicros | Sharp Calculators
Powered by EzPortal