# Patrick Coleman # Comp Sys Res - 6th period - 2007-08 # Sugarscape - main # sugargrid.txt - courtesy of Tony Bigbee, George Mason University require 'environment.rb' require 'display.rb' require 'simulation.rb' require 'tk' #Creates the environment env = Environment.new "sugargrid.txt",1 #Creates the GUI window root = TkRoot.new { title "pcoleman - Sugarscape"} Tk.root.resizable(0,0) Tk.root.protocol 'WM_DELETE_WINDOW', proc{quit} #Initializes the display createGUI(Tk.root,env) #Runs simulation while true #Updates the simulation if the simulation is running runSim if play? #Redraws the environment if the simulation is running updateDisp if play? #Quits and destroys Tk if window has been destroyed Tk.root.destroy if quit? break if quit? #Updates Tk Tk.update end