What's Up, Nick?

A blog for ongoing projects both professional and personal.

19th August 2018 4:11 pm

Machine Learning on a Commodore64 (part 1)

The Future In The Past

Recently I downloaded an Emulator for the Commodore 64 and was also reminded of the fact that anachronisms are funny. This is why, when trying to think of projects to tackle with this old thing, I thought it’d be fun to see how far I could take Machine Learning on the ol’ 6510 Processor.

I, myself, own a VIC-20. I haven’t brought it out of its box for a long while, having been distracted by other things, so my BASIC is a little rusty. So, what better way to start this project than to try and implement one of the more simple learning machines, the Perceptron. Old methods for old machines.

Nic and the Vic

Should this work, I’d like to see just how far I can go. I’m doubtful I’ll be able to go much further without breaking into C64 Machine Code (which I may very well do). My ultimate goal is to have this running on my Vic-20, so for now this is just a proof of concept, sorta. As in, if the C64 can’t do it, the poor Vic sure can’t.

This first version of this will be simple, manually inputting training values with expected output. The skeleton roadmap is as follows:

Code 01

Here, I’m doing an easy version of the perceptron. No input_0 & weight_0, I’m opting for a regular bias. Also, I decided to keep the learning rate at 1 so I’m not including it in the math.

The hiccup here is “what format does data come in”? Well, again, for simplicity I’ll probably keep it as a string of 1s and 0s and it’ll be binary classification. With a string, we can break it into a list of chars and do a VAL(X$) on each to get their numeric value. For each one. It’s sloppy, but it should get the job done.

As for reconnecting with Commodore BASIC, most videos were a little slow paced, feeling first the need to explain “no there isn’t a mouse” and “no you can’t get Windows on C64” before explaining and re-explaining the history of the processor. Thankfully, I’m able to kick it like it’s the early 80s and read from the user’s manual quick reference for the C64 (an online scan, of course).

For my first hack at it, I wrote this out:

Code 01

Again, my BASIC V2 is really rusty so I’m probably missing something here. There’s a lot of string to real conversion knocking about in this code which makes me nervous. That was the easiest way to break apart a string of 1s and 0s. I’d do a little magic with mod10, but if the string began with a 0 I’m worried it’d be lost (ie 0101 becomes 101). Else it’d just halt the program. I’ll give it a try in the emulator when I have time tomorrow.

~Nicko

16th August 2018 4:18 am

Welcome to the Blog!

Heya!

This is Nicholas Casteen reporting in. This is my dumping ground for any and
everything I feel like sharing. From new additions to my retro collection to
progress reports on programming challenges I’ve taken, there’s a fair bit to
see here!

I’ve got a link to my github on the sidebar. Hopefully I’ll also have some
‘Github Project Progress’ thing there, too. This here blog’s nothing if not
a work in progress.

And, of course, if ever you want to learn more about the author or get in
contact, check the ‘About’ and ‘Contact Me’ pages up in the top!

S’all for now,
Nicko

My Github!

Recent Projects: