ScottJDaley / ada

A Discord bot for the Satisfactory video game.
MIT License
33 stars 5 forks source link

Consider more flexible queries #65

Closed ScottJDaley closed 4 years ago

ScottJDaley commented 4 years ago

Instead of strict commands and syntax, allow for more natural queries.

Some examples:

ScottJDaley commented 4 years ago

The query parsing would need new logic to interpret these examples.

ScottJDaley commented 4 years ago

New idea:

Assume that outputs should be maximized and inputs (and constraints) should be minimized. Always keep the syntax order the same. Use a symbol such as ? to indicate what you want the optimizer to optimize for.

Some examples:

produce ? power from 240 crude oil

produce ? power and _ plastic from 240 crude oil

produce 60 iron plate

produce 60 iron plate with ? space

produce 60 iron plate from ? weighted resouces

produce 60 iron plate from ? resources without alternate recipes

produce 60 iron plate without refineries

produce ? power from 60 crude oil with _ fuel generators

produce 60 modular frames from ? resources and 30 iron rods

Formal query syntax:

          <query_syntax> ::= <output_keyword> <outputs>
                             [<input_keyword> <inputs>]
                             [<constraint_keyword> <constraints>]
                             [<inv_constraint_keyword> <inv_constraints>]

        <output_keyword> ::= "produce" | "make" | "create" | "output"
         <input_keyword> ::= "from" | "input"
    <constraint_keyword> ::= "with" | "using"
<inv_constraint_keyword> ::= "without" | "excluding"
           <and_keyword> ::= "and" | "+"
       <inv_and_keyword> ::= "and" | "or"
               <outputs> ::= <value> <output> [<and_keyword> <outputs>]
                <inputs> ::= <value> <input> [and <inputs>]
           <constraints> ::= <value> <constraint> [<and_keyword> <constraints>]
       <inv_constraints> ::= <constraint> [<inv_and_keyword> <inv_constraints>]
                <output> ::= <item_expr> | "power"
                 <input> ::= <item_expr> | <resource_expr> | "power" | ["unweighted"] "resources"
                             | "weighted resources"
            <constraint> ::= <recipe_expr> | <building_expr> | "space"
                             | "alternate recipes" | "byproducts"
                 <value> ::=  ["only"] <value_expr> |  "no"
            <value_expr> ::= <number> | <any_value> | <target>
                <number> ::= "[0-9]+"
             <any_value> ::= "any" | "_"
                <target> ::= "?" | ""
ScottJDaley commented 4 years ago

Some notes about the above syntax:

ScottJDaley commented 4 years ago

More details in https://github.com/ScottJDaley/ada/blob/master/query_syntax.md