xonecas.io
6119
My

mysis / commit 3699359

feat: optimize autoplay timing based on database analysis

- Add timing constants to internal/constants/constants.go
- Reduce autoplay interval from 200s to 100s (10 avg tool calls × 10s/tick)
- Database analysis shows actual average is ~3 tool calls per turn
- Using 10 for safety margin while being 2x more responsive
- Make interval configurable via AvgToolCallsPerTurn constant
- Clean up Makefile trailing whitespace

xonecas2026-02-10 369935965a49d60cc4e46281c2724b0275d837db parent 2c0bac1

3 files changed

Makefile+0−2
@@ -27,5 +27,3 @@ test:
2727
2828 clean:
2929 rm -rf bin/ coverage.out
30-
31-
cmd/mysis/main.go+7−6
@@ -15,6 +15,7 @@ import (
1515 "github.com/rs/zerolog"
1616 "github.com/rs/zerolog/log"
1717 "github.com/xonecas/mysis/internal/config"
18+ "github.com/xonecas/mysis/internal/constants"
1819 "github.com/xonecas/mysis/internal/mcp"
1920 "github.com/xonecas/mysis/internal/provider"
2021 "github.com/xonecas/mysis/internal/store"
@@ -635,7 +636,10 @@ func (app *App) handleAutoplayCommand(ctx context.Context, input string) error {
635636 app.mu.Unlock()
636637
637638 fmt.Println(styles.Secondary.Render(fmt.Sprintf("Autoplay started: \"%s\"", message)))
638- fmt.Println(styles.Muted.Render("Interval: 200s (20 tool rounds × 10s/tick)"))
639+ fmt.Println(styles.Muted.Render(fmt.Sprintf("Interval: %ds (%d avg tool calls × %ds/tick)",
640+ int(constants.AutoplayInterval.Seconds()),
641+ constants.AvgToolCallsPerTurn,
642+ int(constants.GameTickDuration.Seconds()))))
639643 fmt.Println(styles.Muted.Render("Type '/autoplay stop' to stop"))
640644
641645 // Start autoplay loop in background
@@ -644,13 +648,10 @@ func (app *App) handleAutoplayCommand(ctx context.Context, input string) error {
644648 return nil
645649 }
646650
647-// runAutoplay sends the autoplay message every 200 seconds (20 tool rounds × 10s/tick)
651+// runAutoplay sends the autoplay message at intervals based on expected tool call duration.
648652 func (app *App) runAutoplay(ctx context.Context) {
649653 log.Debug().Msg("Autoplay goroutine started")
650654
651- // maxToolRounds (20) × game tick time (10s) = 200 seconds
652- const autoplayInterval = 200 * time.Second
653-
654655 defer func() {
655656 app.mu.Lock()
656657 app.autoplayEnabled = false
@@ -669,7 +670,7 @@ func (app *App) runAutoplay(ctx context.Context) {
669670 log.Debug().Msg("First autoplay message sent successfully")
670671
671672 // Then wait and send subsequent messages
672- ticker := time.NewTicker(autoplayInterval)
673+ ticker := time.NewTicker(constants.AutoplayInterval)
673674 defer ticker.Stop()
674675
675676 for {
internal/constants/constants.go+11−0
@@ -15,4 +15,15 @@ const (
1515 const (
1616 // DefaultTimeout is the default timeout for operations.
1717 DefaultTimeout = 30 * time.Second
18+
19+ // GameTickDuration is the SpaceMolt game server tick duration.
20+ GameTickDuration = 10 * time.Second
21+
22+ // AvgToolCallsPerTurn is the expected average tool calls per turn for autoplay timing.
23+ // Database analysis shows actual average is ~3, but we use 10 for safety margin.
24+ AvgToolCallsPerTurn = 10
25+
26+ // AutoplayInterval is the interval between autoplay turns.
27+ // Calculated as: AvgToolCallsPerTurn × GameTickDuration
28+ AutoplayInterval = AvgToolCallsPerTurn * GameTickDuration
1829 )