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

xotb

v2.3.0

Published

A customizable timer API for TurboChat applications.

Downloads

268

Readme

XOTB.js Documentation

Welcome to the official documentation for XOTB.js, the ultimate API for integrating intelligent Tic Tac Toe gameplay into your applications. Whether you're developing a web-based game, a mobile app, or any other project that requires a smart Tic Tac Toe bot, XOTB.js provides a seamless and efficient solution.

Disclaimer

⚠️ Disclaimer

XOTB.js is designed for educational and recreational purposes. While it employs sophisticated algorithms to provide challenging gameplay, it should not be used for critical applications where security and fairness are paramount.

How to Use

Integrate XOTB.js into your project by following the appropriate steps based on your development environment:

1. Install via npm

If you're using XOTB.js in a Node.js project or any environment that supports npm, you can install it using the following command:

npm install xotb

2. Import XOTB.js into Your Project

After installation, import XOTB.js into your JavaScript files to start using its functionalities.

For CommonJS (Node.js):

const XOTB = require('xotb');

const bot = new XOTB('medium'); // Initialize with 'easy', 'medium', or 'hard'

// Player makes a move at position 0 (top-left corner)
bot.makeMove(0, 'X');

console.log(bot.getBoard()); // Display current board state
console.log(bot.getStatus()); // Display current game status

// Bot makes its move
const botMove = bot.getBotMove();
console.log(`Bot (O) moved at position ${botMove}`);
console.log(bot.getBoard());
console.log(bot.getStatus());

For ES Modules:

import XOTB from 'xotb';

const bot = new XOTB('hard'); // Initialize with 'easy', 'medium', or 'hard'

// Player makes a move at position 4 (center)
bot.makeMove(4, 'X');

console.log(bot.getBoard()); // Display current board state
console.log(bot.getStatus()); // Display current game status

// Bot makes its move
const botMove = bot.getBotMove();
console.log(`Bot (O) moved at position ${botMove}`);
console.log(bot.getBoard());
console.log(bot.getStatus());

Using XOTB.js in Browser with Module Bundlers

If you're using module bundlers like Webpack or Parcel, you can import XOTB.js as follows:

// Import XOTB.js
import XOTB from 'xotb';

// Initialize the bot with desired difficulty
const bot = new XOTB('easy');

// Player makes a move at position 2 (top-right corner)
bot.makeMove(2, 'X');

console.log(bot.getBoard()); // Display current board state
console.log(bot.getStatus()); // Display current game status

// Bot makes its move
const botMove = bot.getBotMove();
console.log(`Bot (O) moved at position ${botMove}`);
console.log(bot.getBoard());
console.log(bot.getStatus());

3. Using XOTB.js Directly in Web Projects

If you're developing a TurboChat application and prefer to include XOTB.js directly without a module bundler, you can reference the local xotb.js file.

<script src="xotb.js"></script>

Once included, utilize the XOTB class as shown below:

<script>
    const bot = new XOTB('medium'); // Initialize with 'easy', 'medium', or 'hard'

    // Player makes a move at position 6 (bottom-left corner)
    bot.makeMove(6, 'X');
    console.log(bot.getBoard()); // Display current board state
    console.log(bot.getStatus()); // Display current game status

    // Bot makes its move
    const botMove = bot.getBotMove();
    console.log(`Bot (O) moved at position ${botMove}`);
    console.log(bot.getBoard());
    console.log(bot.getStatus());
</script>

API Reference

  • constructor(difficulty): Initializes a new instance of XOTB.js with the specified difficulty.
  • resetGame(): Resets the game state to start a new game.
  • setDifficulty(level): Sets the difficulty level of the bot. Acceptable values are 'easy', 'medium', and 'hard'.
  • makeMove(index, player): Makes a move for the specified player ('X' or 'O') at the given board index (0-8).
  • getBotMove(): Calculates and makes the bot's move based on the current difficulty level. Returns the index where the bot moved.
  • getStatus(): Retrieves the current status of the game (e.g., "Player X wins!", "Bot O wins!", "It's a draw!", "Current turn: Player X").
  • getBoard(): Returns a copy of the current board state as an array.

Parameters:

  • difficulty: string - The difficulty level for the bot. Acceptable values are 'easy', 'medium', and 'hard'.
  • index: number - The board position index (0-8) where the player wants to make a move.
  • player: string - The player symbol, either 'X' for the human player or 'O' for the bot.

Returns:

  • getBotMove: number - The index where the bot made its move.
  • getStatus: string - The current status of the game.
  • getBoard: array - A copy of the current board state.

Example Code

1. Basic Game Flow

const XOTB = require('xotb'); // For CommonJS

const bot = new XOTB('medium'); // Initialize with 'easy', 'medium', or 'hard'

// Player X makes a move at position 0
bot.makeMove(0, 'X');
console.log(bot.getBoard()); // ['X', '', '', '', '', '', '', '', '']
console.log(bot.getStatus()); // 'Current turn: Player O'

// Bot O makes its move
const botMove = bot.getBotMove();
console.log(`Bot (O) moved at position ${botMove}`);
console.log(bot.getBoard()); // Updated board with bot's move
console.log(bot.getStatus()); // 'Current turn: Player X'

2. Resetting the Game

const bot = new XOTB('hard');

// Player X makes a move
bot.makeMove(4, 'X');

// Bot O makes a move
bot.getBotMove();

// Reset the game
bot.resetGame();
console.log(bot.getBoard()); // ['','','','','','','','','']
console.log(bot.getStatus()); // 'Current turn: Player X'

3. Changing Difficulty Mid-Game

const bot = new XOTB('easy');

// Player X makes a move
bot.makeMove(2, 'X');

// Change difficulty to 'hard'
bot.setDifficulty('hard');

// Bot O makes its move based on new difficulty
const botMove = bot.getBotMove();
console.log(`Bot (O) moved at position ${botMove}`);