Bomberman Client
Client for a Bomberman game event. Your goal is to implement a player
function
in the Bomberman.Player
module.
player :: ( MonadIO m
, MonadReader r m
, HasLogFunc r
)
=> Board Cell
-> m Action
player board = pure $ Action Stay BombBeforeMove
Building and running
In order to build and run this client you need to install stack. Once you have it, just run the following commands in the root of the project.
$ stack build
$ stack exec bomberman-bot -- --user [email protected] --code CODE
# or simply
$ stack build && stack exec bomberman-bot -- --user [email protected] --code CODE
If you wish to change the default server, there are --address
and --port
options that you can use.
Use --help
option to get more information about the command line options.
bomberman-bot - enjoy the bot playing bomberman Usage: bomberman-bot [--version] [--address VALUE] [--port NUMBER] --user VALUE --code VALUE bomberman bot Available options: -h,--help Show this help text --version Show version --address VALUE Override default address --port NUMBER Override default port --user VALUE Set the user --code VALUE Set the code
Docker
One can also build and run the client using docker
.
$ docker build .
$ docker run -e [email protected] -e code=CODE
Writing the bot
player :: ( MonadIO m
, MonadReader r m
, HasLogFunc r
)
=> Board Cell
-> m Action
The player
function takes the current Board
and returns an Action
-
combination of Move
command (stay or move to one of the Direction
) and
Bomb
command (do nothing, place a bomb before the move or place a bomb after
the move).
The Board
datatype is more interesting. Under the hood, itโs just a
two-dimensional variant of the pointed lost (Universe a
), which represents and
element (focus), a list of elements to the โleftโ of the focus and a list of
elements to the โrightโ of the focus. Think of an endless tape with a focus. You
can shift it to either of the sides (left/right). Universe a
is polymorphic.
Now if you put another Universe
as element, you get two-dimensional
Universe
. Board
in a nutshell is just an Universe (Universe a)
.
The great thing about Universe
(and Board
in particular) is that itโs a
Functor
and Comonad
. This gives an ability to nicely evaluate the game
board. Just take a look at mark
function. If you have questions, just ask
@d12frosted.
Monad
here is present for two reasons:
- allow usage of
random
(requiresMonadIO
), - allow usage of logging (
MonadReader
withHasLogFunc
).