Code Monkey home page Code Monkey logo

hexdsl's Introduction

HexDSL

A programming language specifically designed for describing turn based hex-grid board games rules and simulating them.

The goal of this language is to be as straight-forward for non-programmers as possible while retaining programmable flexibility in the construction of game rules to maximize board game design space for fun and creativity.

Game loop:

- item/resource setup
- rule setup (acts on items)
- player setup, player-specific rules
- board setup
- loop until winning condition reached
    - player execute rule
    - meta rule executed
    - rules modified as a result of player-executed-rule take into effect   
    - select next player

Game data structures are generally dictionary entires

Rule - global or per-player logic, composed of one or more actions stored as a tree of nodes (see AST)

Item - countable units per player or global (bank)

Alias - a word that can be player-resolved into a number of items xor rules

Verb - specifies action to be performed,

- AST - rules are stored as a pseudo abstract syntax trees
    - each node can either be an operator or a verb
        - operators govern the structure of the tree (and, or, if, then, else)
        - verbs specifies how to modify game data
        - verbs may also modify rules themselves
    - each node has an action, an amount, and a kind
    - ex. pay 3 coin becomes a verb with action='pay' amount=3 and kind='coin'
- data is contained globally, per player, per tile, per unit on tile, or per AST node in rule or per-player-rule.
- each player is a dictionary that can contain items (coin, food, etc), alias, and rules
- a verb acts on items
- a metaVerb acts on other verbs inside a rule
- an alias may contain all items or all rules
- when an alias is encountered, player will resolve ambiguity with a selection

TODO

cancel an action - a rule or verb may return true or false, but player may wish to undo action before

dot syntax - implies hierarchy, properties

1. can be dictionary lookup: ex player.coin is translated to player['coin'] internally
2. can be tree traversal:
    - ex. verb.blocked.amount is ASTNode.left.amount IF verbs.__contains__(ASTNode.action) and IF ASTNode.left.action == 'blocked'
- Assumes 1. if kind is an item and 2. if kind is a rule

metaVerb - verbs that modifies other verbs

- metaVerbs are determined by how they are used
    - a rule that uses a metaVerb must specify a rule or a rule alias as its kind type, eg kind='trade'
- all metaVerbs act on 1 verb inside a rule, when a rule has more than one verb, player decides
- 

ex. #metaVerb
    unblock: if verb.blocked.amount > 0 then verb.amount++ and verb.blocked.amount--
    #rule alias
    topRow: bolster, trade, use, 
    #rule that enacts a metaVerb on 1 unit of a verb aliased to topRow
    upgrade: unblock 1 topRow

metaRule - rules executed in response to player executed rules after a turn

- register which rule a player just executed, then execute corresponding metaRules; beware of dependencies and metarule execution order requirements; can metaRules be dependent on other metaRules?
- ex. if player exec upgrade then 
        for p in player.adjacent do 
            if p.upgrade.recruit then 
                p gain 1 power 
            endif 
         endloop 
       endif

player reference

- player (the player of current turn)
- adjacent.player - players physically adjacent to player of current turn

data reference

- data in per player rule (upgrade.recruit.power)
- data on board location (tile.resource)
- data indirect references (adjacent.player.worker.position.tile.resource)

movement

- move units on hex grid
- hex board setup and resource placement in association with tiles

priorities

- priorities should be programmable
    - prioritize player.rule over global.rule or vice versa

hexdsl's People

Contributors

omikun avatar

Watchers

 avatar

hexdsl's Issues

Add issues for democracy model

bribes, propaganda, better visibility of sentiment impact when viewing politks or creating a bill, better random distribution for population preferences, sentiments, bribe picks, etc

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.