MlogArithmeticRunner
A Mindustry Logic emulator built for automated testing of compilers (like MlogEvo).
Install
pip install https://github.com/UMRnInside/MlogArithmeticRunner
or
pip install mlog_arithmetic_runner
Usage
$ python3 -m mlog_arithmetic_runner --help
usage: mlog_arithmetic_runner [-h] [--limit LIMIT] [--continue-if-past-the-end] [--ipt IPT]
[--memory-banks MEMORY_BANKS] [--memory-cells MEMORY_CELLS]
[--json-indent JSON_INDENT] [--json-dump-memory-blocks]
Reads some mlog code from stdin, runs it, and generates JSON report
optional arguments:
-h, --help show this help message and exit
--limit LIMIT Max instructions/cycles allowed, something like TimeLimit
--continue-if-past-the-end
--ipt IPT Instructions per tick. 2 for micro-processor, 8 for logic-processor,
25 for hyper-processor
--memory-banks MEMORY_BANKS
Memory bank count
--memory-cells MEMORY_CELLS
Memory cell count
--json-indent JSON_INDENT
JSON indent, set 0 to disable
--json-dump-memory-blocks
dump all memory content in JSON report
Supported Instructions
setjumpend- All
ops since Mindustry V7 Beta (beta 140), exceptop noise readandwritememory cells and banksgetlinkto get memory blocks (cells/banks)set @counterorop @counteras unconditional jumps
Features
@tickand@timeincreases with processor runs- Stop emulation once some instruction jumps to itself
- (Optional, Default) Stop emulation once
@counterpast the end - (Optional) Dump memory cells and banks
- Dump variables into JSON report
Limitations
- Does NOT have
@thisyet, so do@thisxand@thisy - No comment in mlog code
- (not sure)
Python Usage
from mlog_arithmetic_runner import MlogProcessor
processor = MlogProcessor(ipt=2, memory_cells=0, memory_banks=0)
code = """\
set a 90
op sin b a 0
"""
processor.assemble_code(code)
processor.run_with_limit(1000)
# When comparing 2 float-point numbers, remember there could be float precision errors.
# Use abs(a-b) < 1e-6 instead of a == b
print("a =", processor.get_variable("a"))
print("b =", processor.get_variable("b"))
JSON Report Sample
set a 1
set a 2
set b @tick
set c @time
This generates:
{
"cycles": 4,
"success": true,
"reason": "",
"variables": {
"a": 2.0,
"b": 1,
"c": 0.016666666666666666
},
"memory_blocks": {}
}
Metadata
Release files for mlog-arithmetic-runner 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mlog_arithmetic_runner-0.0.5-py3-none-any.whl | Python 3 | none | any | Details for mlog_arithmetic_runner-0.0.5-py3-none-any.whl |
Release files / mlog_arithmetic_runner-0.0.5-py3-none-any.whl
| Download URL | mlog_arithmetic_runner-0.0.5-py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
723320bb4cd1d0a9a73836d4277a1ed7428f902036b64383b120a20dda15da6f
|
|
BLAKE2b-256 checksum How to use checksums |
f0695279508d79a4c727f025a666a44ddbd270a411feac57d4d8b5bfa96124fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.2
|
Security for mlog-arithmetic-runner 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.