Recently I've been looking at Povray, pyprocessing, and cfdg (version 3.0) as tools for creating digital images. I have branched two separate blogs where I mainly explore jruby + processing and processing.py

Wednesday, 17 November 2010

Refactoring my Tic Tac Toe eisenscript to use flip and recursion

Exploring limited recursion, and flip directives in StructureSynth "Hinxton".

Using the javascript interface, it should be possible to create some sort of animation here.

The position of spheres/jacks, within the frame are known, so if we create a map of those, and then randomly select (remove) positions, we could then place jack or sphere (alternately). Ideally though there needs to be some logic to assess a "winning line" to stop the animation, it should not be impossible.
However a chicken way out would be create a game sequence, consisting of a set of valid moves. Create a eisenscript for each move, and then call those scripts in sequence using the javascript interface.

   1 // Camera settings. Place these before first rule call.
   2 set translation [-0.0633663 0.0965309 -20]
   3 set rotation [0.888729 0.0811242 0.451178 -0.094785 0.995468 0.00771677 -0.448509 -0.0496248 0.892393]
   4 set pivot [0 0 0]
   5 set scale 0.4
   6 
   7 
   8 game
   9 
  10 set background #fff
  11 
  12 rule game{
  13   {h 20} frame
  14   {s 4 h 220} sphere::reflection
  15   {x -5 z -5 y -5 ry 45 rz 45 rx 45} jack
  16   {x 5 z 5 y 5 ry 45 rz 45 rx 45} jack
  17 }
  18 
  19 
  20 rule frame maxdepth 2{
  21   cross
  22   {ry 90} frame
  23 }
  24 
  25 rule cross maxdepth 2{
  26   four
  27   {rz 90} cross
  28 }
  29 
  30 rule four{
  31  {y -2.5 z -2.5}bar
  32  {y -2.5 z 2.5}bar
  33  {y 2.5 z -2.5}bar
  34  {y 2.5 z 2.5}bar
  35 }
  36 
  37 rule bar{
  38   {s 14 0.5 0.5} box::phong
  39 }
  40   
  41 rule jack maxdepth 3{
  42   arm
  43   {ry 90}jack
  44   {rz 90}jack
  45 }
  46 
  47 rule arm maxdepth 2{
  48   5 *{x 0.28284271} sphere::phong
  49   {fx} arm
  50 }
  51 
  52 set raytracer::max-threads 2
  53 set raytracer::ambient-occlusion-samples 20
  54 set raytracer::size [600x0]
  55 set raytracer::shadows true
  56 set raytracer::phong [0.6,0.6,0.3]
  57 set raytracer::reflection 0.8

Rendered using built in raytracer






















Here is my experiment with the groovelock sunflow template (using mirror property for the ball)

Rendered in sunflow with groovelock template

No comments:

Post a Comment

Followers

Blog Archive

About Me

My photo
Pembrokeshire, United Kingdom
I have developed JRubyArt and propane new versions of ruby-processing for JRuby-9.1.5.0 and processing-3.2.2