game

package
v0.25.0-563e3bd Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultGameRulesNormal = GameRules{
		MaximumScore:              361,
		MinimumScore:              165,
		MaximumResourceScore:      130,
		MinimumResourceScore:      30,
		MaxOver300:                10,
		MaxSameLandscapePerRow:    2,
		MaxSameLandscapePerColumn: 2,
		AdjacentSame:              0,
		GameType:                  0,
		GameTypeString:            "Normal",
		Generations:               2500,
		Delimiter:                 "_",
	}

	DefaultGameRulesLarge = GameRules{
		MaximumScore:              365,
		MinimumScore:              156,
		MaximumResourceScore:      130,
		MinimumResourceScore:      65,
		MaxOver300:                22,
		MaxSameLandscapePerRow:    3,
		MaxSameLandscapePerColumn: 3,
		AdjacentSame:              0,
		GameType:                  1,
		GameTypeString:            "Large",
		Generations:               5000,
		Delimiter:                 "_",
	}
)
View Source
var LargeGame = CreateLargeGame()
View Source
var NormalGame = CreateNormalGame()

Functions

func GenerateGameCodeNormalGame added in v0.1.0

func GenerateGameCodeNormalGame() string

func ValidateAdjacentTiles added in v0.1.0

func ValidateAdjacentTiles(board *Board, rules GameRules) bool

ValidateAdjacentTiles validates the scores based on the tiles that lie next to each other we derive the scores from the probability score of the Number (based on a two dice roll) we do not want a too great a spot, we also do not want a too weak spot in addition, we also do not want too many spots (3 adjacent tiles) to be over a score of 300 as this would signify a skewed distribution of resources and their scores

func ValidateHarbors added in v0.1.0

func ValidateHarbors(board *Board, rules GameRules) bool

ValidateHarbors validates whether or not a harbor is linked to a resource tile with the same resource as the harbor

func ValidateResourceScores added in v0.1.0

func ValidateResourceScores(board *Board, rules GameRules) bool

ValidateResourceScores validates the scores of the resources we derived the scores from the probability scores of the Number of the tile they're associated with there is a maximum, and a minimum to validate, to make sure all resources fall within a certain distribution

func ValidateResourceSpread added in v0.1.0

func ValidateResourceSpread(board *Board, rules GameRules) bool

ValidateResourceSpread validates whether resources are spread on the board. There shouldn't be too many of the same resource next to each other.

func ValidateTilesNumbers added in v0.1.0

func ValidateTilesNumbers(board *Board, rules GameRules) bool

ValidateTilesNumbers validates if the number of tiles in the board matches the expected tiles for a given game type

Types

type Board

type Board struct {
	Tiles     []*model.Tile
	Board     map[string][]*model.Tile
	GameType  GameType
	Harbors   map[string]*model.Harbor
	GameCode  string
	WaitGroup sync.WaitGroup
}

Board the Catan game Board, contains the Tiles and how they are distributed on the Board

func InflateLargeGameFromCode added in v0.1.0

func InflateLargeGameFromCode(code string, gameType *GameType) (Board, error)

func InflateNormalGameFromCode added in v0.1.0

func InflateNormalGameFromCode(code string, gameType *GameType) (Board, error)

InflateNormalGameFromCode inflates a normal game from code

func (*Board) GetGameCode added in v0.1.0

func (board *Board) GetGameCode(delimiter bool) string

func (*Board) IsValid

func (b *Board) IsValid(rules GameRules, game GameType) bool

IsValid wrapper function for encapsulating all the validations for the map

func (*Board) PrintToConsole

func (b *Board) PrintToConsole()

type GameRules

type GameRules struct {
	MaximumScore              int
	MinimumScore              int
	MaximumResourceScore      int
	MinimumResourceScore      int
	MaxOver300                int
	MaxSameLandscapePerRow    int
	MaxSameLandscapePerColumn int
	AdjacentSame              int
	GameType                  int
	GameTypeString            string
	Generations               int
	Delimiter                 string
}

GameRules the rules for generating this Game's map

type GameType

type GameType struct {
	Name               string
	TilesCount         int
	DesertCount        int
	ForestCount        int
	PastureCount       int
	FieldCount         int
	RiverCount         int
	MountainCount      int
	HarborCount        int
	AdjacentTileGroups [][]string
	NumberSet          []*model.Number
	HarborSet          []*model.Harbor
	HarborLayout       []string
	BoardLayout        map[string]int
	ToConsole          PrintBoardToConsole
}

GameType the information for the type of game Should be exhaustive and will be expanded for supporting alternative game types such as Seafarers

func CreateLargeGame

func CreateLargeGame() GameType

CreateLargeGame creates a Large game for up to four players. Will create a board layout as shown below.

func CreateNormalGame

func CreateNormalGame() GameType

CreateNormalGame creates a Normal game for up to four players. Will create a board layout as shown below. Harbors: [c0], [a0, a1], [a2], [b3, c4], [d3, c4], [e2], [e0, e1]

c, a0, a1, a2, b3, d3, e2, e1,  e0

............H........... ........../.3\..........a- b- c0 d- e- ....H./11\\.2//.8\.H....a- b0 c0 d0 e- ../.6\\.3//.3\\.2//.0\..a0 b0 c1 d0 e0 .H\.1//.6\\.4//.9\\.0/H.a0 b1 c1 d1 e0 ../.4\\.1//.9\\.5//.8\..a1 b1 c2 d1 e1 ..\.2//.4\\.3//10/\.5/..a1 b2 c2 d2 e1 ../.5\\.1//.5\\.3//.2\..a2 b2 c3 d2 e2 .H\.3//12\\.1//11\\.2/H.a2 b3 c3 d3 e2 ......\.4//10\\.4/......a- b3 c4 d3 e- ........H.\.5/.H........a- b- c4 d- e- ........................ a -> an+1, bn, bn+1 b -> an, an-1, bn+1, cn, cn+1 c -> cn+1, dn, dn-1 d -> dn+1, en, en-1 where n => 0 where an < 3 where bn < 4 where cn < 5 where dn < 4 where en < 3

type PrintBoardToConsole

type PrintBoardToConsole func(b *Board)

type ValidateBoard added in v0.1.0

type ValidateBoard func(board *Board, gameRules GameRules) bool

ValidateBoard function that validates certain attributes of a game Board the validate function should compare the current board against the rules for the request game

Jump to

Keyboard shortcuts

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