-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Doing this early since we likely will want fine control over our search strategy, and assuming that the RNG is similar to last year's it was relatively straightforward to clone it in Rust (we can reuse our implementation from last year).
- Loading branch information
JesseEmond
committed
Oct 2, 2024
1 parent
9931cf7
commit 7aa519e
Showing
10 changed files
with
117 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Dev | ||
|
||
## Setup | ||
|
||
```sh | ||
cd bot | ||
python3 -m venv venv | ||
./venv/bin/pip install -r dev-requirements.txt # Note! Not requirements.txt! | ||
``` | ||
|
||
## Local bot test | ||
|
||
Because we run Rust called from Python, the command to run the program is a bit | ||
more involved. For simplicity, it is available in `run.sh`: | ||
|
||
```sh | ||
cd bot | ||
./run.sh | ||
``` | ||
|
||
This will: | ||
- Build the Rust binary with `maturin` | ||
- Install the built wheel program (force reinstall it) | ||
- Run `application.py` | ||
|
||
## Upload new version | ||
|
||
```sh | ||
cd bot | ||
./package.sh | ||
``` | ||
|
||
This will create a `devnull.zip` file. | ||
|
||
Then: | ||
- Navigate to the website | ||
- Upload `devnull.zip` | ||
- Wait for the build to complete | ||
- Run `Try us!` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[package] | ||
name = "devnull_bot" | ||
edition = "2021" | ||
version = "0.1.0" | ||
|
||
[lib] | ||
name = "devnull_bot" | ||
crate-type = ["cdylib", "rlib"] | ||
|
||
[dependencies] | ||
pyo3 = { version = "0.20.0", features = ["extension-module"] } | ||
|
||
[dev-dependencies] | ||
criterion = { version = "0.4", features = ["html_reports"] } | ||
|
||
[profile.release] | ||
debug = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Requirements that are needed for both devs and on-server. | ||
websockets==10.4 | ||
dataclasses-json==0.6.7 | ||
mcts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-r core-requirements.txt | ||
maturin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
#!/bin/sh | ||
rm devnull.zip; zip devnull.zip *.py requirements.txt | ||
set -e | ||
./venv/bin/maturin build --release | ||
rm devnull.zip; zip devnull.zip *.py core-requirements.txt \ | ||
requirements.txt ./target/wheels/*.whl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
websockets==10.4 | ||
dataclasses-json==0.6.7 | ||
mcts | ||
# Note! This is the file that runs on Blitz servers, not what devs run. | ||
# Notably, it expects a whl file for our Rust binary to already be built. | ||
# Devs: see dev-requirements.txt | ||
-r core-requirements.txt | ||
./target/wheels/devnull_bot-0.1.0-cp310-cp310-manylinux_2_34_x86_64.whl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
set -e | ||
./venv/bin/maturin build --release | ||
./venv/bin/pip install target/wheels/devnull_bot-0.1.0-cp310-cp310-manylinux_2_34_x86_64.whl --force-reinstall | ||
./venv/bin/python application.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use pyo3::prelude::*; | ||
|
||
#[pyfunction] | ||
fn hello_world() -> PyResult<u128> { | ||
println!("Hello world, from Rust!"); | ||
Ok(42) | ||
} | ||
|
||
#[pymodule] | ||
fn devnull_bot(_py: Python, m: &PyModule) -> PyResult<()> { | ||
m.add_function(wrap_pyfunction!(hello_world, m)?)?; | ||
Ok(()) | ||
} |