You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
776 B
42 lines
776 B
var inputsValue = 0 |
|
|
|
fun onLoad { |
|
snackBar("Script loaded", "Start", start) |
|
} |
|
|
|
fun getFunctions { |
|
return ["start", "random"] |
|
} |
|
|
|
fun start { |
|
inputsValue = 0 |
|
simSetPartiallySimulating(false) |
|
simRestart() |
|
tick() |
|
} |
|
|
|
fun tick { |
|
final inputs = getInputs() |
|
final inputsLength = inputs.length |
|
|
|
simSetInputsBinary(inputsValue) |
|
inputsValue += 1 |
|
|
|
if (inputsValue >= Math.pow(2, inputsLength)) { |
|
inputsValue = 0 |
|
snackBar("Finished going through all possible values", "Restart", () { |
|
start() |
|
}) |
|
} |
|
else { |
|
setTimeout(1000, tick) |
|
} |
|
} |
|
|
|
fun random { |
|
final inputs = getInputs() |
|
final inputsLength = inputs.length |
|
|
|
simSetInputsBinary(Math.randomInt(Math.pow(2, inputsLength))) |
|
} |
|
|
|
|