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 🙏

© 2025 – Pkg Stats / Ryan Hefner

alphazorua

v0.1.1

Published

Pokemon battle engine powered by minimax search

Readme

AlphaZorua

Pokemon engine

Installation

# Using bun
bun add alphazorua

# Using yarn
yarn add alphazorua

# Using npm
npm install alphazorua

Usage

import { bestMove } from 'magikarp'

const result = await bestMove(battle, {
    maxDepth: 4,
    verbose: true,
})

Optimizations

The engine uses several optimizations to improve search speed and decision quality:

Core Search Optimizations

  1. Alpha-Beta Pruning

    • Prunes branches that can't affect the final decision
    • Significantly reduces the number of positions evaluated
    • Implemented in the minimax search function
  2. Move Ordering

    • Orders moves by likely strength to improve pruning
    • Considers:
      • Base power
      • Type effectiveness
      • STAB bonus
      • Terastallize bonus
      • Priority moves
      • Status move value
      • Switch position quality

Caching Optimizations

  1. Type Effectiveness Cache

    • Caches type effectiveness calculations
    • Avoids recalculating common type matchups
  2. Battle State Cache

    • Caches battle states using HP percentages
    • Reduces clone operations for similar positions
  3. Transposition Table

    • Stores search results for previously seen positions
    • Reuses results when encountering similar positions
    • Includes depth and bound information
  4. Evaluation Cache

    • Caches evaluation results for leaf nodes
    • Avoids recalculating static evaluations

Learning Optimizations

  1. History Heuristic
    • Learns from successful/unsuccessful moves
    • Improves move ordering based on search history
    • Adapts to effective moves during gameplay

Parallel Search Optimizations

  1. Lazy SMP (Symmetric Multi-Processing)
    • Runs multiple searches in parallel with offset search windows
    • Each thread explores different parts of the tree
    • Simple but effective parallelization strategy
    • Used by chess engines like Stockfish

Performance Impact

Most impactful optimizations:

  1. Move Ordering (major improvement)
  2. Alpha-Beta Pruning (major improvement)
  3. Evaluation Caching (noticeable improvement)
  4. History Heuristic (helps move ordering)

Other optimizations had smaller impacts but help in specific situations.

To install dependencies:

bun install

To run:

bun run index.ts

This project was created using bun init in bun v1.2.3. Bun is a fast all-in-one JavaScript runtime.

TODO List

  • [x] Alpha-Beta Pruning
    • Accuracy: No loss
    • Speed: ~10-20% faster
  • [x] Move Ordering (base implementation)
    • Accuracy: No loss
    • Speed: ~10-20% faster
  • [x] Type Effectiveness Cache
    • Accuracy: No loss
    • Speed: ~5-10% faster
  • [x] Battle State Cache
    • Accuracy: No loss
    • Speed: ~5-10% faster
  • [x] Transposition Table
    • Accuracy: No loss
    • Speed: ~5-10% faster
  • [x] Evaluation Cache
    • Accuracy: No loss
    • Speed: ~10-15% faster
  • [x] History Heuristic
    • Accuracy: No loss
    • Speed: ~5-10% faster
  • [x] Lazy SMP (parallel search)
    • Accuracy: No loss
    • Speed: No significant improvement (JS limitations)
  • [x] Progressive Deepening
    • Accuracy: No loss
    • Speed: ~40-50% faster
    • Benefits:
      • Always returns a move within time limit
      • Better move ordering from previous depths
      • Earlier depths guide deeper searches
  • [ ] Move Limiting at Deep Depths
    • Accuracy: Small loss at deep positions
    • Speed: ~40-60% faster
  • [ ] Quiescence Search
    • Accuracy: Better in tactical positions
    • Speed: ~10-20% slower
  • [ ] Late Move Reduction
    • Accuracy: Small loss in some positions
    • Speed: ~30-40% faster
  • [ ] Null Move Pruning
    • Accuracy: Small loss in zugzwang positions
    • Speed: ~20-30% faster
  • [ ] Static Exchange Evaluation
    • Accuracy: No loss
    • Speed: ~5-10% faster
  • [ ] Principal Variation Search
    • Accuracy: No loss
    • Speed: ~10-20% faster
  • [ ] Futility Pruning
    • Accuracy: Small loss in deep positions
    • Speed: ~20-30% faster