I love the way you explain things, you have a very good speed and intonation when speaking, which makes listening pleasant and not exhausting. Happy pi day!
The reason you needed to use parenthesis () around SPLITSCREEN is because it has optional parameters. You can use SPLITSCREEN by itself to change it from FULLSCREEN to having a text screen at the bottom. To set the number of textlines, you use the parenthesis. Another example is PRINT. You can print one thing with PRINT "Hello or print multiples things with (PRINT "Hello "World)
@@8_Bit You're welcome. The reason for the odd syntax is because LOGO is based off of LISP. In LISP the parenthesis are always required, but LOGO only needs them in cases like this.
When I see there is a video by the gesturing hand (aka Robin) I don't care what's the topic, I want to watch the video, and I always learn something new. But some people are weird enough to "dislike" no matter what. Go figure...
They're probably some losers who know nothing about the history of these machines that Robin explains so brilliantly. Even the news feeds in the UK picked-up on him taking the code of old records on my google feed.
@@G.B... I love the gesturing hand. It seems to be Robin's trademark. I do wish he'd show his face a little more, but I think the gesturing hand works for him. Also, the soft-spoken Canadian accent. See also: www.harkavagrant.com/index.php?id=250 img0.joyreactor.com/pics/post/funny-pictures-auto-comics-stereotype-366758.jpeg
Nicely done Robin. Man Logo takes me back. The extent of our “computer lessons” in school in the mid 80’s was being allocated 15mins at an Atari on a trolley hooked up to a TV with Logo running. Totally unguided. Hated logo as a result of sheer boredom after drawing some basic geometric shapes and eventually constructing a a crude house of a triangle roof, square building, square windows, rectangular door etc. The method in your video was intriguing. A modern take would be calculating Pi with a RayTracing API on a GPU 🤔
Logo and its derivatives being translated into the user's native language is a great educational feature. It taught me that it's a horrible idea and should never be done! I like the idea of drawing a point by "going forward 0 units". Reminds me of an anecdote about someone explaining the Paradox of Heaps to a programmer. If you remove sand from a heap grain-by-grain, at which point does it stop being a considered a "heap" of sand? The programmer answered: if you remove every grain of sand, it's now a heap of size zero.
Great stuff - this is exactly the sort of thing I used to do on my C64 in my teens 👍 I'd say your result was pretty good and you didn't have to eat Humble Pi 😁
I can't tell you how many times I ran a pi calculating program on my C64 and would leave it running for days.. The only one I can remember using was a Gregory-Leibniz formula I found in a book. (I had to look up the name of the series/formula.) It involved setting up just a simple FOR:NEXT series to add (and subtract) 4/1 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11 + 4/13... and so on. Mathematics and computers fascinated me. I had no idea why it worked.. it was just fun to do, to me anyway. According to google it takes about 500,000 iterations to start getting close.. but I had so much free time back then. 😀 Thanks for covering such an interesting subject.
I hated Logo when I was a kid, as I first learned BASIC, and made little, but functional, usable "real world" programs with it, then a bit later even started playing with Turbo Pascal on the early PC, writing small games and stuff, and then in school they forced me to waste time instead to "learn" programming with this "useless" language which had no real world use but education, plus most of our Logo stuff was written on paper, and we very rarely fired up a computer to even try it... Because "you must understand algorithms first!". How to make a class of kids hate programming for life. :) Of course, now it still sparks a bit of nostalgia. I might even try to get a copy of this Logo to play around on my C64.
@@bobbobbity463 Whatever was available as Turbo Pascal on the C64 I'm sure it wasn't Borland's Turbo Pascal. Also, I played around with several editions of "Turbo Pascal v1.2" available online, and all of them seems to be pretty much unusable and gives all sorts of weird error messages (like suddenly unable to save the edited file, etc). So yea. I'm going to pass on this one I guess.
I learned Logo in elementary school, and used it again in high school for computer and geometry classes. I can still hear the teacher yelling at me to "Stop abbreviating! We're not there yet!" But I forget the name of the golf game we used to play in between classes...along with 99% of the commands. Thanks for the trip(s) down memory lane! :)
HAH! I had exactly this issue in my LOGO class in High school. I already knew it and was taking it only because it was a prereq to take the Pascal class the following year. Teacher took points off an early quiz for "draw a square" where I used a repeat statement instead of doing multiple FD 40 RT 90. I argued for about 20 minutes "Does it draw a square? Yes. Then what's the problem?" and finally got the points back with the understanding "Try to stick to stuff we've learned in class." :-)
@@granitepenguin That pretty much sums up what's wrong with that method of teaching. I'm just glad I didn't have to subject my programming to teachings of school - it could've just managed to crush my interest. Nah, I doubt it; I would've learned at my own pace anyway.
LOGO is the only programming language I have ever used- we had it in school in the late 90s- early 00s.... sadly there wasn't much with computers going on at my school--- but there was a project week where we used LOGO to program "Fischer Technik" (don't know if that stuff is still a thing- it is basically Lego with electronics and an interface)
When I was playing early graphic/text adventures from the 1980s (Blade of Blackpool is one example) they would visibly draw each location procedurally from primitives, rather than just display a pre-rendered bitmap. I often wondered if they were using Logo to make those images! It was a neat way of compressing the graphics.
Logo on C64 was a big chunk of our computing class back in 1987 when I was in high school. I think we even had a little robot that would plot the commands to paper.
You made me remember about the time I tried to write a program in basic on my c64 as a 10 year old to print pi to thousands of digits. I didn't succeed.
I was a teen in the 80's. I had the C64 (used the most), Atari, RS Colour Computer, Timex Sinclair, TRS-80 II & II . . . Programmed in BASIC, C, machine code, etc . . . and never heard about LOGO until today! Always time to learn something new. :)
It's funny how so many don't know about it, while for many others it was their first or second computer language (after BASIC). It was one of those things you either learned at school or you didn't, and there wasn't a lot of opportunities to hear about it outside of school.
I remember using the Forth language which had the same environment by creating functions which became commands. Also using logo at the same time on my C128 while in sixth form to help the other children with challenging education needs.
Fun episode! I remember reading an article back in the day in Run Magazine (R. Holleran, "A High-Performance Turtle", Run Magazine, Issue 19, 1985) that introduced support for a set of turtle graphics commands in C64 Basic. It wasn't full Logo but the commands were (somewhat) useful and the program listing in the magazine was short. :) Great stuff!
@@8_Bit Yes, that's what I used. I remember being amazed how they were able to add new Basic commands for these kinds of graphics. I know I still have the disk somewhere with the View To A Kill demo.
This was brilliant, Robin! I never experienced LOGO as a language back in the day and this showed its potential. Would love to see how fast this was in writing some game-like programs as I also used 6502 assembly!
I think the short answer is Logo is faster than BASIC but still much slower than assembly :) I might do a video showing some of the other features it has.
Awesome, estimating π with Logo - and on C64. Normally, the Monte-Carlo method can find an accurate estimation (up to 7 decimal digits) in about 1000 iterations, but it heavily depends on the platform (precision of mathematical operations in real numbers, and random number generator used). In any case, increasing the number of iterations too much won't help - it only causes an "oscillation" of the estimation around the exact value (similar to what you are experiencing in the end of the video). Why the program is not able to stabilize in an estimation accurate to 7-decimals? My guess is we have to blame truncation errors first. I am not sure what's C64-Logo's precision in mathematical operations, but judging from the results I'd say it's probably less than "single precision". A poor random number generator could also contribute to the oscillation around the exact value, and it's easier to check; there are many random number generators, relatively easy to implement in any programming language, and it is worth trying to replace Logo's RND with such an "improved" generator.
LOGO's RANDOM function appears to return only integers, which will limit its precision. However, the sampling space used here is 2001 * 2001 = 4,004,001 points, so the precision available here should be at least five digits.
I wonder how many different random numbers the RNG in C64 Logo can generate? I mean, if it's only using a 16-bit integer seed (no idea if it does, just wondering) then that's only 65,536 possible different random values no matter how long you run the program.
BASIC on the C64 could only generate 256 random numbers. Probably the same thing here. Normally, you use the SID chip to generate random numbers. For LOGO, I would generate two random numbers from 0 to 255. Then do (A*256 + B). Then MOD it with the range you want (+1). This should give much better results. It'll still be biased, but you're not doing encryption, so should be good.
@@alienrenders That was only true if you used RND(0). If you used RND with any positive number then you got a much greater range of possible random numbers, although I don't know how much greater.
FYI, I tried this in perl on my linux machine. After about 2 billion calculations, it got to 3.1415... Yep, four decimal places. After two billion iterations. I also tried an "ordered" method, where I cut the square into a 32768x32768 matrix. That actually did worse. ^_^ P.S. I'd kill for Perl on the C64, or some subset of it. Basic line numbers (and other limitations) make me want to cry.
Here in South Africa we had a ripped off version developed by one of our universities and was used in schools. It was for PC's running DOS and the graphics was much better(monochrome though) , the turtle actually looked like one.We just drew pictures with it and didn't write any programs and even had a version that ran on Windows. C64 versions were not available since there weren't many of C64's around here , even in the 1980's, just boring old IBM PC's and their clones. Still had fun though and I was really good at it.
A nice version, though I prefer the default look of the Atari turtle (it actually looks like a turtle and not just a triangle). Around '87 I wrote a mini-game utilizing all four turtles, two of them controlled by joysticks (two players), the other two having 'AI' derived from the the inputs of each of the joysticks. It wasn't really fun to play, but definitely a 'let's do it' kind of a programming experience, memories of which I cherish. Anyway, LOGO was a nice little language to play with in the 80's, but sadly, almost no-one around me used it, or even knew about it. Here instead (I mean former Czechoslovakia), the ultra-popular KAREL was used, for educational purposes (not a bad educational language either). BTW there was one thing, that I always found hilarious - the default _almighty_ (LOL) Atari BASIC was shipped in an 8kB cartridge (there's quite some history in regards to Atari BASIC - today it's entertainment gold), while the LCSI LOGO (Atari LOGO) one utilized a 16kB one 😀
As a proud French Canadian, I can tell you that it is effectively rare that a programming language instructions are translated in French. To my taste, it is not wanted and brings many incompatibilities and transportability issues. In Quebec, the only other instance of that phenomenon that I know of is the macro language in MS-Office. Funny thing is that the macros are in French but the VBA instructions are in English. Further more, the translation is done when one convert's a macro in VBA but not the other way around. P.S. Keep on the great work. ;o)
Really fun idea! Never heard of Logo before. I would think that the RND procedure should use (SIZE * 2) rather than (SIZE * 2 + 1), as the width of the interval [-1000, 1000] is 2000, not 2001. Maybe that's why using a SIZE of 1000 ended up being more accurate than 100 (smaller relative error)? But then you're missing out on one edge of the square... Hmm...
Returning to school, I have stars to draw in logo and I didn't know where to start. But more important than that, the spigot pi will be very interresting for me to benchmark my various µP projects
Thanks for the great video. Really interesting. One thing I was thinking, the Random number generator will most probably come up with quite a few duplicate pixels, which will happen more often when the screen is filled halve with pixels, which will most probably skew the stats. I guess LOGO cannot tell if a particular pixel has already been drawn to and ignore that pixel for the stats.
We use Monte Carlo sampling method for calculating market risk for reports which must be submitted to financial oversight authorities. The sampling space is ten million samples and the initial model is constructed in the R programming language. Monte Carlo is a very important and common methodology in the financial industry. You might want to try the Kalman filter for computing Pi, too. Also I can see now why they say Logo resembles Lisp: it's almost a Lisp dialect.
It speeds up because the you're doing an approximation of pi by cutting a circle into smaller and smaller slices. As the slices get smaller, the calculation is faster.
Does Logo support colours? A simple improvement of the visualisation would be to have points inside the circle be green, points outside the circle be red.
@6:26 reminds me of when I had to maintain some source code to the NATAL language developed by Canada's National Research Council (NRC) and as such the code was bi-lingual and included French variable names, etc.
I did some contract work with a Montreal-based videogame company and even though it was against the standards, I'd find bits of French in the comments and occasionally variable names too.
Instead of picking 10000 random numbers, would it be faster and/or more accurate to just follow a square pattern (i.e., FORY=1TO100:FORX=1TO100:... [in basic terms])?
It should be more accurate to fill every co-ordinate like that, but it would also be slower. I'm using a 2001x2001 grid and choosing randomly from that, so that'd be just over 4 million locations. We could do every X locations (like in your BASIC example, FOR Y=1 TO 100 STEP 10) but that would reduce accuracy. The neat thing about the random/Monte Carlo method is how quickly it gets a rough estimate between 3 and 4 after even just 5 or 10 points, while doing the more brute force method doesn't give a useful answer until it's pretty much finished. Or maybe halfway through it would also be a good answer?
@@8_Bit Ok, getting a decent immediate answer makes sense for the random method. I'm still wondering if doing a "raster-style" calculation with the same number of points (i.e., 100x100 grid, instead of a random sampling of 10,000 from a much larger grid) would yield a more accurate result. Or just a more stable one (not randomized) ;) What do you think?
@@8_Bit: If you used a binary decomposition on an index into a space-filling curve, you could both quickly cover the breadth of the sample space and then slowly zoom in while maintaining a uniform coverage of the sample space - the best of both worlds. For example, the first sample of a quadtree-midpoint scheme with a range of 0 to 1 (for the upper-right quadrant of a circle) would be (0.5, 0.5) = inside → π=4, then (0.25, 0.25) = inside → π=4, (0.75, 0.25) = inside → π=4, (0.25, 0.75) =inside → π=4, (0.75, 0.75) = outside → π=3.2, (0.125, 0.125) = inside → π=3.333, … This scheme will converge to the real value from above, coming closest after every 2²ⁿ+1 tests.
Good eye! It scales everything on the y-axis by default, so while there's 320 true pixels across, there's about 260 "pixels" vertically. That scalar can be adjusted.
0:25 It's a horsie! 1:50 As a nerdy teenager, I memorized the first 50 digits of pi. The displayed result passes the sniff test. 3:22 Seems odd that Mathematics is considered an Arts Degree by some universities. Where I went, math is considered its own faculty and Computer Science to be a field of mathematics. 6:18 That is a bit odd. Most programming languages use English keywords, as a reflection of the environment in which they were developed, like most musical terms are Italian or ballet terms, French. 10:31 It seems a bit odd how they jam all of the statements together inside of a REPEAT structure that are normally put on separate lines. How do they know where one statement ends and the next begins? Is it based on recognizing keywords and procedure names? Do the root-level statements really need to be on separate lines? 11:00 I guess the leading ":" character prevents variable names from being confused with keyword/procedure names. 14:40 Does LOGO have string variables? I guess the apostrophe is still free if it does. 15:20 Does LOGO use only integers or does it have floating point? Your scaling factor would make the results more accurate if everything's an integer, but should have no effect if everything's floating point. 15:58 Does LOGO have the concept of functions (vs. procedures)? Would functions need to be enclosed in parentheses? Though, I don't know why SPLITSCREEN would be a function. 16:24 If LOGO doesn't have functions, then values need to be passed between procedures using global variables, which gives LOGO scalability problems like BASIC has: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-eabOVMxn8iw.html . 17:40 When I see things like this, it makes me wonder about off-by-one errors. RANDOM apparently gives a results of 0 … n-1. Are you modelling the pixels as little boxes or as a grid of points? I guess the latter, with the point axes labelled from -1000 to +1000, inclusive. So far, so good. I guess the RANDOM function returns only integer values, which creates your need for scaling the coordinates to get better precision. 18:12 The RANDOM(SIZE*2+1 = 2001) will produce a result from 0 to 2000, not 1999. 18:34 I take it they distinguish assignments from reading references to variables with the (") vs. the (:). 18:40 If :PX were a 16-bit integer, then 1000*1000 would exceed its capacity. 18:56 Shouldn't that be a '
Yes, the pi symbol might look more like a horse than the animals I suggested! re: 50 digits of pi, that's funny that's the same number Darren chose when writing his song. After spending so long recording, playing on, and mixing that song, I think I might even be able to sing back all 50. And yes, those characters are from the VIC-20 font! My friend Sam wrote a routine to plot the ROM pixels out with giant characters. And then I tediously synced the number changes up to the song. That Wisconsin arts degree in Math seemed weird to me too. Although I just stayed here in Thunder Bay for Computer Science, my education was heavily influenced by the University of Waterloo in many ways, from both high school teachers and university profs who were alumni of Waterloo, to the UW math and computer science contests. And I've been meaning to ask if a lot of Waterloo professors would call parenthesis "brackets" - I think that's where I got the habit which American viewers in particular often correct me about. LOGO does have string variables though I don't fully understand them. There's a whole bunch of aspects of the language I'll have to study more if I'm to make another video about it. LOGO seems to just automatically decide if the variable is an int, float, string, or list. The RANDOM primitive appears to return INTs. re: SPLITSCREEN, another commenter said that the parentheses are needed because SPLITSCREEN has *optional* parameters, and the parser doesn't know how to interpret it without the help of the (). Logo doesn't seem to have a >= or
@@8_Bit: Maybe it's just that 50 digits is feasible to memorize, while 100's a lot tougher. I never noticed anyone calling parentheses "brackets" when I was at UW, and I would have noticed that if they did. The other university I went to now has Computer Science as its own independent faculty. So LOGO does have 'float's. On second thought, that's obvious from the printout of its estimate for pi. Those values only seem to have six significant digits, suggesting that they use 32-bit floats, which is odd considering that 40-bit float routines are available in the BASIC ROM for free, and six digits would have been considered unsophisticated in the era of 8-digit calculators! Does LOGO have logical operators? You could use '< OR =' or 'NOT >'.
I wonder if that French LOGO translation is where Microsoft got inspired to use different names for Excel functions based on localisation which causes issues between versions with different languages.
An interesting though on the Pi calculation method.. wouldn't simply looping through and dropping a pin on each location available(or every 5th, 10th etc) produce a more accurate result once complete? shouldn't be too hard to code(or even modify your code)
(Joking about the typo) Given just how many unique and obscure things they made I wouldn't be surprised if CMD made a "SuperCPI" that only sped up trig functions on a C64 =P
when i heard turtle the first thing i thought was minecraft (theres a mod "computercraft" that adds turtles that can interact with the ingame world using lua, many of the language commands are added in too)
Speaking of LOGO, I had Delta Drawing when I was a kid. I never really got it when I was a kid, the manual just seemed confusing and I could already program in BASIC, why did I need this drawing program thing? I never even gave it a shot, but looking back it was pretty awesome.
Dear Robin, I'm experiencing a strange issue with Commodore Basic. I use UART from user port to Arduino, which controls lego robot with cheap servos. When i OPEN 5,2,0,CHR$(10), I can send with ?#5,"something". However if I have a variable declared before OPEN, the variable is lost after OPEN. Similarly, any variable declared after OPEN is also lost after CLOSE. Am I missing something? How can one transfer a variable to the user port????
Similarly if OPEN is reached with GOSUB, it looses where it was coming from too and can not do a RETURN after CLOSE and you get a return without gosub error. Very strange...
Yes, this is a dumb feature of Commodore BASIC that I only learned when I did the Information Society episode, as I was trying to write a C64 BASIC program to display the modem-encoded text. A CLR is performed when the RS-232 routines are initialized, because buffers are created in BASIC memory space when the file is opened and so memory gets re-organized. The only solution that I know of is to OPEN right at the beginning, and then only CLOSE at the very end. If you must keep some information, then I think it needs to be POKEd into memory (maybe at 49152 and on) and then PEEKed back into variables later.
8-Bit Show And Tell, Thnx for confirming my suspicions. I actually transferred all the variables back and forth with poke/peek around open-close ($C000) However it slows everthing even more so i was considering putting everything inside open-close. 👍👍
Ha. Manual is stamped "Chapleau Public Library". Boy that brings back memories of growing up in Northern Ontario and cottaging just down the road from Chapleau. **sigh** Simpler times. Hope that SuperCPU is a v2 😉.
Seems like I have a few items that came from Chapleau! Unfortunately, the SuperCPU is just a v1. Never did get a v2, but now I wish I had spent the $200 back then!
This "Monte Carlo method" is basically a form of Bayesian inference, so you are computing pi similarly to how your email client filters spam :) It will **eventually** produce the correct answer, but only after an extremely long time - and even then, just how accurate you'd be would be limited to how many points you can put in the square (basically how precise the "PX and "PY variables in your RND procedure are), and may be hampered by the specific implementation of real numbers used by Commodore Logo. ("omfgbunder2008" below in the comments asked whether making the circle bigger would help. I'm not an expert here, but my intuition tells me that it would, but only with the same precision of the points, and only if you run the program longer.) Also I did not know the SuperCPU could speed up the main 6502; I always assumed it was just a coprocessor o_O Now I have to learn more about this thing...
Thanks for the info! And yeah, the SuperCPU actually takes over the system bus so the C64's 6510 is idle; the 65816 in the SCPU is running the show. It's a fun thing to play with.
I didn't notice any static (audio I assume?) while editing but I definitely rushed the editing of this video to get it out on time, so it may have more glitches than normal. Normally I make 3 or 4 passes over a video, and I only did about 1.5 this time.
Here are a couple of my favorite interesting ways to calculate Pi: Buffon's needles: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-sJVivjuMfWA.html\ Elastic collisions: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-abv4Fz7oNr0.html
that Logo program is a bit confusing to look at because LOGO also exists as a PLC for modern industrial automation. and i worked with that. just google "LOGO Siemens" to see what i mean.
I don't know much about how it works internally, but I think it's parsed and tokenized when you hit CTRL+C to exit the editor, and then those tokens are interpreted when run. So it's faster (and takes less memory) than a purely interpreted language.
Compilers are more difficult to write than interpreters. I don't know much about C64 Logo, but the modern standard of Logo (UCBLogo) has features that would be difficult to implement in a compiled language.
I loved Logo back in the day with apple II's at school... still got a boxed copy and all the manuals for my Atari 800XL, as well as PILOT which i think also used turtle graphics
I almost used Pilot for this episode, but then found out that the C64 version I have only allows signed 16-bit integer variables. No floats would have made calculating Pi a pain!
7 of my videos so far have been at least partly assembler lessons or tutorials, and I do plan on making more. Here's a playlist of the ones so far: ru-vid.com/group/PLvW2ZMbxgP9z9Un4LXivII_D1Hh5gZ7r9
Hah! That's cool. I haven't seen Logo since the 80s, it was nice to get a flashback. :) One of my biggest regrets in computing by the way, is that I never bought a SuperCPU when they were still affordable. It's kinda surprising nobody has attempted a modern revamp of the idea. Or have they?
The fairly recent Turbo Chameleon V2 cartridge has an accelerator in it which is 6502-based instead of 65816 like the SuperCPU. Both approaches have their advantages. Watch out though, the TC will not work with a C128 at all, and may even damage it!
What the heck? My dad bought the Commodore Logo for 495 marks back in the day and it did come with both diskettes but the manual was maybe a fifth the thickness of those :(
Thanks, I'd like to eventually learn everything - it's been 36 years so far and I still don't know it all! :) I do have to prep for most episodes to get it back in my mind, but it's fun.
This algorithm can be made more accurate by not dropping -say-10000 points in the 2by2 square randomly, but by dropping 1 point each in a grid of 100by100 smaller .02by.02 squares. The first method has an error of order O(1/sqrt(N)) and the second O(1/N) if I am not mistaken, so double the number of digits accuracy!
I wrote this many years ago: double pi = 0; double mod = 1; for(int i = 1; i < 60000000; i+=2){ pi += mod / i; mod *= -1; } double pi2 = pi + (mod / 60000001); pi = (pi + pi2) * 2.0; System.out.println("Calculated: " + pi); System.out.println("Ground Truth: " + Math.PI); Can you figure out how this calculates pi so accurately? :) If you can't tell, this is doing psudeo-integration, the higher the number of steps, the precise pi is calculated, but the longer it takes. If i is limited to infinity in the loop, then the answer would be exactly pi, if solving it were possible that is.
Yes, HES or HesWare (they seemed to use two names?) made a Logo-like language called Turtle Graphics. I'm not sure if they changed aspects of it to "improve" it, or just to avoid licensing fees?
That's been a common comment this video! Originally the title was "Commodore Logo" but that would have been even more confusing. I guess I should add a "ya know, the language" to the title.