A proof of concept for controlling a Minecraft Non-Player Characters using OpenAI and GPT-3.
- Clone this project on your local machine.
- Minecraft (Java Edition) version 1.17
- Node.js version 14+
- An OpenAI account
- Create a
.env
file and copy your OpenAI API key and save it
CODEX_API_KEY=<your_api_key>
https://slides.com/wassimchegham/playing-minecraft-artificial-intelligence-open-ai-gpt-3-javascript
Here is how to start the Minecraft server:
- Choose a host computer. This computer should be fast enough to play Minecraft, while running a server for other players as well.
- Launch the game and click Single Player.
- Create a new world or open an existing one.
- Inside that world, press the Esc key, and click Open to LAN.
- Choose a game mode to set for the other players.
- Choose Creative mode that allows you to fly and place an infinite number of blocks.
- Click Start LAN World, and you'll see a message that a local game has been hosted.
- Take note of the port number.
From your terminal, run the following commands:
npm install
npm start -- --port [PORT]
In a few seconds, you should see a message that the bot is running, and you should see the NPC pop up in Minecraft.
Inside the Minecraft client, press the T
key to open the chat box.
There are mulptiple supported contexts:
empty
: An empty context (default).simple
: A basic context.advanced
: A more complex context.
To load a context, type load context [context_name]
.
You can also reset the current context by typing reset context
.
This is a proof of concept. It is not intended to be used in production.
If you are using WSL, you may need to provide the host computer's IP address to the bot.
npm start -- --port [PORT] --host [HOST]
To get the IP address of your host computer, run the following command:
wsl.exe hostname -I