gox

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2018 License: GPL-3.0 Imports: 1 Imported by: 3

Documentation

Overview

Package gox provides defines basic datatypes and methods for creating a simple tic-tac-toe game.

Index

Constants

View Source
const BoardSize = 9

Variables

This section is empty.

Functions

This section is empty.

Types

type AIGame

type AIGame struct {
	Human  Symbol
	ArtInt Symbol
	Board
}

AIGame represents a tic-tac-toe game with one player being human, the other being an ai.

type Board

type Board [3][3]Symbol

Board represents a tic-tac-toe field. (0, 0) is upper left corner, (2, 2) is lower right.

func (*Board) CheckWin

func (b *Board) CheckWin() (win bool, player Symbol)

CheckWin returns true if a player won and returns the corresponding symbol.

func (*Board) FreeFields

func (b *Board) FreeFields() [][2]int

FreeFields returns a slice containig (row, col) of unset fields.

func (*Board) Round

func (b *Board) Round() int

Round returns the number of occupied fields.

func (*Board) String

func (b *Board) String() string

String returns you the game board as multi-line string. Preferably to print.

type MPGame

type MPGame struct {
	Player1 Symbol
	Player2 Symbol
	Board
}

MPGame represents a tic-tac-toe game with a board and two players.

type Symbol

type Symbol byte

Symbol holds a character representing a player. Make sure they are uniqe and non-zero.

func (Symbol) String

func (s Symbol) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL