
Hugh Perkins wrote:
Had an idea: a real shootout game for Haskell.
scripts "fight" in an arena for a second or so, and the results are published to the website
Sounds great :) There are lots of "robot battle" games out there, like http://realtimebattle.sourceforge.net/ http://robocode.sourceforge.net but none in Haskell, of course. I think there's a classic predecessor to those but I don't know exactly.
Each turn is represented by a function something like:
doturn :: String -> [[GridValue]] -> (Action,String)
The explicit state can be dispensed with by introducing a stream type data Robot = Robot (BattleField -> (Action, Robot) type BattleField = [[GridValue]] This way, the program is entirely free in how to choose its state representation. You can turn any doturn - based program into a stream-based one toRobot :: String -> (BattleField -> String -> (Action,String)) -> Robot toRobot s doturn = Robot $ \arena -> let (action, s') = doturn bf s in (action, toRobot s' doturn) The drawback is that it's no longer possible to save a snapshot of each program's state to disk and resume the fight later. Regards, apfelmus