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

global-azure-2021-battleship

v1.0.2

Published

This is a helper library for the Battleship coding contest at Global Azure Austria 2021

Downloads

11

Readme

Global Azure Austria 2021 - Battleship coding contest

DESCRIPTION

Installation

Just run this command:

npm install --save global-azure-2021-battleship

And add these two scripts to your package.json:

"scripts": {
  "start": "gaa-battleship start dist/index.js",
  "test": "gaa-battleship test dist/index.js"
}

The package is written for use with TypeScript, so in these scripts the compiled files are specified. If you don't use TypeScript, you can change the paths to match your file.

Usage

The file must export a class derived from the base player class provided in this package. It looks like this:

import { Player } from "global-azure-2021-battleship";

export = class CoolPlayer extends Player {
    // it is possible to store custom state here

    getNextShot() {
        return Math.floor(Math.random() * 100); // don't do this!!! only an example
    }
    registerShotContent(cell: Cell) { // optional
        // do something
    }
};

You have the last shot and the board also stored in the player.


The scripts are made to run and test the players. With start you start an express server according to the specification with default port 8012, but by setting the env variable PORT or passing a second argument you can specify another port like this:

"start": "gaa-battleship start dist/index.js 1234"
// or
"start": "PORT=1234 gaa-battleship start dist/index.js"

The test script will run the player locally 500 times and calculate the average shots until all boats are sunken. You can also specify the amount of games:

"test": "gaa-battleship test dist/index.js 50"

If you get the error ERROR SHOULD NEVER HAPPEN board to full try again, that is a rare case in one of a few thousand games that the board filling didn't work. Just ignore it and try again.

There will possibly be an interactive version in Global Azure Austria 2022 :-)

Licence

This project is licenced under the MIT licence. Read it here.