Tiffany Souterre & Wassim Chegham
The code shared in this project is for educational purposes only.
The code is provided “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non-infringement. In no event shall We (the authors) or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the code or the use or other dealings in the code.
DEMO MAY NOT WORK!
THIS IS JUST A PROOF OF CONCEPT. DON'T USE IT IN PRODUCTION!
github.com/manekinekko
github.com/amagash
@TiffanySouterre
* We do not work nor represent GitHub!
amagash.github.io
GDE Web Technologies
WTM ambassador
DALL-E, GPT-3, GPT-2, OpenAI Gym...
Trained on Code
"jump"
Context + "jump"
bot.setControlState('jump', true)
https://github.com/manekinekko/minecraft-openai
Minecraft NPC
Minecraft Local Server
Local Agent (mineflayer)
User Commands
import mineflayer from "mineflayer";
const bot = mineflayer.createBot({
username: "OpenAI",
host: "localhost",
port: 56794,
});
bot.on("chat", async (username, input) => {
if (username === bot.username) return;
console.log(input);
});
Minecraft NPC
Minecraft Local Server
Local Agent (mineflayer)
OpenAI server
User Commands
// (previous context)
// Go forward
bot.setControlState('forward', true);
import mineflayer from "mineflayer";
import { context, callOpenAI, updateContext, eval } from "./core.js";
const bot = mineflayer.createBot({
username: "OpenAI",
host: "localhost",
port: 56794,
});
bot.on("chat", async (username, input) => {
if (username === bot.username) return;
const previousContext = context();
const response = await callOpenAI(input, previousContext);
eval(code);
updateContext(input, code);
});
// Go forward
bot.setControlState('forward', true);
// Go back
bot.setControlState('back', true);
// jump
bot.setControlState('jump', true);
// Hi how are you ?
bot.chat("I'm fine, thanks!");
// What's your name ?
bot.chat("My name is " + bot.username);
const STOP_WORD = "// ";
const EOL = "\n";
const openAIkey = process.env.CODEX_API_KEY;
const body = {
prompt: context + STOP_WORD + input + EOL,
max_tokens: 300,
temperature: 0,
stop: STOP_WORD,
n: 1,
};
const response = await fetch("https://api.openai.com/v1/engines/davinci-codex/completions", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${openAIkey}`,
},
body: JSON.stringify(body),
});
if (!response.ok) {
error("api response failed with statis %s", response.statusText);
return;
}
return await response.json();
// Get bot's current position
bot.entity.position;
// Stop any movement
bot.clearControlStates();
// Come to me
findPlayer(bot, 2, target);
// Follow me
goToPlayerInterval = setInterval(() => followPlayer(bot, 2, target), 1000);
// Stop following me
clearInterval(goToPlayerInterval);
// Get dirt
mineBlock(bot, "dirt", mcData);
// Get oak log
mineBlock(bot, "oak_log");