From 380a1d8f4e977298e7d046b66ee874d1738b8672 Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Tue, 13 Sep 2022 20:40:35 +0200 Subject: add local development doc page --- web/pw-server/src/routes/docs/__layout.svelte | 2 + web/pw-server/src/routes/docs/doc.svelte | 6 +++ web/pw-server/src/routes/docs/local-development.md | 49 ++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 web/pw-server/src/routes/docs/local-development.md (limited to 'web/pw-server/src/routes/docs') diff --git a/web/pw-server/src/routes/docs/__layout.svelte b/web/pw-server/src/routes/docs/__layout.svelte index 40c4317..eaf363a 100644 --- a/web/pw-server/src/routes/docs/__layout.svelte +++ b/web/pw-server/src/routes/docs/__layout.svelte @@ -8,6 +8,7 @@

Docs

@@ -25,6 +26,7 @@ display: flex; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; + flex-grow: 1; } .sidebar { diff --git a/web/pw-server/src/routes/docs/doc.svelte b/web/pw-server/src/routes/docs/doc.svelte index 00431b3..ed08270 100644 --- a/web/pw-server/src/routes/docs/doc.svelte +++ b/web/pw-server/src/routes/docs/doc.svelte @@ -3,7 +3,13 @@ diff --git a/web/pw-server/src/routes/docs/local-development.md b/web/pw-server/src/routes/docs/local-development.md new file mode 100644 index 0000000..0a2c0e3 --- /dev/null +++ b/web/pw-server/src/routes/docs/local-development.md @@ -0,0 +1,49 @@ +## Local development + +Besides using the web editor, it is also possible to develop a bot in your own development environment. +Using the `planetwars-client` you can play test matches remotely, with your bot running on your computer. +You can then submit your bot to the server as a docker container. + +### Playing matches with a local bot + +You can use the `planetwars-client` to play matches locally. + +Currently, no binaries are available, so you'll have to build the client from source. + +#### Building the binary +If you do not have a rust compiler installed already, obtain one through https://rustup.rs/. +1. Clone the repository: + `git clone https://github.com/iasoon/planetwars.dev.git` +2. Build and install the client: + `cargo install --path planetwars.dev/planetwars-client` + +#### Create a bot config +The bot config file specifies how to run your bot. Create a file `mybot.toml` with contents like so: + +```toml +# Comand to run when starting the bot. +# Argv style also supported: ["python", "simplebot.py"] +command = "python simplebot.py" + +# Directory in which to run the command. +# It is recommended to use an absolute path here. +working_directory = "/home/user/simplebot" +``` + +#### Playing a match +Run `planetwars-client /path/to/mybot.toml opponent_name` + +Try `planetwars-client --help` for more options. + + +### Publishing your bot as a docker container +Once you are happy with your bot, you can push it to the planetwars server as a docker container. + +1. **Create a bot.** + Before you can publish a new bot version, you will first need a registered bot name. + You can use an existing name, or you can create one by using the "New bot" button on your user profile page (you can get there by clicking your name in the navbar). +2. Log in to the planetwars docker registry: + `docker login registry.planetwars.dev` +3. Tag and push your bot to `registry.planetwars.dev/my-bot-name:latest`. +4. Your bot should be up and running now! Feel free to launch a game against it to test whether all is working well. + Shortly, your bot should show up in the rankings. -- cgit v1.2.3