func (cfg Config) New(unusedTiles []tile.Tile) (*Board, error) {
	if err := cfg.Validate(); err != nil {
		return nil, errors.New("creating board: validation: " + err.Error())
	}
	unusedTilesByID := make(map[tile.ID]tile.Tile, len(unusedTiles))
	unusedTileIDs := make([]tile.ID, len(unusedTiles))
	for i, t := range unusedTiles {
		unusedTilesByID[t.ID] = t
		unusedTileIDs[i] = t.ID
	}
	usedTiles := make(map[tile.ID]tile.Position)
	usedTileLocs := make(map[tile.X]map[tile.Y]tile.Tile)
	b := Board{
		UnusedTiles:   unusedTilesByID,
		UnusedTileIDs: unusedTileIDs,
		UsedTiles:     usedTiles,
		UsedTileLocs:  usedTileLocs,
		Config:        cfg,
	}
	return &b, nil
}
// New creates a new board with the unused tiles.
New creates a new board with the unused tiles.
// New creates a new board with the unused tiles .
func (cfg Config) New(unusedTiles []tile.Tile) (*Board, error) {
	if err := cfg.Validate(); err != nil {
		return nil, errors.New("creating board: validation: " + err.Error())
	}
	unusedTilesByID := make(map[tile.ID]tile.Tile, len(unusedTiles))
	unusedTileIDs := make([]tile.ID, len(unusedTiles))
	for i, t := range unusedTiles {
		unusedTilesByID[t.ID] = t
		unusedTileIDs[i] = t.ID
	}
	usedTiles := make(map[tile.ID]tile.Position)
	usedTileLocs := make(map[tile.X]map[tile.Y]tile.Tile)
	b := Board{
		UnusedTiles:   unusedTilesByID,
		UnusedTileIDs: unusedTileIDs,
		UsedTiles:     usedTiles,
		UsedTileLocs:  usedTileLocs,
		Config:        cfg,
	}
	return &b, nil
}
func ( cfg Config ) New ( unusedTiles [ ] tile . Tile ) ( * Board , error ) { if err := cfg . Validate ( ) ; err != nil { return nil , errors . New ( " " + err . Error ( ) ) } unusedTilesByID := make ( map [ tile . ID ] tile . Tile , len ( unusedTiles ) ) unusedTileIDs := make ( [ ] tile . ID , len ( unusedTiles ) ) for i , t := range unusedTiles { unusedTilesByID [ t . ID ] = t unusedTileIDs [ i ] = t . ID } usedTiles := make ( map [ tile . ID ] tile . Position ) usedTileLocs := make ( map [ tile . X ] map [ tile . Y ] tile . Tile ) b := Board { UnusedTiles : unusedTilesByID , UnusedTileIDs : unusedTileIDs , UsedTiles : usedTiles , UsedTileLocs : usedTileLocs , Config : cfg , } return & b , nil }
New creates a new board with the unused tiles.
New creates a new board with the unused tiles .