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

q-exp

v0.0.3

Published

Reinforcement learning (Q-Learning) library

Downloads

11

Readme

Q-EXP

https://github.com/starcolon/q-exp

Reinforcement Learning with Q-learning technique for Node.js app. It also provides policy generalisation in-built.


Installation

$ npm install q-exp

Usage

To include q-exp library to your Node.js app:

var qexp = require('q-exp');

Read the instructions all the way down to learn how to use.


Features included

To make reinforcement learning works end-to-end, we implement and include the following features.

  • Q-learning
  • Exploration-exploitation
  • Generalisation with Gradient descent
  • Sample usages (Tic-tac-toe and falling-stones)

Usage

To create an agent, load its learned policy from a physical file, then let it choose an action which it believes it would maximise the reward it would get, you may do this:

// Initialisation
var agent = ql
	.newAgent('johndoe',actionSet=['walk','run','sleep'],alpha=0.35)
	.then(ql.bindRewardMeasure( /* reward function here */ ))
	.then(ql.bindActionCostMeasure( /* action cost function here */ ))
	.then(ql.bindStateGenerator( /* state generator here */ ))
	.then(ql.load('./dir')); 

// Start!
agent.then(ql.setState(initialState)) // Let the agent know the state
	.then(ql.step) // Ask the agent to move
	.then(ql.getState) // Now let's see how the agent moved
	.then((state) => /* Do something with the state */)

Sample #1 - Tic tac toe

Tictactoe

A quick sample implementation is a classic tic-tac-toe game, source code available at /sample/tictactoe.js. This sample does not make use of generalisation, just a plain exploration-exploitation.

To play against the trained tic-tac-toe bot:

	$ cd sample
	$ node tictactoe.js play

After having your agent intensively trained for thousands games, you'll eventually find out how strong your bot has become.

To train the bot

	$ cd sample
	$ ./train-tictactoe

Sample #2 - Falling stones

Falling stones

Another classic game where two stones are falling from the top edge of the screen at random position. The player are forced to move left or right to escape from those falling stones. If a stone fall onto the player, the game is over.

This sample makes use of generalisation so it can survive longer even you train it for just ten or twenty games.

To run it:

	$ cd sample
	$ node falling-stones.js

Benchmark

After generalisation, the agent can survive slightly longer. However we just fit the reward space with linear plane which might not well fit critical cases. It doesn't guarantee convergence.

Y axis represents the number of moves it survives in a game.

Benchmark

Licence

This project is released under Apache 2.0 licence.