GithubHelp home page GithubHelp logo

robthekilla / mineflayer-stateful Goto Github PK

View Code? Open in Web Editor NEW

This project forked from thedudefromci/mineflayer-stateful

0.0 0.0 0.0 11 KB

A copy-on-write wrapper for Mineflayer bots, to allow testing and AI mental simulations.

License: MIT License

mineflayer-stateful's Introduction

mineflayer-stateful

A copy-on-write wrapper for Mineflayer bots to allow testing and AI mental simulations.


This plugin is not ready for release.


Purpose

The purpose of this plugin is to allow developers to wrap bot actions into a simple container that allows for a low-overhead approach to testing or simulating various actions within the game. This plugin does not aim to provide an accurate world simulation (for that, you should probably try hosting an embedded server) but instead to help aid developers to get a rough idea of what kind of a set of actions would have within a world.

In terms of AI development, this plugin can allow a bot to preform a set of actions and what kind of effects it would have on the world to aid in making decisions about the correct course of action to take. This plugin uses a copy-on-write approach to saving game data in order to minimize the resource overhead and allow for instant feedback.

In terms of testing, this plugin is useful for running a small set of functions against the bot in order to see what the final outcome is. The plugin aims to cleanly wrap the stable Mineflayer API, allowing simulations to be seemless between the state object and the real bot.

Example

The statful plugin adds a new object type which wraps the Mineflayer bot cleanly in order to intercept functions being sent to the bot and redirect them to a fake state object for reading.

// Our normal bot logic code.
function runSomeLogic(bot, offset) {
  const pos = bot.player.entity.position.offset(offset, 0, 0)
  const block = bot.getBlockAt(pos)
  
  bot.dig(block, err => {
    console.log(bot.getBlockAt(pos).type) // Prints air
  })
}

// Lets create a normal Mineflayer bot
const bot = mineflayer.createBot({ username: "Stateful_Bot" })

// Running the bot normally
runSomeLogic(bot, 3)
// The bot mines the block as expected, and "air" is printed to the console.

// Running the bot in a fake world
const state = new WorldState(bot)
runSomeLogic(state, 10)
// The bot preforms no action, yet "air" is still printed to the console.

// By sampling the state, it appears that the world has been modified.
state.getBlockAt(...)

// But run the same function again on the actual bot, and the world remains unchanged.
bot.getBlockAt(...)

mineflayer-stateful's People

Contributors

thedudefromci avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.