package soko type Entity struct { ID int Pos int Typ EntityType } type Entities []Entity func (e Entities) ByID(id int) Entity { idx := e.IdxById(id) if idx == -1 { return Entity{ID: -1} } return e[idx] } func (e Entities) Clone() Entities { clone := make(Entities, len(e)) copy(clone, e) return clone } func (e Entities) IdxById(id int) int { for i, e := range e { if e.ID == id { return i } } return -1 } type Ints []int func NewInts(n int) Ints { ids := make(Ints, n) for i := range ids { ids[i] = -1 } return ids } func (e Ints) Clone() Ints { clone := make(Ints, len(e)) copy(clone, e) return clone }