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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mehra/pokemon

v6.2.5

Published

I have no idea what this actually does

Downloads

4

Readme

pokemon

npm version documentation status

I still don't know what this does.

Simulates something to do with Pokemon Battle.

Installation

npm i @mehra/pokemon

If using the CLI commands and not using the abstract library, you generally want to do a global install instead:

npm i -g @mehra/pokemon

Links

Library

lib/ should have implemented most rules.

To create a player:

const Weedle = new Player(
  Players.Weedle, // The configuration for the player
  // Presets are exported from players.ts.
  true, // Whether the player is human;
  // applies different rules
  Math.random // The function to generate random numbers
  // You can build a closure to log or playback random numbers
);

To create a team:

const A = new Team(
  [Weedle], // An array of instantiated Players on the team
  Math.random // The function to generate random numbers
);

To create a game:

const game = new Game(
  A, // One of the teams
  B, // The other team
  random // The function to generate random numbers
);

To play a round (one turn for each player) of the game:

// If there is a winner, returns a boolean indicating whether team A (from constructor) is the winner.
// Otherwise, returns undefined.
game.playRound();

To finish the game until one team wins:

// Returns a boolean indicating whether team A (from constructor) is the winner.
game.play();

Weedle vs Agatha

Simulates a game that is supposedly important? Very unlikely for team A to win this game.

Teams

Simulates a game with these teams:

const A = new Team([Players.Weedle].map(createPlayer(true, random)), random);
const B = new Team(
  [
    Players.Gengar1,
    Players.Golbat,
    Players.Haunter,
    Players.Arbok,
    Players.Gengar2,
  ].map(createPlayer(false, random)),
  random
);

Usage

weedle <maxNumIterations = 1000> <progressCheckInterval = floor(maxNumIterations / 100)> <continueOnSuccess = false> <divideProgressLogByInterval = false>

Some systems require you to prefix the command with npx.

This will run up to maxNumIterations simulations, halting earlier if and only if team A wins and !continueOnSuccess.

It will log the elapsed time and current iteration (divided by progressCheckInterval if divideProgressLogByInterval) before every progressCheckInterval number of iterations; you can set progressCheckInterval = 0 to not have this happen, or to some sufficiently large number to have it occur only at step 0.

On success (team A's win), it will log and append a record to the end of the file avi.log (or create it if it does not exist). This log will include the current (not elapsed) time, the iteration at which the success occurred, and the entire sequence of random numbers in that simulation. This is sufficient information to replay the game without loss (see Playback).

Note: continueOnSuccess and divideProgressLogByInterval check for JavaScript truthiness. In particular, if "false" is entered in the command line, it will be treated as true!

Speed

Expect running time of around 9.2-9.7µs per iteration.

Production config for bashing

When bashing out simulations, I generally use

weedle Infinity 1e6 true true > run.log &

Playback

Playback any run given its sequence of random numbers:

pokemon-playback <path-to-file>

where path-to-file is the path to a requireable file which gives the array of randoms. Some systems require you to prefix the command with npx.

If omitted, path-to-file defaults to an internal constant file, namely test/fail/1.rands.json. While expected to remain for the life of the project, this should not be relied on programmatically.