Skip to content

Commit

Permalink
Merge pull request #88 from MaxKev1n/v3
Browse files Browse the repository at this point in the history
fix the bug that larger simulations are not deterministic
  • Loading branch information
syifan authored Mar 13, 2024
2 parents 837e1dc + dd451df commit 11d3f6c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions sim/portowner.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package sim
import (
"fmt"
"os"
"sort"
)

// A PortOwner is an element that can communicate with others through ports.
Expand Down Expand Up @@ -54,10 +55,18 @@ func (po PortOwnerBase) GetPortByName(name string) Port {

// Ports returns a slices of all the ports owned by the PortOwner.
func (po PortOwnerBase) Ports() []Port {
portList := make([]string, 0, len(po.ports))

for k := range po.ports {
portList = append(portList, k)
}

sort.Strings(portList)

list := make([]Port, 0, len(po.ports))

for _, p := range po.ports {
list = append(list, p)
for _, port := range portList {
list = append(list, po.ports[port])
}

return list
Expand Down

0 comments on commit 11d3f6c

Please sign in to comment.