Python SDK for NetCrawl — the programmable idle game
Project description
netcrawl Python SDK
Write NetCrawl workers in Python. Workers communicate with the local game server over HTTP.
Install
pip install .
Quick start
from netcrawl import WorkerClass, Route
from netcrawl.items.equipment import Pickaxe
class Collector(WorkerClass):
"""Harvests ore and returns to hub."""
pickaxe = Pickaxe()
to_mine = Route("Path from Hub to ore node")
to_hub = Route("Return path back to Hub")
def on_startup(self):
self.trips = 0
def on_loop(self):
self.move_through(self.to_mine)
self.collect()
self.move_through(self.to_hub)
self.deposit()
self.trips += 1
Field types
| Field | Description |
|---|---|
Pickaxe() |
Consumes 1 Pickaxe from inventory at deploy time |
Shield() |
Consumes 1 Shield from inventory at deploy time |
Beacon() |
Consumes 1 Beacon from inventory at deploy time |
Route("description") |
User specifies a list of node IDs in the UI |
Worker API
| Method | Description |
|---|---|
self.move(node_id) |
Move to adjacent node (blocking) |
self.move_through(route) |
Walk a list of node IDs in order |
self.collect() / self.harvest() |
Harvest resources at current node |
self.deposit() |
Deposit carried resources at Hub |
self.scan() |
Scan adjacent nodes |
self.repair(node_id) |
Repair an infected adjacent node |
self.info/warn/error(msg) |
Log a message (visible in UI) |
self.current_node |
Current node ID (property) |
self.carrying |
Currently held resources (property) |
AdvancedGraphGadget mixin
from netcrawl.mixins.graph import AdvancedGraphGadget
class Explorer(WorkerClass, AdvancedGraphGadget):
def on_loop(self):
self.travel_to("r3") # A* pathfinding
nearest = self.find_nearest("ore")
nodes = self.explore() # wide-radius scan
Schema introspection
print(Collector.get_schema())
Running examples
cd packages/sdk-python
python examples/test_sdk.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
netcrawl_sdk-0.9.0.tar.gz
(24.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file netcrawl_sdk-0.9.0.tar.gz.
File metadata
- Download URL: netcrawl_sdk-0.9.0.tar.gz
- Upload date:
- Size: 24.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e9795f92bc7ae6a2340af7f483a249b74e9868c94daa6bc58024069c73e3e1a
|
|
| MD5 |
ff414e88eb7c838f1cccf124d454ea63
|
|
| BLAKE2b-256 |
0e4563164bdd2a61dc89699299f853422c4264e7a7d155f2f466fc363bd736c9
|
File details
Details for the file netcrawl_sdk-0.9.0-py3-none-any.whl.
File metadata
- Download URL: netcrawl_sdk-0.9.0-py3-none-any.whl
- Upload date:
- Size: 29.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd539dad1d7fd81e71ef8bf1d0d90acd4fc367cd28a1e00270276b9f6780a19d
|
|
| MD5 |
ed12818a7aa15c5e6e65e495f7b991ad
|
|
| BLAKE2b-256 |
3140c85621c058adea9a7ea62c18001f6e8ada0d6d287d7443a721e381d9ff78
|