Skip to main content

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


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.5.0.tar.gz (22.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

netcrawl_sdk-0.5.0-py3-none-any.whl (27.2 kB view details)

Uploaded Python 3

File details

Details for the file netcrawl_sdk-0.5.0.tar.gz.

File metadata

  • Download URL: netcrawl_sdk-0.5.0.tar.gz
  • Upload date:
  • Size: 22.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for netcrawl_sdk-0.5.0.tar.gz
Algorithm Hash digest
SHA256 7bfabdc40049f4d2110773d84af65e0f9db453ab9564a2e99ec6693cd9a1ae11
MD5 51d47985fc01c9e56d6ed9247204c28e
BLAKE2b-256 9cdaaf08e6ffb0f4374f854d059a6119f8512b272a400d8fa53a2f39557d9dea

See more details on using hashes here.

File details

Details for the file netcrawl_sdk-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: netcrawl_sdk-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 27.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for netcrawl_sdk-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2729ca51b16e57b41a8193ad9b92831b4916a5fae558f57fed87509f6fada02d
MD5 66a99b9224ae54daf66b0c38141b2d3f
BLAKE2b-256 e176d667a3927965d510502cae397d4c5bf7835dc87f8d9f148bb6ad18643206

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page