This is a quick and dirty interface to Dragon Go Server's robot interface, as outlined at http://www.dragongoserver.net/faq.php?read=t&cat=215#Entry219. It does almost no sanity-checking of things you send it, nor does it do very much error-checking on the things Dragon sends back. Use with caution.
Here are some sample interactions from ghci, with a fictitious password:
*Network.DGS> browseDGS (silence >> login development "smartypants" "password") LoginSuccess *Network.DGS> browseDGS (silence >> statusUID production 4155) >>= mapM_ print (453881,"jedge42",False,"2009-12-21 03:14 GMT","F: 30d 1h") (532927,"bartnix",False,"2009-12-20 06:06 GMT","F: 21d 13h") *Network.DGS> browseDGS (silence >> statusUser production "dmwit") >>= mapM_ print (453881,"jedge42",False,"2009-12-21 03:14 GMT","F: 30d 1h") (532927,"bartnix",False,"2009-12-20 06:06 GMT","F: 21d 13h") *Network.DGS> :{ *Network.DGS| browseDGS $ do { *Network.DGS| silence; *Network.DGS| login development "smartypants" "password"; *Network.DGS| (_, (gid, _, black, _, _):_) <- status development; *Network.DGS| move development gid black (16, 18) (17, 16) *Network.DGS| } *Network.DGS| :} MoveSuccess
- data LoginResult
- login :: String -> String -> String -> DGS LoginResult
- type Game = (Integer, String, Bool, String, String)
- type Message = (Integer, String, String, String)
- status :: String -> DGS ([Message], [Game])
- statusUID :: String -> Integer -> DGS [Game]
- statusUser :: String -> String -> DGS [Game]
- type Point = (Integer, Integer)
- data MoveResult
- move :: String -> Integer -> Bool -> Point -> Point -> DGS MoveResult
- sgf :: String -> Integer -> Bool -> DGS String
- module Network.Browser
- newtype DGS a = DGS {
- runDGS :: BrowserAction (HandleStream String) a
- development :: String
- production :: String
- silence :: DGS ()
- browseDGS :: DGS a -> IO a
Logging in
data LoginResult Source
WrongUsername | |
WrongPassword | |
LoginProblem String | it's a bug in the library if one of these ever gets built |
LoginSuccess |
:: String | server, e.g. |
-> String | user name |
-> String | password |
-> DGS LoginResult |
some commands either require you to be logged in, or will give additional information if you log in
Listing games and messages
type Game = (Integer, String, Bool, String, String)Source
(game ID, username of the opponent, current player is black?, date, time remaining)
type Message = (Integer, String, String, String)Source
(message ID, username of the sender, subject, date)
get the inbox and games list of whoever is currently logged in; this will
return ([], [])
if you are not logged in
get the games list of an arbitrary user; this will give the same results whether or not you are logged in
get the games list of an arbitrary user this will give the same results whether or not you are logged in
Making a move
data MoveResult Source
NotLoggedIn | |
NoGameNumber | |
DatabaseCorrupted | or a bad game ID |
NotYourTurn | or you're not playing in the game, or you claimed to be the wrong color |
MoveAlreadyPlayed | or the previous move didn't match reality |
IllegalPosition | ko, playing on top of another stone, playing off the board |
MoveProblem String | it's a bug in the library if one of these ever gets built |
MoveSuccess |
you can only get private comments if you are logged in; if you are not logged in, this will succeed, but a request for private comments will be ignored, and you'll get an SGF with only the public comments
Miscellaneous
module Network.Browser
a convenient type synonym for HTTP's browser monad
DGS | |
|
the address of the development server, "dragongoserver.sourceforge.net"
the address of the most well-known public server, "www.dragongoserver.net"
by default, HTTP's browser chatters a lot on stdout; this action turns off the chatter