dgs-0.2: Haskell front-end for DGS' bot interface

Network.DGS

Contents

Description

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

Synopsis

Logging in

data LoginResult Source

Constructors

WrongUsername 
WrongPassword 
LoginProblem String

it's a bug in the library if one of these ever gets built

LoginSuccess 

loginSource

Arguments

:: String

server, e.g. development or production

-> 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)

statusSource

Arguments

:: String

server

-> DGS ([Message], [Game]) 

get the inbox and games list of whoever is currently logged in; this will return ([], []) if you are not logged in

statusUIDSource

Arguments

:: String

server

-> Integer

user ID

-> DGS [Game] 

get the games list of an arbitrary user; this will give the same results whether or not you are logged in

statusUserSource

Arguments

:: String

server

-> String

user name

-> DGS [Game] 

get the games list of an arbitrary user this will give the same results whether or not you are logged in

Making a move

type Point = (Integer, Integer)Source

0-indexed x/y coordinates that start at the top left

data MoveResult Source

Constructors

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 

moveSource

Arguments

:: String

server

-> Integer

game ID

-> Bool

playing as black? (can use exactly the value you got from status)

-> Point

the move the opponent just made

-> Point

your move

-> DGS MoveResult 

sgfSource

Arguments

:: String

server

-> Integer

game ID

-> Bool

request the private comments?

-> DGS String 

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

newtype DGS a Source

a convenient type synonym for HTTP's browser monad

Constructors

DGS 

development :: StringSource

the address of the development server, "dragongoserver.sourceforge.net"

production :: StringSource

the address of the most well-known public server, "www.dragongoserver.net"

silence :: DGS ()Source

by default, HTTP's browser chatters a lot on stdout; this action turns off the chatter