[Haskell-cafe] Haskell shootout game

David LaPalomento dlapalomento at gmail.com
Sun Jul 15 16:23:08 EDT 2007

On 7/15/07, Hugh Perkins <hughperkins at gmail.com> wrote:
> Had an idea: a real shootout game for Haskell.
> The way it would work is:
> - you email a haskell program to a specific address
> - it shows up on a web-page
> The webpage shows the last submitted solution for each person
> - anyone can select two solutions and click "Fight"
> -> the scripts "fight" in an arena for a second or so, and the results are
> published to the website
> The arena itself comprises:
> - a 2d grid, of a certain size (or maybe variable size)
> - each grid cell can be a wall, or one of the opponents
> - the boundaries of the grid are walls
> - random blocks of wall are placed around the grid
> The opponents only perceive what is in a section of space to their front,
> in a 45 degree arc from either side of the direction they are facing
> - each player can face along one of the four grid axes
> Each player takes it in turns to move
> - at each move the player can:
>    - move one square
>    - turn 90 degrees, in either direction
>    - fire
> Firing will score one point if the opponent is in the line of fire at that
> time, and there are no intervening walls.
> Opponents can see the direction the other opponent is facing, as long as
> the other opponent is in their view arc, and there are no intervening walls.
> Each turn is represented by a function something like:
> doturn :: String -> [[GridValue]] -> (Action,String)
> -- [[GridValue]] is a map of what Me sees this turn, or has seen
> previously
> -- the Strings are a way for the function to pass state to itself between
> moves
> data GridValue = Opponent | Me | Wall | Empty
> data Action = Fire | MoveNorth | MoveSouth |MoveEast | MoveWest | TurnLeft
> | TurnRight | Wait    -- (players can move backwards and sideways)
> many   :: Parser a -> Parser [a]
> many p = do { x <- p; xs <- many p; return (x:xs) }
> The turn would be run as a separate thread, which either terminates
> successfully, or is aborted after a fixed time x milliseconds (maybe 10
> milliseconds?)
> The String that doturn produces at the end of a turn is passed back in at
> the beginning of the next turn (so one could use gread/gshow to
> serialize/deserialize arbitrary data types, and there is no limitation on
> what data can be stored in the state).
> After say 1000 turns, the results are the points of each script. (or we
> could give each script a number of "lives" and if its loses them all the
> other script wins outright)
> This can run on a hosted webserver probably, because each match is part of
> a webpage request, and lasts a maximum of about a second, so shouldnt be
> terminated prematurely by cpu-monitoring scripts.

I think this is a great idea!  Besides being a nice AI testing ground, it
might be a lot of fun.  Of course, that web-hosting issue could end up being
more of a minefield than one might expect...

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070715/9eb2aaba/attachment.htm

More information about the Haskell-Cafe mailing list