Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement --map option #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Bot
import Data.String (fromString)
import Data.Text (pack, unpack)

data Cmd = Training Settings (Maybe Int) (Maybe Board)
data Cmd = Training Settings (Maybe Int) (Maybe BoardId)
| Arena Settings
deriving (Show, Eq)

Expand All @@ -24,7 +24,7 @@ settings = Settings <$> (Key <$> argument (Just . pack) (metavar "key"))
trainingCmd :: Parser Cmd
trainingCmd = Training <$> settings
<*> optional (option (long "turns"))
<*> pure Nothing
<*> optional (strOption (long "map"))

arenaCmd :: Parser Cmd
arenaCmd = Arena <$> settings
Expand Down
2 changes: 1 addition & 1 deletion src/Vindinium/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Control.Monad (liftM, mzero)
import Control.Monad.IO.Class (liftIO)
import Control.Applicative ((<$>), (<*>))

startTraining :: Maybe Int -> Maybe Board -> Vindinium State
startTraining :: Maybe Int -> Maybe BoardId -> Vindinium State
startTraining mi mb = do
url <- startUrl "training"
let obj = object ( maybe [] (\i -> [("turns", toJSON i)]) mi
Expand Down
2 changes: 1 addition & 1 deletion src/Vindinium/Play.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Vindinium.Play
import Vindinium.Types
import Vindinium.Api

playTraining :: Maybe Int -> Maybe Board -> Bot -> Vindinium State
playTraining :: Maybe Int -> Maybe BoardId -> Bot -> Vindinium State
playTraining mt mb b = startTraining mt mb >>= playLoop b

playArena :: Bot -> Vindinium State
Expand Down
3 changes: 3 additions & 0 deletions src/Vindinium/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module Vindinium.Types
, Tile (..)
, Pos (..)
, Dir (..)
, BoardId
)
where

Expand All @@ -23,6 +24,8 @@ import Data.Text (Text)
import Control.Monad.Reader (MonadReader, ReaderT, runReaderT, asks)
import Control.Monad.IO.Class (MonadIO)

type BoardId = String
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about using a Text based newtype ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be fine, too. I only needed to specify things like "--map m1" so I just reached for a String.

It seems that the REST API allows you to specify a complete custom map. If that is the case did you have any ideas on how that would be expressed via the command line options?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can specify the path to a file and/or read from the stdin.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, perhaps I was wrong about being able to send a custom map - will have to check with the devs. But if it is possible then reading it from a file or stdin would be a good option.


newtype Key = Key Text deriving (Show, Eq)

data Settings = Settings {
Expand Down