- Add ZoneBounds type to bot state structs (Go, Rust, TypeScript) - GathererBot now moves toward zone center when outside or near edge - Bots can see zone bounds in fog-filtered state (per plan §3.7.1) - Fixes gofmt formatting in types.go and bot_strategies.go This improves bot survival and combat behavior by making them zone-aware, preventing unnecessary zone deaths when the safe area shrinks. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
80 lines
1.7 KiB
Go
80 lines
1.7 KiB
Go
package main
|
|
|
|
import "encoding/json"
|
|
|
|
// Position represents a coordinate on the grid.
|
|
type Position struct {
|
|
Row int `json:"row"`
|
|
Col int `json:"col"`
|
|
}
|
|
|
|
// Direction represents a movement direction.
|
|
type Direction int
|
|
|
|
const (
|
|
DirNone Direction = iota
|
|
DirN
|
|
DirE
|
|
DirS
|
|
DirW
|
|
)
|
|
|
|
// String returns the string representation of a direction.
|
|
func (d Direction) String() string {
|
|
switch d {
|
|
case DirN:
|
|
return "N"
|
|
case DirE:
|
|
return "E"
|
|
case DirS:
|
|
return "S"
|
|
case DirW:
|
|
return "W"
|
|
default:
|
|
return ""
|
|
}
|
|
}
|
|
|
|
// MarshalJSON serializes Direction as a string.
|
|
func (d Direction) MarshalJSON() ([]byte, error) {
|
|
return json.Marshal(d.String())
|
|
}
|
|
|
|
// VisibleBot represents a bot visible to this player.
|
|
type VisibleBot struct {
|
|
Position Position `json:"position"`
|
|
Owner int `json:"owner"`
|
|
}
|
|
|
|
// VisibleCore represents a core visible to this player.
|
|
type VisibleCore struct {
|
|
Position Position `json:"position"`
|
|
Owner int `json:"owner"`
|
|
Active bool `json:"active"`
|
|
}
|
|
|
|
// You contains information about the current player.
|
|
type You struct {
|
|
ID int `json:"id"`
|
|
Energy int `json:"energy"`
|
|
Score int `json:"score"`
|
|
}
|
|
|
|
// VisibleState represents the fog-filtered game state visible to this player.
|
|
type VisibleState struct {
|
|
MatchID string `json:"match_id"`
|
|
Turn int `json:"turn"`
|
|
Config map[string]any `json:"config"`
|
|
You You `json:"you"`
|
|
Bots []VisibleBot `json:"bots"`
|
|
Energy []Position `json:"energy"`
|
|
Cores []VisibleCore `json:"cores"`
|
|
Walls []Position `json:"walls"`
|
|
Dead []VisibleBot `json:"dead"`
|
|
}
|
|
|
|
// Move represents a bot's movement order.
|
|
type Move struct {
|
|
Position Position `json:"position"`
|
|
Direction Direction `json:"direction"`
|
|
}
|