Skip to content

Commit 4090cb8

Browse files
committed
env.Env interface no longer specifies Action so it can be more flexible in what args it takes (in particular, taking enums instead of strings!)
1 parent a1df5d7 commit 4090cb8

File tree

7 files changed

+21
-45
lines changed

7 files changed

+21
-45
lines changed

env/env.go

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ import (
1919
//
2020
// State is comprised of one or more Elements, each of which consists of an
2121
// tensor.Values chunk of values that can be obtained by the model.
22-
// Likewise, Actions can also have Elements. The Step method is the main
23-
// interface for advancing the Env state.
22+
// The Step method advances the Env state.
2423
//
2524
// The standard String() string fmt.Stringer method must be defined to return
2625
// a string description of the current environment state, e.g., as a TrialName.
@@ -35,11 +34,10 @@ type Env interface {
3534
labels.Labeler
3635

3736
// Init initializes the environment for a given run of the model.
38-
// The environment may not care about the run number, but may implement
39-
// different parameterizations for different runs (e.g., between-subject
40-
// manipulations). In general the Env can expect that the model will likely
41-
// have established a different random seed per run, prior to calling this
42-
// method, and that may be sufficient to enable different run-level behavior.
37+
// It is best if the Env has its own random seed and random sequence
38+
// generator (e.g., lab/randx), and sets a new random seed for each run.
39+
// It may also implement different parameterizations for different runs
40+
// (e.g., between-subject manipulations).
4341
// See Step() for important info about state of env after Init
4442
// but prior to first Step() call.
4543
Init(run int)
@@ -51,13 +49,13 @@ type Env interface {
5149
// If there are no further inputs available, it returns false (most envs
5250
// typically only return true and just continue running as long as needed).
5351
//
54-
// The Env thus always reflects the *current* state of things, and this
52+
// The Env thus always reflects the _current_ state of things, and this
5553
// call increments that current state, such that subsequent calls to
5654
// State() will return this current state.
5755
//
5856
// This implies that the state just after Init and prior to first Step
59-
// call should be an *initialized* state that then allows the first Step
60-
// call to establish the proper *first* state. Typically this means that
57+
// call should be an _initialized_ state that then allows the first Step
58+
// call to establish the proper _first_ state. Typically this means that
6159
// one or more counters will be set to -1 during Init and then get incremented
6260
// to 0 on the first Step call.
6361
Step() bool
@@ -68,9 +66,7 @@ type Env interface {
6866
// The returned tensor must be treated as read-only as it likely points to original
6967
// source data: please make a copy before modifying (e.g., Clone() methdod).
7068
State(element string) tensor.Values
71-
72-
// Action sends tensor data about e.g., responses from model back to act
73-
// on the environment and influence its subsequent evolution.
74-
// The nature and timing of this input is paradigm dependent.
75-
Action(element string, input tensor.Values)
7669
}
70+
71+
// note: Action is no longer defined in the interface so that
72+
// it can be more flexible in the types of arguments used.

env/fixed.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,5 @@ func (ft *FixedTable) State(element string) tensor.Values {
153153
return et
154154
}
155155

156-
func (ft *FixedTable) Action(element string, input tensor.Values) {
157-
// nop
158-
}
159-
160156
// Compile-time check that implements Env interface
161157
var _ Env = (*FixedTable)(nil)

env/freq.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,5 @@ func (ft *FreqTable) State(element string) tensor.Values {
181181
return et
182182
}
183183

184-
func (ft *FreqTable) Action(element string, input tensor.Values) {
185-
// nop
186-
}
187-
188184
// Compile-time check that implements Env interface
189185
var _ Env = (*FreqTable)(nil)

env/mpifixed.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,5 @@ func (ft *MPIFixedTable) State(element string) tensor.Values {
155155
return et
156156
}
157157

158-
func (ft *MPIFixedTable) Action(element string, input tensor.Values) {
159-
// nop
160-
}
161-
162158
// Compile-time check that implements Env interface
163159
var _ Env = (*MPIFixedTable)(nil)

env/typegen.go

Lines changed: 7 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.23.4
44

55
require (
66
cogentcore.org/core v0.3.13
7-
cogentcore.org/lab v0.1.3-0.20260106153658-0557c97a5cea
7+
cogentcore.org/lab v0.1.3-0.20260111225809-4f12ee287b54
88
github.com/cogentcore/yaegi v0.0.0-20250622201820-b7838bdd95eb
99
github.com/stretchr/testify v1.10.0
1010
golang.org/x/exp v0.0.0-20240823005443-9b4947da3948

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cogentcore.org/core v0.3.13 h1:+e7+SqlywIIcDQO4dP0klqaL0BBTbCjO4AXqROQtJlU=
22
cogentcore.org/core v0.3.13/go.mod h1:eDHnTCy1sBhAKN9NPsSCnBW3VAnwQBNA9nbGMo9r+Xs=
3-
cogentcore.org/lab v0.1.3-0.20260106153658-0557c97a5cea h1:9wJdzhCuC3irMJQbVDfgkXNjLtkHcc3oSwy5A67tjbM=
4-
cogentcore.org/lab v0.1.3-0.20260106153658-0557c97a5cea/go.mod h1:lDGnyvokk7YWFBxVwJJVvHxBEbZxBygmVjXichGwOhU=
3+
cogentcore.org/lab v0.1.3-0.20260111225809-4f12ee287b54 h1:afSmMH5/b1948cmPMhUYMfjga0i2qh4fq44x6UwbuJc=
4+
cogentcore.org/lab v0.1.3-0.20260111225809-4f12ee287b54/go.mod h1:lDGnyvokk7YWFBxVwJJVvHxBEbZxBygmVjXichGwOhU=
55
github.com/Bios-Marcel/wastebasket/v2 v2.0.3 h1:TkoDPcSqluhLGE+EssHu7UGmLgUEkWg7kNyHyyJ3Q9g=
66
github.com/Bios-Marcel/wastebasket/v2 v2.0.3/go.mod h1:769oPCv6eH7ugl90DYIsWwjZh4hgNmMS3Zuhe1bH6KU=
77
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=

0 commit comments

Comments
 (0)