Git Product home page Git Product logo

daide's Introduction

DAIDE

SUPPORTS most bot order related communication commands levels 0-30. Please make an issue if u want a new word (or a PR :) )

AND ORR XDO HLD MTO SUP CVY CTO VIA YES HUH FCT PRP

This library parses DAIDE strings into a recursive object model. It can also generate a string from the object model.

e.g. "AND (order1) (order2)" -> AND([order1, order2])

Usage

(FFF are placeholders for a province)

>>> from DAIDE import parse
>>> arrangement = parse('AND (XDO ((FFF FFF FFF) HLD)) (XDO ((FFF FFF FFF) HLD))')

>>> arrangement
<DAIDE.syntax.lvl30.binop.AND object at 0x7fb6623193c8>

# parsed objects are nested
>>> arrangement.arrangements
[<DAIDE.syntax.lvl20.xdo.XDO object at 0x7fb6622bd7f0>, <DAIDE.syntax.lvl20.xdo.XDO object at 0x7fb6622bd8d0>]

# generate string from DAIDE object
>>> str(arrangement)
'AND (XDO ((FFF FFF FFF) HLD)) (XDO ((FFF FFF FFF) HLD))'

# easily compose DAIDE keywords
>>> from DAIDE import Order, Unit, ORR, HLD
>>> arrangement = ORR([Order(Unit("FFF FFF FFF"), HLD()), Order(Unit("FFF FFF FFF"), HLD())])
>>> str(arrangement)
'ORR ((FFF FFF FFF) HLD) ((FFF FFF FFF) HLD)'

Advanced

If you are not working with DAIDE style orders (e.g. Diplomacy Github uses shorthand order style), run the following at the beginning of your code:

from DAIDE import config
config.ORDERS_DAIDE = False

Installation

From Github (easiest)

pip install git+https://github.com/trigaten/DAIDE.git

From inside repo

pip install -e .

Adding Syntax

All syntax words are represented as objects which implement

a parse() function and __str__

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.