Documentation
¶
Index ¶
- Constants
- func CorrespondingValidMoveIndex(move core.Move, allValidMoves []ValidMove) (found bool, index int)
- func EqualsCoreMove(validMove ValidMove, move core.Move) bool
- func ExportCoreLocation(location core.Location) int
- func GetCoreLocation(location int) core.Location
- func GetCorePlayer(teamId TeamType) core.Player
- func RandomIntInRange(min, max int) int
- type Capture
- type Changes
- type CheckersBotFlags
- type CheckersBotRawFlags
- type FeedType
- type Game
- func (game *Game) CreateRemoteUser()
- func (game *Game) GameLoop()
- func (game *Game) InitDbConnection()
- func (game *Game) InitGame()
- func (game *Game) OutgoingVoteFromMove(validMove ValidMove) (votes *OutgoingVotes)
- func (game *Game) PostChosenMove(votes *OutgoingVotes)
- func (game *Game) ServerUrl() string
- func (game *Game) SetDelayBeforeMove(delayBeforeMove int)
- func (game *Game) SetFeedType(feedType FeedType)
- func (game *Game) SetServerUrl(serverUrl string)
- func (game *Game) Turn() int
- func (game *Game) WaitForNextGame()
- type GameState
- type MoveHistory
- type Observer
- type OutgoingVotes
- type Piece
- type Team
- type TeamType
- type Thinker
- type User
- type ValidMove
- type VoteMove
Constants ¶
View Source
const ( DEFAULT_SERVER_URL = "http://localhost:4984/checkers" GAME_DOC_ID = "game:checkers" VOTES_DOC_ID = "votes:checkers" )
View Source
const ( RED_TEAM = TeamType(iota) BLUE_TEAM )
View Source
const ( NORMAL = FeedType(iota) LONGPOLL )
Variables ¶
This section is empty.
Functions ¶
func ExportCoreLocation ¶
func GetCoreLocation ¶
func GetCorePlayer ¶
func RandomIntInRange ¶
Types ¶
type CheckersBotFlags ¶
type CheckersBotFlags struct {
Team TeamType
SyncGatewayUrl string
FeedType FeedType
RandomDelayBeforeMove int
}
func ParseCmdLine ¶
func ParseCmdLine() (checkersBotFlags CheckersBotFlags)
type CheckersBotRawFlags ¶
type CheckersBotRawFlags struct {
TeamString string
SyncGatewayUrl string
FeedString string
RandomDelayBeforeMove int
}
func GetCheckersBotRawFlags ¶
func GetCheckersBotRawFlags() *CheckersBotRawFlags
func (*CheckersBotRawFlags) GetCheckersBotFlags ¶
func (rawFlags *CheckersBotRawFlags) GetCheckersBotFlags() CheckersBotFlags
type Game ¶
type Game struct {
// contains filtered or unexported fields
}
func (*Game) CreateRemoteUser ¶
func (game *Game) CreateRemoteUser()
func (*Game) GameLoop ¶
func (game *Game) GameLoop()
Follow the changes feed and on each change callback call game.handleChanges() which will drive the game
func (*Game) InitDbConnection ¶
func (game *Game) InitDbConnection()
func (*Game) OutgoingVoteFromMove ¶
func (game *Game) OutgoingVoteFromMove(validMove ValidMove) (votes *OutgoingVotes)
Given a validmove (as chosen by the Thinker), create an "Outgoing Vote" that can be passed to the server. NOTE: the struct OutgoingVotes needs to be renamed from plural to singular
func (*Game) PostChosenMove ¶
func (game *Game) PostChosenMove(votes *OutgoingVotes)
func (*Game) SetDelayBeforeMove ¶
func (*Game) SetFeedType ¶
func (*Game) SetServerUrl ¶
func (*Game) WaitForNextGame ¶
func (game *Game) WaitForNextGame()
Wait until the game number increments
type GameState ¶
type GameState struct {
Id string `json:"_id"`
Rev string `json:"_rev"`
Teams []Team `json:"teams"`
ActiveTeam TeamType `json:"activeTeam"`
WinningTeam TeamType `json:"winningTeam"`
Number int `json:"number"`
Turn int `json:"turn"`
MoveInterval int `json:"moveInterval"`
Moves []MoveHistory `json:"moves"`
}
data structure that corresponds to the checkers:game json doc
func NewGameStateFromString ¶
type MoveHistory ¶
type OutgoingVotes ¶
type OutgoingVotes struct {
Id string `json:"_id"`
Rev string `json:"_rev"`
Revisions map[string]interface{} `json:"_revisions"`
Channels []interface{} `json:"channels"` // ??
Moves []VoteMove `json:"moves"` // ??
TeamId TeamType `json:"team"`
GameId int `json:"game"`
Count int `json:"count"`
Turn int `json:"turn"`
PieceId int `json:"piece"`
Locations []int `json:"locations"`
}
type Piece ¶
type Piece struct {
// the locations are numbered from 1 to 32 where 1
// represents the top-left dark square for the red team,
// and 32 represents the bottom-right dark square for blue team.
Location int `json:"location"`
King bool `json:"king"`
Captured bool `json:"captured"`
ValidMoves []ValidMove `json:"validMoves"`
PieceId int
}
type Team ¶
type Team struct {
Score int `json:"score"`
ParticipantCount int `json:"participantCount"`
Pieces []Piece `json:"pieces"`
}
func (Team) AllValidMoves ¶
type ValidMove ¶
type ValidMove struct {
// in the case of a normal move or single jump, this will contain a single
// location which contains the location value of the move destination.
// (the move starting point is contained in the outer Piece struct)
// in the case of a double+ jump however, this will contain an array of
// the locations - the first location will be the first jump landing spot,
// the second location will be the second jump landing spot, etc..
// so for example, in this position: http://cl.ly/image/3k470u1P0G3M
// the piece location will be 24, and the locations will be: "locations":[15,6]
// which means 24->15,15->6
Locations []int `json:"locations"`
Captures []Capture `json:"captures"`
King bool `json:"king"`
PieceId int
StartLocation int
}
func (ValidMove) EndLocation ¶
Click to show internal directories.
Click to hide internal directories.


