by vimes656 on 12/15/13, 11:33 AM with 24 comments
by tinco on 12/15/13, 1:08 PM
What about a component oriented design? This is the standard architecture for games anyway.
An enemy, actually every entity, would just be a map of components, which can be simple algebraic data types. The actions can be implemented as a system function with pattern matching or guards, like:
-- The walking system
walk :: Entity -> Entity
walk e = update entity "position" $ walk' (lookup "position" entity)
walk' (x,y) = (x+1,y)
In reality systems usually work on more than one component, so you'd have to make actions that work on tuples of components, but you'll figure it out :)by flohofwoe on 12/15/13, 3:24 PM
by lelf on 12/15/13, 1:02 PM
The goal of expression problem is ability to add new cases in type and new operations on type without touching existing code (and without compromising static type safety)
by jokoon on 12/15/13, 1:04 PM