Hi Guys,
I think I arrived a little late yesterday and might have missed some of the discussion. I've had a little think about things now and as luck would have it something from Chris Granger (of light table fame) popped up on hacker news this morning. He posted a small article about his entry to a game programming competition written in clojurescript which I think we'd do well to harvest some ideas from.
I think the key idea is the one of the state of the world being a data structure that the logic of the game (which are simple functions) acts upon. Very crudely, something like:
EntityID = Integer
Component = Pos (Int, Int)
| TurretDir (Float)
| Speed (Float)
| Render [Component] -> ()
....
newtype Word = Map EntityID [Component]
botState = [
Pos (0, 0)
, TurretDir 90
, Speed 1.5
]
If we think about it like this then our Bot monad is just something that submits commands to be run against the state of the world. The UI is a function (catamorphism?) that filters the world for Entities that have a Render constructor and calls the function contained.
What do you think?
Ben