Skip to main content

A package to run bots for 漢字でGO!.

Project description

kadego

kadego is a python package for running bots to play the browser game 漢字でGO!.

This package allows you to automate gameplay, collect data (like readings and meanings), and customize game-playing strategies.

📦 Structure

This package provides five main objects to work with: Bot, Logger, Observer, Strategy and Runner.

🦾 Bot

The Bot is the one actually playing the game.

When calling its launch method it navigates to the provided mode and level, sets the provided number of lives and questions and finally enters into the level. Calling the run method will then make the bot play a full game answering questions according to the specified strategy and logging answers with the specified logger.

📜 Logger

A Logger logs data from the game.

Its log method is called each time an answer is presented to the associated Bot and provided with the current gameVariables. An example use case would be storing readings and meanings to a JSON file.

👀 Observer

An Observer runs in parallel to a Bot.

Its observe method runs continuously and can perform actions depending on the state of the Bot or any outside factors. One of these actions can be stopping the Runner from continuing to run the Bot. An example use case would be stopping the Bot after a certain amount of time or when the intended task has been completed.

🧠 Strategy

A Strategy returns an answer and the corresponding outcome when presented with a question.

Its solve method is called each time the associated Bot is presented with a question. The Strategy will then depending on the gameVariables and the current GameStatus choose a Solver to provide an answer and the associated outcome. An example use case would be acing the game by always choosing the right answer.

🚀 Runner

A Runner is responsible for concurrently running a Bot together with an Observer.

Its run method runs the specified Bot by first calling its launch method and the repeatedly calling its run method until a signal to stop is sent. Additionally, it also runs the specified Observer by calling its observe method.

🗺️ Map

The different game modes are conceptualized as a WorldMap which the Bot uses to navigate namely the KanjiDeGoMap.

⚙️ Main

The main (メイン) mode has levels:

  • easy (ノーマル)
  • hard (ハード)
  • very_hard (ゲキムズ)
  • hell (ヘル)

🔄 Casual

The casual (カジュアル) mode has levels:

  • basic (ベーシック)
  • variety (バラエティ)
  • variety_hard (鬼・バラエティ)
  • one_character (一文字)
  • four_characters (四字熟語)
  • places (国・都市の名前)
  • bugs (虫の名前)
  • mammals (哺乳類の名前)
  • birds (鳥の名前)
  • aquatic (水性物の名前)
  • plants (植物の名前)
  • food (グルメ・調味料)

⏱️ Rush

The rush (ラッシュ) mode has levels:

  • level_1 (1ラッシュ)
  • level_2 (2ラッシュ)
  • level_3 (3ラッシュ)
  • level_4 (4ラッシュ)
  • level_5 (5ラッシュ)
  • level_6 (6ラッシュ)

🌟 Extra

extra (エクストラ) mode has levels:

  • math (数学アタック)
  • math_hard (鬼・数学アタック)
  • english (英語・アタック)
  • elements (元素記号)

⚙️ Installation

To install kadego, run

pip install kadego

📚 Example Usage

To run a bot that scrapes all the readings and meanings for words from a single level, you can run the following.

import asyncio
from kadego import get_kadego
from kadego.runners import SingleLevelScraper


async def run(level: int, log_path: str) -> None:
    kadego = await get_kadego()
    runner = SingleLevelScraper(kadego, level, log_path)

    await runner.run()


if __name__ == "__main__":
    example_level = 1
    exampe_log_path = "/path/to/store/data/to"
    asyncio.run(run(example_level, exampe_log_path))

The bot will then run until the data for all words has been collected.

🛠️ Troubleshooting

漢字でGO! might crash or time out from time to time. This will in turn crash the Bot meaning you wil need to rerun your script.

📝 Changelog

v0.1.0 — Initial release (based on 漢字でGO! v1.1.2.2b).

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

kadego-0.1.0.tar.gz (26.6 kB view details)

Uploaded Source

Built Distribution

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

kadego-0.1.0-py3-none-any.whl (34.3 kB view details)

Uploaded Python 3

File details

Details for the file kadego-0.1.0.tar.gz.

File metadata

  • Download URL: kadego-0.1.0.tar.gz
  • Upload date:
  • Size: 26.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for kadego-0.1.0.tar.gz
Algorithm Hash digest
SHA256 202fa55744a22b9cd1ef49da4e5c0c1f74adcd3646caf3f0c78e6b57d5828381
MD5 b9ae5ac20d672c215c5296ee073c8607
BLAKE2b-256 5ff17ad5d32cd9c039a2c46afda0bf28a8b18f64d0974ef75e67cfb816e333dd

See more details on using hashes here.

File details

Details for the file kadego-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: kadego-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 34.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for kadego-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3ebb3af38a579f76927039c0422abfb660af306904b540556bdf64ba36ab325f
MD5 de271dce11c0c35f6cac50095abcdb26
BLAKE2b-256 6a5f5bd22b7b82ab40bac1e681d2764bf4a59a8a8d9a6dbc9aa14cdd25cd6d13

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