Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ai/bot/elite.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func endGameBest(ctx context.Context, p *BotTurnPlayer, endgamePlies int) (*move
gameCopy := p.Game.Copy()
gameCopy.SetBackupMode(game.SimulationMode)
gameCopy.SetStateStackLength(endgamePlies + 1)
gen1 := movegen.NewGordonGenerator(gd, gameCopy.Board(), p.Game.Rules().LetterDistribution(), p.Game.Rules().BingoBonus())
gen1 := movegen.NewGordonGenerator(gd, gameCopy.Board(), p.Game.Rules().LetterDistribution())
err = p.endgamer.Init(gen1, gameCopy)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion ai/turnplayer/static_player.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func AddAIFields(p *turnplayer.BaseTurnPlayer, conf *config.Config, calculators
if err != nil {
return nil, err
}
gen := movegen.NewGordonGenerator(gd, p.Board(), p.Bag().LetterDistribution(), p.Rules().BingoBonus())
gen := movegen.NewGordonGenerator(gd, p.Board(), p.Bag().LetterDistribution())
gen.SetEquityCalculators(calculators)
ret := &AIStaticTurnPlayer{*p, calculators, gen, conf}
return ret, nil
Expand Down
8 changes: 4 additions & 4 deletions board/board.go
Original file line number Diff line number Diff line change
Expand Up @@ -844,16 +844,16 @@ func (g *GameBoard) formedCrossWord(crossVertical bool, letter tilemapping.Machi
// assume the row stays static as we iterate through the letters of the
// word.
func (g *GameBoard) ScoreWord(word tilemapping.MachineWord, row, col, tilesPlayed int,
crossDir BoardDirection, ld *tilemapping.LetterDistribution, bingoBonus int) int {
crossDir BoardDirection, ld *tilemapping.LetterDistribution) int {

// letterScore:
var ls int

mainWordScore := 0
crossScores := 0
bonus := 0
bingoBonus := 0
if tilesPlayed == 7 {
bonus = bingoBonus
bingoBonus = 50
}
wordMultiplier := 1

Expand Down Expand Up @@ -904,7 +904,7 @@ func (g *GameBoard) ScoreWord(word tilemapping.MachineWord, row, col, tilesPlaye
crossScores += ls*letterMultiplier*thisWordMultiplier + cs*thisWordMultiplier
}
}
return mainWordScore*wordMultiplier + crossScores + bonus
return mainWordScore*wordMultiplier + crossScores + bingoBonus

}

Expand Down
21 changes: 0 additions & 21 deletions board/layouts.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,11 @@ var (
// SuperCrosswordGameBoard is a board for a bigger Crossword game, featuring
// even more wingos and blonks.
SuperCrosswordGameBoard []string
// CrossplayGameBoard is a board like Crossword but with alternate wingo blonk
// arrangement.
CrossplayGameBoard []string
)

const (
CrosswordGameLayout = "CrosswordGame"
SuperCrosswordGameLayout = "SuperCrosswordGame"
CrossplayGameLayout = "CrossplayGame"
)

func init() {
Expand Down Expand Up @@ -59,21 +55,4 @@ func init() {
` - " - - " - `,
`~ ' = ' = ' ~`,
}
CrossplayGameBoard = []string{
`" = ' = "`,
` - " " - `,
` ' ' `,
`= ' - ' =`,
` ' " " ' `,
` " ' " `,
` " " `,
`' - ' ' - '`,
` " " `,
` " ' " `,
` ' " " ' `,
`= ' - ' =`,
` ' ' `,
` - " " - `,
`" = ' = "`,
}
}
3 changes: 0 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const (
ConfigOpenaiApiKey = "openai-api-key"
ConfigDeepseekApiKey = "deepseek-api-key"
ConfigWooglesApiKey = "woogles-api-key"
ConfigBingoBonus = "bingo-bonus"
ConfigAliases = "aliases"
)

Expand Down Expand Up @@ -114,7 +113,6 @@ func (c *Config) Load(args []string) error {
c.BindEnv(ConfigOpenaiApiKey)
c.BindEnv(ConfigDeepseekApiKey)
c.BindEnv(ConfigWooglesApiKey)
c.BindEnv(ConfigBingoBonus)

cfgdir, err := os.UserConfigDir()
if err != nil {
Expand Down Expand Up @@ -168,7 +166,6 @@ func (c *Config) Load(args []string) error {
c.SetDefault(ConfigOpenaiApiKey, "")
c.SetDefault(ConfigDeepseekApiKey, "")
c.SetDefault(ConfigWooglesApiKey, "")
c.SetDefault(ConfigBingoBonus, 50)

return nil
}
Expand Down
27 changes: 0 additions & 27 deletions data/letterdistributions/english_crossplay

This file was deleted.

2 changes: 1 addition & 1 deletion endgame/negamax/solver.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ func (s *Solver) makeGameCopies() error {
s.movegens = []movegen.MoveGenerator{}
gaddag := s.stmMovegen.(*movegen.GordonGenerator).GADDAG()
for i := 0; i < s.threads-1; i++ {
mg := movegen.NewGordonGenerator(gaddag, s.gameCopies[i].Board(), s.gameCopies[i].Bag().LetterDistribution(), s.gameCopies[i].Rules().BingoBonus())
mg := movegen.NewGordonGenerator(gaddag, s.gameCopies[i].Board(), s.gameCopies[i].Bag().LetterDistribution())
mg.SetSortingParameter(movegen.SortByNone)
mg.SetGenPass(true)
mg.SetPlayRecorder(movegen.AllPlaysSmallRecorder)
Expand Down
6 changes: 3 additions & 3 deletions equity/calculators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func TestEndgameTiming(t *testing.T) {
bd := board.MakeBoard(board.CrosswordGameBoard)
ld, err := tilemapping.EnglishLetterDistribution(DefaultConfig.WGLConfig())
assert.Nil(t, err)
generator := movegen.NewGordonGenerator(gd, bd, ld, 50)
generator := movegen.NewGordonGenerator(gd, bd, ld)
tilesInPlay := bd.SetToGame(gd.GetAlphabet(), board.MavenVsMacondo)
cross_set.GenAllCrossSets(bd, gd, ld)
generator.GenAll(tilemapping.RackFromString("AEEORS?", alph), false)
Expand Down Expand Up @@ -131,7 +131,7 @@ func TestPreendgameTiming(t *testing.T) {
bd := board.MakeBoard(board.CrosswordGameBoard)
ld, err := tilemapping.EnglishLetterDistribution(DefaultConfig.WGLConfig())
assert.Nil(t, err)
generator := movegen.NewGordonGenerator(gd, bd, ld, 50)
generator := movegen.NewGordonGenerator(gd, bd, ld)
tilesInPlay := bd.SetToGame(gd.GetAlphabet(), board.VsOxy)
cross_set.GenAllCrossSets(bd, gd, ld)
generator.GenAll(tilemapping.RackFromString("OXPBAZE", alph), false)
Expand Down Expand Up @@ -170,7 +170,7 @@ func TestOpeningPlayHeuristic(t *testing.T) {
bd := board.MakeBoard(board.CrosswordGameBoard)
ld, err := tilemapping.EnglishLetterDistribution(DefaultConfig.WGLConfig())
assert.Nil(t, err)
generator := movegen.NewGordonGenerator(gd, bd, ld, 50)
generator := movegen.NewGordonGenerator(gd, bd, ld)
cross_set.GenAllCrossSets(bd, gd, ld)
generator.GenAll(tilemapping.RackFromString("AEFLR", alph), false)
els, err := equity.NewCombinedStaticCalculator(
Expand Down
1 change: 0 additions & 1 deletion game/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ func (g *Game) Copy() *Game {
maxScorelessTurns: g.maxScorelessTurns,
exchangeLimit: g.exchangeLimit,
players: copyPlayers(g.players),
rules: g.rules,
// stackPtr only changes during a sim, etc. This Copy should
// only be called at the beginning of everything.
stackPtr: 0,
Expand Down
2 changes: 1 addition & 1 deletion game/game.go
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ func (g *Game) CreateAndScorePlacementMove(coords string, tiles string, rack str
// ScoreWord assumes the play is always horizontal, so we have to
// do the transpositions beforehand.
score := g.Board().ScoreWord(mw, row, col, tilesPlayed,
crossDir, g.bag.LetterDistribution(), g.rules.BingoBonus())
crossDir, g.bag.LetterDistribution())
// reset row, col back for the actual creation of the play.
if vertical {
row, col = col, row
Expand Down
14 changes: 0 additions & 14 deletions game/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ type GameRules struct {
boardname string
distname string
exchangeLimit int
bingoBonus int
}

func (g GameRules) Config() *config.Config {
Expand Down Expand Up @@ -89,10 +88,6 @@ func (g GameRules) ExchangeLimit() int {
return g.exchangeLimit
}

func (g GameRules) BingoBonus() int {
return g.bingoBonus
}

func NewBasicGameRules(cfg *config.Config,
lexiconName, boardLayoutName, letterDistributionName, csetGenName string,
variant Variant) (*GameRules, error) {
Expand All @@ -108,8 +103,6 @@ func NewBasicGameRules(cfg *config.Config,
bd = board.CrosswordGameBoard
case board.SuperCrosswordGameLayout:
bd = board.SuperCrosswordGameBoard
case board.CrossplayGameLayout:
bd = board.CrossplayGameBoard
default:
return nil, errors.New("unsupported board layout")
}
Expand Down Expand Up @@ -147,12 +140,6 @@ func NewBasicGameRules(cfg *config.Config,
exchLimit = 1
}

// Set bingo bonus based on board layout
bingoBonus := cfg.GetInt(config.ConfigBingoBonus)
if boardLayoutName == board.CrossplayGameLayout {
bingoBonus = 40
}

rules := &GameRules{
cfg: cfg,
dist: dist,
Expand All @@ -163,7 +150,6 @@ func NewBasicGameRules(cfg *config.Config,
crossSetGen: csgen,
variant: variant,
exchangeLimit: exchLimit,
bingoBonus: bingoBonus,
}
return rules, nil
}
Expand Down
49 changes: 0 additions & 49 deletions game/rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package game
import (
"testing"

"github.com/domino14/macondo/board"
"github.com/domino14/macondo/config"
"github.com/matryer/is"
)

Expand All @@ -30,50 +28,3 @@ func TestMaxCanExchange(t *testing.T) {
is.Equal(MaxCanExchange(tc.inbag, tc.exchlimit), tc.expected)
}
}

func TestBingoBonus(t *testing.T) {
is := is.New(t)

cfg := config.DefaultConfig()
cfg.Set(config.ConfigBingoBonus, 50) // Set default to 50

// Create rules manually
rules := &GameRules{
cfg: cfg,
bingoBonus: 0,
}

// Simulate the bingo bonus setting logic from NewBasicGameRules
bingoBonus := cfg.GetInt(config.ConfigBingoBonus)
if board.CrossplayGameLayout == board.CrossplayGameLayout {
bingoBonus = 40
}
rules.bingoBonus = bingoBonus

is.Equal(rules.BingoBonus(), 40) // Crossplay overrides to 40

// Test other layouts use configured value
bingoBonus = cfg.GetInt(config.ConfigBingoBonus)
if board.CrosswordGameLayout == board.CrossplayGameLayout {
bingoBonus = 40
}
rules.bingoBonus = bingoBonus
is.Equal(rules.BingoBonus(), 50) // Should use configured value

// Test custom bingo bonus
cfg.Set(config.ConfigBingoBonus, 35)
bingoBonus = cfg.GetInt(config.ConfigBingoBonus)
if board.CrosswordGameLayout == board.CrossplayGameLayout {
bingoBonus = 40
}
rules.bingoBonus = bingoBonus
is.Equal(rules.BingoBonus(), 35) // Should use configured value

// Test Crossplay still overrides to 40 even with custom config
bingoBonus = cfg.GetInt(config.ConfigBingoBonus)
if board.CrossplayGameLayout == board.CrossplayGameLayout {
bingoBonus = 40
}
rules.bingoBonus = bingoBonus
is.Equal(rules.BingoBonus(), 40) // Crossplay should still be 40
}
8 changes: 3 additions & 5 deletions movegen/movegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ type GordonGenerator struct {
quitEarly bool
maxTileUsage int
maxCanExchange int
bingoBonus int

// For top N only:
topNPlays []*move.Move
Expand All @@ -120,7 +119,7 @@ type GordonGenerator struct {

// NewGordonGenerator returns a Gordon move generator.
func NewGordonGenerator(gd gaddag.WordGraph, board *board.GameBoard,
ld *tilemapping.LetterDistribution, bingoBonus int) *GordonGenerator {
ld *tilemapping.LetterDistribution) *GordonGenerator {

gen := &GordonGenerator{
gaddag: gd.(*kwg.KWG),
Expand All @@ -136,7 +135,6 @@ func NewGordonGenerator(gd gaddag.WordGraph, board *board.GameBoard,
placeholder: new(move.Move),
maxTileUsage: 100, // basically unlimited
maxCanExchange: game.DefaultExchangeLimit,
bingoBonus: bingoBonus,
}
return gen
}
Expand Down Expand Up @@ -396,7 +394,7 @@ func (gen *GordonGenerator) goOn(curCol int, L tilemapping.MachineLetter,
leftstrip, rightstrip int, uniquePlay bool, baseScore, crossScores, wordMultiplier int) {
var bingoBonus int
if gen.tilesPlayed == game.RackTileLimit {
bingoBonus = gen.bingoBonus
bingoBonus = 50
}
if curCol <= gen.curAnchorCol {
if gen.board.HasLetter(gen.curRowIdx, curCol) {
Expand Down Expand Up @@ -484,7 +482,7 @@ func (gen *GordonGenerator) crossDirection() board.BoardDirection {

func (gen *GordonGenerator) scoreMove(word tilemapping.MachineWord, row, col, tilesPlayed int) int {

return gen.board.ScoreWord(word, row, col, tilesPlayed, gen.crossDirection(), gen.letterDistribution, gen.bingoBonus)
return gen.board.ScoreWord(word, row, col, tilesPlayed, gen.crossDirection(), gen.letterDistribution)
}

// Plays returns the generator's generated plays.
Expand Down
Loading