BaubleBlog/ 0000755 0000765 0000765 00000000000 11040652214 013225 5 ustar unclebob unclebob BaubleBlog/Bauble-0.1.gem 0000644 0000765 0000765 00000006000 11040652214 015401 0 ustar unclebob unclebob data.tar.gz 0000644 0000000 0000000 00000000755 00000000000 013326 0 ustar 00wheel wheel 0000000 0000000 /~H SQk0b,/-#c
CdRkN'-즱S7 βVռXi`dLú?|Z`DQ9T{(T/Z+C\v- EYrX{: BCBe2shQBvӾ jllN@6\V9SwMW!̝?$/`tL7ne
փݥd9>:`@\0p|v7ElvL
ńַm*^Joͻ«Zh݁ïg Ɇf w@w>m|kpoye%~CC|Ylf>#e(X22;.`,tzg!5$`4EJej$JA3<N
metadata.gz 0000644 0000000 0000000 00000000651 00000000000 013403 0 ustar 00wheel wheel 0000000 0000000 /~H SKo0ϯ0;V* K(Tₐe;3Ix&|#s&U};">iAc֨bc`G>OLa_O;?t8U1yZZ昲`Y
ơ9c&Jdچ&2m H3+K_v?e և^0QUW$E%q0b0$U.W։[}Mpa`h^dG{FG*Y}'
+V*=.jjJ!^*wޛ&UsQWyldqxu}w *IμhY'h+!%zlv
6LOzzAY~qrDZ)=_/ yU BaubleBlog/cellular_automaton/ 0000755 0000765 0000765 00000000000 11040651775 017132 5 ustar unclebob unclebob BaubleBlog/cellular_automaton/Cellular_automaton.iml 0000644 0000765 0000765 00000001457 11040651775 023476 0 ustar unclebob unclebob
BaubleBlog/cellular_automaton/cellular_automaton.ipr 0000644 0000765 0000765 00000051505 11040651775 023546 0 ustar unclebob unclebob
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
BaubleBlog/cellular_automaton/cellular_automaton.iws 0000644 0000765 0000765 00000047371 11040651775 023564 0 ustar unclebob unclebob
/Users/unclebob/.subversion
none
BaubleBlog/cellular_automaton/lib/ 0000755 0000765 0000765 00000000000 11022371066 017670 5 ustar unclebob unclebob BaubleBlog/cellular_automaton/lib/cell_panel.rb 0000644 0000765 0000765 00000000776 11022370764 022331 0 ustar unclebob unclebob
class CellPanel < JPanel
def init(xcells, ycells, cell_size, clear_screen, world_class)
@xcells = xcells
@ycells = ycells
@cell_size = cell_size
@clear_screen = clear_screen
@world_class = world_class
@world = world_class.new(xcells, ycells)
end
def paintComponent(g)
super if @clear_screen
@screen = g
@world.step(self)
end
def draw_cell(x,y,color)
@screen.setColor(color)
@screen.fillRect(x*@cell_size, y*@cell_size, @cell_size, @cell_size)
end
end BaubleBlog/cellular_automaton/lib/cellular_automaton.rb 0000644 0000765 0000765 00000002363 11022371251 024107 0 ustar unclebob unclebob require 'helper'
require 'cell_panel.rb'
class CellularAutomaton
def initialize
@mutex = Mutex.new
@swing_is_running = ConditionVariable.new
@cellPanel = CellPanel.new
end
def title(title)
@title = title
end
def world_size(xcells, ycells)
@xcells = xcells;
@ycells = ycells;
end
def cell_size(cell_size)
@cell_size = cell_size
end
def clear_screen_each_step(clear_screen)
@clear_screen = clear_screen
end
def world(world_class)
@world_class = world_class
end
def makeFrame
@frame = JFrame.new @title
@frame.set_size(@xcells*@cell_size, @ycells*@cell_size)
@frame.default_close_operation = JFrame::EXIT_ON_CLOSE
@cellPanel.init(@xcells, @ycells, @cell_size, @clear_screen, @world_class)
@frame.add @cellPanel
@frame.show
@swing_is_running.signal
end
def wait_for_swing_to_start_running
@mutex.synchronize do
@swing_is_running.wait(@mutex)
end
end
def run
wait_for_swing_to_start_running
while (true)
@frame.repaint
Thread.yield
end
end
def self.start(&proc)
frame = CellularAutomaton.new
frame.instance_eval(&proc)
javax.swing.SwingUtilities.invokeLater(proc {frame.makeFrame})
frame.run
end
end
BaubleBlog/cellular_automaton/lib/helper.rb 0000644 0000765 0000765 00000000425 11022370764 021501 0 ustar unclebob unclebob require 'java'
require 'thread'
include_class ['javax.swing.JFrame', 'javax.swing.JLabel', 'javax.swing.JButton', 'javax.swing.JPanel']
include_class ['java.lang.Runnable', 'javax.swing.SwingUtilities', 'java.awt.Graphics', 'java.lang.Thread']
include_class ['java.awt.Color'] BaubleBlog/LangtonsAnt/ 0000755 0000765 0000765 00000000000 11040652134 015456 5 ustar unclebob unclebob BaubleBlog/LangtonsAnt/LangtonsAnt.iml 0000644 0000765 0000765 00000001321 11012451437 020410 0 ustar unclebob unclebob
BaubleBlog/LangtonsAnt/LangtonsAnt.ipr 0000644 0000765 0000765 00000051053 11012447207 020430 0 ustar unclebob unclebob
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
BaubleBlog/LangtonsAnt/LangtonsAnt.iws 0000644 0000765 0000765 00000053413 11040652134 020440 0 ustar unclebob unclebob
/Users/unclebob/.subversion
none
BaubleBlog/LangtonsAnt/langtonsAnt.rb 0000644 0000765 0000765 00000002334 11040643742 020302 0 ustar unclebob unclebob require 'rubygems'
require 'bauble'
Bauble.use('../cellular_automaton')
class AntWorld
def initialize(xcells, ycells)
@xcells = xcells
@ycells = ycells
@world = []
@xcells.times {@world << []}
@x = @xcells/2
@y = @ycells/2
@direction = 0
end
def step(screen)
@screen = screen
if (white?)
blacken
turn_right
else
whiten
turn_left
end
end
def white?
cell = @world[@x][@y]
cell == nil || cell == true
end
def whiten
@world[@x][@y] = true
white_cell
end
def blacken
@world[@x][@y] = false
black_cell
end
def white_cell
@screen.draw_cell(@x, @y, Color.white)
end
def black_cell
@screen.draw_cell(@x, @y, Color.black)
end
def turn_right
@direction += 90
move
end
def turn_left
@direction -= 90
move
end
def move
@direction %= 360
case @direction
when 0
@x = (@x + 1) % @xcells
when 90
@y = (@y + 1) % @ycells
when 180
@x = (@x - 1) % @xcells
when 270
@y = (@y - 1) % @ycells
end
end
end
CellularAutomaton.start do
title "Langton's Ant"
world_size(1000,1000)
cell_size(1)
clear_screen_each_step false
world AntWorld
end
BaubleBlog/LangtonsAnt/spec/ 0000755 0000765 0000765 00000000000 10770540705 016421 5 ustar unclebob unclebob