|
Post by plus on Aug 22, 2023 17:01:59 GMT
Here is the kind of fun I miss at Basic Forums these days, all yak and no code Well I made some spaghetti code, I hope it's not too advanced for you all ;-)) 1 Print "Sauce": GoTo 22 2 Print "Sauce": GoTo 21 3 Print "Sauce": GoTo 20 4 Print "Spaghetti": GoTo 19 5 Print "Spaghetti": GoTo 18 6 Print "Sauce": GoTo 17 7 Print "Spaghetti": GoTo 16 8 Print "Sauce": GoTo 15 9 Print "Cheese": GoTo 14 10 Print "Sauce": GoTo 13 11 Print "Spaghetti": GoTo 12 12 Print "Sauce": End 13 Print "Cheese": GoTo 11 14 Print "Sauce": GoTo 10 15 Print "Spaghetti": GoTo 9 16 Print "Meatball": GoTo 8 17 Print "Cheese": GoTo 7 18 Print "Spaghetti": GoTo 6 19 Print "Meatball": GoTo 5 20 Print "Spaghetti": GoTo 4 21 Print "Sauce": GoTo 3 22 Print "Sauce": GoTo 2
After 23 the screen scrolls in another Basic so that's why I only went to 22 lines. The spaghetti maker was in different basic but the spaghetti works fine in JB! Actually it was a little tricky to use every line in program and took me awhile to come up with something that works for 22 lines or 1000's! b = b + ...
|
|
|
Post by xxgeek on Aug 22, 2023 18:18:46 GMT
3 Print "Sauce": GoTo 20 : 4 Print "Spaghetti": GoTo 19 : 5 Print "Spaghetti": GoTo 18 : 6 Print "Sauce": GoTo 17 : 7 Print "Spaghetti": GoTo 16 : 8 Print "Sauce": GoTo 15 : 9 Print "Cheese": GoTo 14 : 10 Print "Sauce": GoTo 13 : 11 Print "Spaghetti": GoTo 12 : 12 Print "Sauce": End : 13 Print "Cheese": GoTo 11 : 14 Print "Sauce": GoTo 10 : 15 Print "Spaghetti": GoTo 9 : 16 Print "Meatball": GoTo 8 : 17 Print "Cheese": GoTo 7 : 18 Print "Spaghetti": GoTo 6 : 19 Print "Meatball": GoTo 5 : 20 Print "Spaghetti": GoTo 4 : 21 Print "Sauce": GoTo 3 : 22 Print "Sauce": GoTo 2 Too many Spaghetti code noodles. How about 1 noodle? You ok plus? Should we call your doctor about now?
|
|
|
Post by plus on Aug 22, 2023 20:32:51 GMT
xxgeekCurious that code works because it has a goto 2 and you have no line 2 Also curious it works with all those line numbers after colons on same line. Also curious you start at line 3. So you are missing allot of sauce, maybe you are on a diet b = b + ...
|
|
|
Post by tsh73 on Aug 22, 2023 21:31:24 GMT
Oh guys Looking first code, I got an impression of something with very many legs Both cute and ugly (may be dangerous) Like this But second code really hurts my brain So we can GOTO within a single line of code in JB? And I just checked, [symbolicLabels] works too? Let me un-seen this...
|
|
|
Post by plus on Aug 22, 2023 22:21:22 GMT
Spaghetti Maker 2.bas no longer uses a pattern of GoTo's with new and improved tracker of random pick line numbers: Here is one sample of a 50 line program, no line is skipped for spaghetti dinner of 50 bites:
1 Print "Spaghetti": GoTo 32 2 Print "Spaghetti": GoTo 5 3 Print "Cheese": GoTo 4 4 Print "Spaghetti": GoTo 45 5 Print "Cheese": GoTo 10 6 Print "Sauce": GoTo 44 7 Print "Cheese": End 8 Print "Spaghetti": GoTo 26 9 Print "Cheese": GoTo 43 10 Print "Sauce": GoTo 39 11 Print "Sauce": GoTo 2 12 Print "Meatball": GoTo 13 13 Print "Spaghetti": GoTo 14 14 Print "Sauce": GoTo 50 15 Print "Sauce": GoTo 46 16 Print "Sauce": GoTo 17 17 Print "Spaghetti": GoTo 37 18 Print "Sauce": GoTo 27 19 Print "Spaghetti": GoTo 24 20 Print "Sauce": GoTo 30 21 Print "Spaghetti": GoTo 20 22 Print "Cheese": GoTo 6 23 Print "Cheese": GoTo 34 24 Print "Spaghetti": GoTo 9 25 Print "Spaghetti": GoTo 16 26 Print "Spaghetti": GoTo 33 27 Print "Sauce": GoTo 42 28 Print "Spaghetti": GoTo 25 29 Print "Sauce": GoTo 22 30 Print "Sauce": GoTo 7 31 Print "Meatball": GoTo 36 32 Print "Spaghetti": GoTo 23 33 Print "Sauce": GoTo 28 34 Print "Spaghetti": GoTo 40 35 Print "Cheese": GoTo 48 36 Print "Sauce": GoTo 47 37 Print "Spaghetti": GoTo 35 38 Print "Spaghetti": GoTo 49 39 Print "Cheese": GoTo 19 40 Print "Spaghetti": GoTo 15 41 Print "Sauce": GoTo 3 42 Print "Sauce": GoTo 29 43 Print "Sauce": GoTo 38 44 Print "Meatball": GoTo 21 45 Print "Meatball": GoTo 31 46 Print "Cheese": GoTo 8 47 Print "Spaghetti": GoTo 18 48 Print "Sauce": GoTo 12 49 Print "Sauce": GoTo 41 50 Print "Spaghetti": GoTo 11 b = b + ...
|
|
|
Post by xxgeek on Aug 23, 2023 0:10:34 GMT
We need some new commands for JB Too many goto's not enough comebackfroms
You might be surprized at how much you can put on one line. I've written entire programs on 1 line just for fun. There will be some things that force to code a new line, I forget exactly all of them. Probably subs/Functions won't work if they are on same line.
When you put the last code together plus, did you have to be sure not to end up in a forever loop?
|
|
|
Post by plus on Aug 23, 2023 0:56:01 GMT
Yes absolutely! It is very easy to make smaller cycles through 5, 10, 15 lines of code and loop forever on same set of lines. Just pick a series of random numbers even without duplicates (like a card deck shuffle) you still are far more likely to double back in an endless loop than get through the entire deck after a shuffle eg say you goto the same line you are on, there's the shortest infinite loop. Are you familiar with the 100 Prisoners Problem? rosettacode.org/wiki/100_prisonersThere is a small but not nothing change that the 100 Prisoners can be set free, totally anti-intuitive you would think it impossible. It depends on how small the biggest cycle is going from one goto line to next. In the 100 prisoners problem it is possible everyone is in a 50 person or less cycle. What I am doing in Spaghetti Making code is cycling through all 100 Prisoners = Code Lines without repeating a code line. BTW I seem to recall IF statements could not be doubled up on one line. b = b + ...
|
|
|
Post by tsh73 on Aug 23, 2023 7:51:49 GMT
I seem to recall IF statements could not be doubled up on one line. It is sure can be, and it even works
for x = 0 to 1 for y = 0 to 1 print x;y;" "; print "always ";:if x then print 1 else if y then print 2 else print 3: print "after" next next
But you cannot continue that line: anything to the end of line will be either IF part or ELSE part AND JB does not let me insert label after IF/ELSE so I can jump there. So theer is no way to make (print "after" ) execute always while on a single line.
ah
it "kind of" works, sometimes first, as is, "after" printed for ELSE X - 2 times (I expect it to print in ELSE Y, 1 time)
00 always 3 after3 01 always 2 after3 10 always 1 11 always 1
second, JB does not *always* let add more statements via (:)
Somehow I can do
print "always ";:if x then print 1: print "after1" else if y then print 2 else print 3: print "after3" but cannot
print "always ";:if x then print 1: print "after1" else if y then print 2: print "after2" else print 3: print "after3"
I would say it's a bug / or nesting of single-line IFs not officially supported. In another BASIC it works, and I got results I expect
00 always 3 after3 01 always 2 after2 10 always 1 after1 11 always 1 after1
|
|
|
Post by plus on Aug 23, 2023 12:53:18 GMT
JB is full of surprises!
Here are the ABC's the hard way ;-))
1 Print "A";: GoTo 3 2 Print "T";: GoTo 7 3 Print "B";: GoTo 5 4 Print "W";: GoTo 26 5 Print "C";: GoTo 19 6 Print "Q";: GoTo 9 7 Print "U";: GoTo 17 8 Print "J";: GoTo 24 9 Print "R";: GoTo 10 10 Print "S";: GoTo 2 11 Print "M";: GoTo 25 12 Print "O";: GoTo 13 13 Print "P";: GoTo 6 14 Print "H";: GoTo 16 15 Print "F";: GoTo 23 16 Print "I";: GoTo 8 17 Print "V";: GoTo 4 18 Print "Z";: End 19 Print "D";: GoTo 20 20 Print "E";: GoTo 15 21 Print "L";: GoTo 11 22 Print "Y";: GoTo 18 23 Print "G";: GoTo 14 24 Print "K";: GoTo 21 25 Print "N";: GoTo 12 26 Print "X";: GoTo 22
b = b + ...
|
|
|
Post by xxgeek on Aug 24, 2023 1:21:28 GMT
Once I have my JB Studio running like a swiss watch I'll be joining you guys with some graphics code. I need to get up to speed with all the graphic commands, the recent work with FFUL by Rod got me started a little. There was a time when I had the top marks in my grade 12 Trigonometry class. Now? > What's trig lol But back then(1982'ish) I had my RadioShack TRS-80 Color Computer and did some graphics. I give 'getting back on the bicycle' a try. Iknow Iknow. Too much talking, not enough code.
|
|
|
Post by plus on Aug 24, 2023 21:16:54 GMT
That'd be great! I look forward...
BTW Trig in code seems like a completely different animal than Trig learned from HS, IMO.
b = b + ...
|
|