• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mlange-42 / arche-model / 4731229459

18 Apr 2023 10:20AM CUT coverage: 96.368% (+0.2%) from 96.144%
4731229459

push

github

GitHub
Single grid coords & MatrixToGrid observer (#38)

24 of 24 new or added lines in 1 file covered. (100.0%)

398 of 413 relevant lines covered (96.37%)

127.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/system/callback_termination.go
1
package system
2

3
import (
4
        "github.com/mlange-42/arche-model/resource"
5
        "github.com/mlange-42/arche/ecs"
6
        "github.com/mlange-42/arche/generic"
7
)
8

9
// CallbackTermination system.
10
//
11
// Terminates a model run according to the return value of a callback function.
12
//
13
// Expects a resource of type [model.Termination].
14
type CallbackTermination struct {
15
        Callback func(t int64) bool // The callback. ends the simulation when it returns true.
16
        termRes  generic.Resource[resource.Termination]
17
        step     int64
18
}
19

20
// Initialize the system
21
func (s *CallbackTermination) Initialize(w *ecs.World) {
2✔
22
        s.termRes = generic.NewResource[resource.Termination](w)
2✔
23
        s.step = 0
2✔
24
}
2✔
25

26
// Update the system
27
func (s *CallbackTermination) Update(w *ecs.World) {
200✔
28
        term := s.termRes.Get()
200✔
29

200✔
30
        if s.Callback(s.step) {
202✔
31
                term.Terminate = true
2✔
32
        }
2✔
33
        s.step++
200✔
34
}
35

36
// Finalize the system
37
func (s *CallbackTermination) Finalize(w *ecs.World) {}
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc