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

cellsforai

v0.2.1

Published

Game to be played by AI

Downloads

2

Readme

#CellsForAI

A game to be played by AI


##Rules

Different players can fight on a grid, each controling his cells.

Cells - represented by squares on that grid - have a weight and can move in either direction, stay where they are, or move in multiple directions. In case of multiple directions, they will be divided into multiple cells going in those directions, each having a weight that is the floored result of the division of the original weight.

When two cells cross or end up on the same square, merge. The one with the greatest weight absorbs the smaller ones, adding their weights to its own.

Vitamins are added and randomly placed on the grid at each turn. Those have a weight of one and can be eaten by any cell coming on their position.


##How To Play

###Install

Simply install with

	npm install cellsforia

###Start server

Your server is already good to go. Just start it with

	node app.js

If you want to have the server running continuously, you probably should check for the forever package and do :

	npm forever install
	forever start app.js

###Change domain

By default the server runs on localhost:3000; If you wanna change that to make it accesible over the internet, you'd need to change the domain constant in script.js to you desired address and port. Change the port constant in app.js if needed.

###Communication with players

An example of a fully functional player can be found on npm as randomcellforaiplayer. You should probably download it and try it out.

Just changing the makeMove function is the way to go.

####Details

Basically the communication with the players is socket based, using _socket.io _ package

messages to be emitted by the player are of the following kind :

  • playerID : having the player's name as content. If 'default' is sent, the server will automatically attribute a name to the player.
  • move : shall contain an object of the following type (note move can be partial): {player:,move:}

messages received by the player are of the following kind :

  • playerID : having our name as data. relevant only if we sent 'default' previously as a name.

  • state : marks the beginning of a new turn and states the current position on the grid, stored as an array of cells, each being an object ressembling this :

      {	id:<id>,
      	x:<x>,
      	y:<y>,
      	player:<player's name>,
      	weight:<weight>}

The game will start as soon as the correct number of players are connected

###Watching the game

Using any modern browers, just open the chosen domain address and port. (by default, navigate to localhost:3000)

Note that a sliding pannel can be toogled to change the appearance

Of course custom view can be implemented. Just mimic the socket part of the script.js file

###Changing the room settings

On a view from a browser, access the side pannel and modify the default settings. Clicking the 'fire' button will reset the game with the desired settings.

Of course custom settings changers can be implemented. Just mimic the sidebar.js socket behavior.