Compact definition formats
This commit is contained in:
@@ -2,15 +2,11 @@ global_memory_size: 1
|
||||
function_memory_size: 1
|
||||
instruction_limit: 2
|
||||
samples:
|
||||
- global_memory_inputs:
|
||||
0: 0
|
||||
global_memory_outputs:
|
||||
0: 1
|
||||
- global_memory_inputs:
|
||||
0: 1
|
||||
global_memory_outputs:
|
||||
0: 2
|
||||
- global_memory_inputs:
|
||||
0: 100
|
||||
global_memory_outputs:
|
||||
0: 101
|
||||
- in: [0]
|
||||
out: [1]
|
||||
|
||||
- in: [1]
|
||||
out: [2]
|
||||
|
||||
- in: [100]
|
||||
out: [101]
|
||||
|
||||
@@ -2,19 +2,14 @@ global_memory_size: 1
|
||||
function_memory_size: 1
|
||||
instruction_limit: 2
|
||||
samples:
|
||||
- global_memory_inputs:
|
||||
0: 0
|
||||
global_memory_outputs:
|
||||
0: 0
|
||||
- global_memory_inputs:
|
||||
0: 1
|
||||
global_memory_outputs:
|
||||
0: 5
|
||||
- global_memory_inputs:
|
||||
0: 2
|
||||
global_memory_outputs:
|
||||
0: 10
|
||||
- global_memory_inputs:
|
||||
0: 100
|
||||
global_memory_outputs:
|
||||
0: 500
|
||||
- in: [0]
|
||||
out: [0]
|
||||
|
||||
- in: [1]
|
||||
out: [5]
|
||||
|
||||
- in: [2]
|
||||
out: [10]
|
||||
|
||||
- in: [100]
|
||||
out: [500]
|
||||
|
||||
@@ -2,19 +2,14 @@ global_memory_size: 1
|
||||
function_memory_size: 1
|
||||
instruction_limit: 2
|
||||
samples:
|
||||
- global_memory_inputs:
|
||||
0: 0
|
||||
global_memory_outputs:
|
||||
0: 0
|
||||
- global_memory_inputs:
|
||||
0: 1
|
||||
global_memory_outputs:
|
||||
0: 4
|
||||
- global_memory_inputs:
|
||||
0: 2
|
||||
global_memory_outputs:
|
||||
0: 8
|
||||
- global_memory_inputs:
|
||||
0: 100
|
||||
global_memory_outputs:
|
||||
0: 400
|
||||
- in: [0]
|
||||
out: [0]
|
||||
|
||||
- in: [1]
|
||||
out: [4]
|
||||
|
||||
- in: [2]
|
||||
out: [8]
|
||||
|
||||
- in: [100]
|
||||
out: [400]
|
||||
|
||||
@@ -2,19 +2,14 @@ global_memory_size: 1
|
||||
function_memory_size: 1
|
||||
instruction_limit: 2
|
||||
samples:
|
||||
- global_memory_inputs:
|
||||
0: 0
|
||||
global_memory_outputs:
|
||||
0: 0
|
||||
- global_memory_inputs:
|
||||
0: 1
|
||||
global_memory_outputs:
|
||||
0: 2
|
||||
- global_memory_inputs:
|
||||
0: 2
|
||||
global_memory_outputs:
|
||||
0: 4
|
||||
- global_memory_inputs:
|
||||
0: 100
|
||||
global_memory_outputs:
|
||||
0: 200
|
||||
- in: [0]
|
||||
out: [0]
|
||||
|
||||
- in: [1]
|
||||
out: [2]
|
||||
|
||||
- in: [2]
|
||||
out: [4]
|
||||
|
||||
- in: [100]
|
||||
out: [200]
|
||||
|
||||
@@ -3,19 +3,19 @@ package grow
|
||||
import "github.com/firestuff/subcoding/vm"
|
||||
|
||||
type Sample struct {
|
||||
GlobalMemoryInputs map[uint64]uint64 `yaml:"global_memory_inputs"`
|
||||
GlobalMemoryOutputs map[uint64]uint64 `yaml:"global_memory_outputs"`
|
||||
In []uint64 `yaml:"in,flow"`
|
||||
Out []uint64 `yaml:"out,flow"`
|
||||
}
|
||||
|
||||
func (s *Sample) SetInputs(state *vm.State) {
|
||||
for i, val := range s.GlobalMemoryInputs {
|
||||
state.GlobalMemory().WriteUnsigned(i, val)
|
||||
for i, val := range s.In {
|
||||
state.GlobalMemory().WriteUnsigned(uint64(i), val)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Sample) OutputsMatch(state *vm.State) bool {
|
||||
for i, val := range s.GlobalMemoryOutputs {
|
||||
if state.GlobalMemory().MustReadUnsigned(i) != val {
|
||||
for i, val := range s.Out {
|
||||
if state.GlobalMemory().MustReadUnsigned(uint64(i)) != val {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user