npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pmars-ts

v1.0.0

Published

TypeScript port of pmars (portable Memory Array Redcode Simulator) for Corewar

Readme

pmars-ts

TypeScript port of pMARS (portable Memory Array Redcode Simulator) for Core War. Faithfully replicates the behavior of the original C implementation.

Installation

npm install pmars-ts

Quick Start

Direct API

import { Assembler, Simulator } from 'pmars-ts';

const asm = new Assembler();
const imp = asm.assemble(';redcode\n;name Imp\nMOV.I $0, $1');
const dwarf = asm.assemble(';redcode\n;name Dwarf\nADD.AB #4, $3\nMOV.I $2, @2\nJMP $-2, $0\nDAT.F #0, #0');

const sim = new Simulator({ coreSize: 8000, maxCycles: 80000 });
sim.loadWarriors([imp.warrior!, dwarf.warrior!]);
const results = sim.run();

console.log(results[0].outcome, results[0].winnerId);

API Reference

Assembler

const asm = new Assembler(options?);
const result = asm.assemble(source);
// result.success, result.warrior, result.messages

Simulator

const sim = new Simulator(options?);
sim.loadWarriors([warrior1, warrior2]);
const results = sim.run(rounds?);     // Run all rounds
sim.setupRound();                      // Manual round setup
const stepResult = sim.step();         // Step one instruction

Simulator Options

| Option | Default | Description | |---|---|---| | coreSize | 8000 | Size of the core memory array | | maxCycles | 80000 | Maximum cycles per round | | maxLength | 100 | Maximum warrior length | | maxProcesses | 8000 | Maximum processes per warrior | | minSeparation | 100 | Minimum distance between warriors | | rounds | 1 | Number of rounds to simulate |

Features

  • All 19 ICWS'94 opcodes (MOV, ADD, SUB, MUL, DIV, MOD, JMP, JMZ, JMN, DJN, CMP/SEQ, SNE, SLT, SPL, DAT, NOP, LDP, STP)
  • All 7 instruction modifiers (A, B, AB, BA, F, X, I)
  • All 8 addressing modes (#, $, @, <, >, *, {, })
  • P-space support with PIN sharing
  • In-register evaluation (ICWS'88 compliant)
  • Deterministic RNG matching pmars
  • Zero runtime dependencies
  • ESM and CommonJS dual output

Attribution

This project is a TypeScript port of pMARS (portable Memory Array Redcode Simulator), the official Redcode simulator of rec.games.corewar.

Original pMARS authors:

  • Albert Ma
  • Nandor Sieben
  • Stefan Strack
  • Mintardjo Wangsaw

Additional contributors to the original C codebase: Alex Macaulay (Mac front-end), Martin Maierhofer (X-Windows and Linux SVGA displays), Nathan Summers (VMS port), Ken Espiritu (optimized x86 sim.c), Ilmari Karonen (-P option and improvements), Joonas Pihlaja (read/write limits and improvements).

pMARS has been actively maintained with patches reviewed by John Metcalf. More information at corewar.co.uk/pmars.htm.

License

GPL-2.0 - see LICENSE for details. Matches the original pMARS license.