Nature Of Code: converted to OF here

As a way to learn OF (and also more general concepts) I’ve gone through Daniel Shiffman’s excellent book “Nature Of Code”, converting it all from Processing to OF. I’ve uploaded the results in case they’re useful to anyone else … might put them on github at some stage when I have time if there’s any interest, but for now it’s just a zip file with all the projects. A few notes:

  • I’m also new to C++, so bear in mind these aren’t necessary examples of the best way to do things. But they work, and I have tried to use best practice to the best of my knowledge. Earlier projects are mostly a simple syntax conversion, some of the later ones get into more fundamental differences between the languages.
  • Pretty much all of the examples from the book are here, not that many of the exercises at this stage. Sometimes when an example is built on directly in the next one, I won’t have included the first one because I just carried on while working. But anyway all of the code you need for the first will be there. And a few of them I may have carried on experimenting with, so will have some superfluous stuff.
  • It’s not very well commented.
  • I’ve deleted all the bin directories to make it a manageable file size. So probably the best way to use it is just to create new projects and copy in the source.

http://clem.tv/files/NatureOfCodeOF.zip

Edit - github repository here: https://github.com/superartificial/Nature-Of-Code-Open-Frameworks-Port

8 Likes

Definitely I will check this for my students!! Thanks a lot. Great contribution to the OF community. I used to cover the Processing Nature of Code from Daniel Shiffman in my classes

1 Like

@superartificial thanks!
Also inspired by the Nature of Code by Shiffman, there is this course https://github.com/bschorr/OFAnimation_Spring2015

1 Like

Hope it’s useful! Some of it might be a bit rough and ready at this stage, I’m hoping to get time to come back to it at some point and tidy up and comment the code a bit, and maybe write a few tutorial notes on areas where the conversion to C++ isn’t quite so straight forward.

thanks, hadn’t come across that & it looks really good!

Hi there!

You may consider opening a github repository. It’s easier to share and people could build it up.

3 Likes

That does make sense … here it is: https://github.com/superartificial/Nature-Of-Code-Open-Frameworks-Port

Thanks! I’ll definitely check it out!

looks great.
i pulled a copy and added the OS X project files.

most of these examples ran on OS X 10.10 with OF 0.8.4.
but everything that contains #include did not compile.
also these examples did not have any visual output.
NOC8_9__Simple_L_system_sent
NOC9_1__Genetic_algorithm__Evo
NOC10_3__Neural_network_diagr

1 Like

Hmmm not sure I’m understanding what you mean about the ones with #include not working - is that all of the ones that have separate class files (which would be a lot of them)? It’s probably just a matter of making sure everything is in the right place in the project.

NOC8_9__Simple_L_system_sent & NOC9_1__Genetic_algorithm__Evo actually don’t have any output in the main window, I should have included a comment about that. They’re just conceptual exercises which output in the console, but could easily be extended to produce visual output. The L system produces a new generation in the console each time you click the main window with the mouse … also the string grows exponentially so if you do it enough times it will crash!

I’m not sure why the Neural Network one isn’t producing output for you, I’m getting similar results to Example 10.4 here: http://natureofcode.com/book/chapter-10-neural-networks/ … did you copy the ofApp.cpp file into the project?

sorry i mean the #include cause problems.
the others that also have separate class files work well.

the Neural Network example has all the same files as your folder. not sure why it stays white.
it does print stuff in the console

Neuron Feed Forward: 0.657434
Neuron Feed Forward: 1.59907
Neuron Fire
Neuron Feed Forward: 0.092191
Neuron Feed Forward: 0.54593

it is strange that it’s not displaying anything if you’re getting that output, I had a look at the code and can’t think of any reasons … only thing I can suggest is putting some debug output in the various display() methods in the 3 classes … or even some visual debug, e.g. just draw a basic circle within the Network display method() (as that’s the one that calls the others) and follow on from there