utils

package
v0.0.0-...-4880841 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package utils, implements utility functions used by game TicTacToe.

Index

Constants

View Source
const (
	Blank string = "---------" // Blank board state
)

Variables

View Source
var WinningCombo = [][]int{
	{0, 1, 2},
	{3, 4, 5},
	{6, 7, 8},
	{0, 3, 6},
	{1, 4, 7},
	{2, 5, 8},
	{0, 4, 8},
	{2, 4, 6},
}

Functions

func GenerateUUID

func GenerateUUID() (strfmt.UUID, error)

GenerateUUID, uses google/uuid package to generate a UUID.

func GetBkSym

func GetBkSym(userSym rune) rune

GetBkSym takes user symbol as input and returns robot symbol, default is X.

func GetGameStatus

func GetGameStatus(board string) string

GetGameStatus, takes board as input and returns game status - Running, Draw, XWins or OWins.

func ValidateUserMove

func ValidateUserMove(board string, before string) (rune, error)

ValidateUserMove, validates User move

func Winner

func Winner(sym rune) string

Winner return winner X or O.

Types

This section is empty.

Jump to

Keyboard shortcuts

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