Skip to content

Latest commit

 

History

History
86 lines (86 loc) · 6.13 KB

todo.org

File metadata and controls

86 lines (86 loc) · 6.13 KB

support custom backwards predicate (<<) under stage label

decide on consistent syntax for arguments e.g. keywords?

arbitrary math expressions e.g. ‘expr 2 + A / 3 + 1.5 = B’

lispy key properties to enable pattern matching

syntax to match rule only once per update / permanently. or even make matching once per update the default.

  • option to scope permanence by a variable
  • #stage: { input 3= output } evaluates max 3 times within stage, becomes: #stage: { // must be structured to keep behavior of random rule selection !tmp-counter-123 _ . input = output . tmp-counter-123 2 tmp-counter-123 N . > N 0 . - N 1 N’ . input = output . tmp-counter-123 N’ () = #tmp-cleanup } #tmp-cleanup: { tmp-counter-123 _ = () }
  • could also allow integer variables to be used instead of constant e.g. #stage: { $count N . input N= output }

make $ remove instead of preserve, since remove is less common and this makes the stage behavior (#asdf:) consistent with other syntax

replace !== backwards predicate with ability to use ‘!’ anywhere in a phrase

ability to arbitrarily nest ‘stage’ scopes

ability to put rule output in ‘stage’ scopes e.g. in1 . in2 = out1 { subset = () } === in1 . in2 . subset = out1

reduce serialization boilerplate with either serde or generated code (like with pest)

allow output in custom backwards predicate, i.e. output is appended to rule

test doing initial matching through ecs instead of first atoms (e.g. https://github.com/TomGillen/legion)

  • requires a macro to generate rust structs for throne identifiers
  • an item of state is then e.g. &[FooAtom::N1, Var::N2, BarAtom::N3, etc..]
  • possible matching rules are found using a component query

support marking state phrases immutable in debug builds, logging warning when the state is consumed by a rule. or do compile-time check.

support matching phrases while binding to them, to avoid retyping them in output e.g. (foo A)@FOO . bar = FOO

look at prolog optimizations

  • could we compile each rule down to a specialized routine with a stack for variable matches to replace test_inputs_with_permutation
  • bin each phrase by (atom, atom position) and variable name to speed up matching

add syntax for matching on const lists i.e. (FOO | BAR) matched against (a b c): FOO = a, BAR = (b c)

ink -> throne converter

syntax for inserting the result of an input match directly into output

  • e.g. foo FOO = `foo capitalized is` (^capitalize FOO <OUT) instead of foo FOO . ^capitalize FOO OUT = `foo capitalized is` OUT where OUT can also be a wildcard (or omitted?)

evaluate constant expressions to eliminate rules that will never match

an easy way to test a rule with a chance of success based on a probability extracted from state

  • This is currently difficult since the number of times that a rule may be evaluated in an update is not well defined

use const generics to replace find_phrases* and find_phrases_exactly* variants with single function

  • e.g. `find_phrases<const N: usize>(pattern: [Option<&Atom>; N], match_pattern_length: bool) -> Vec<&[Token]> { … }`
  • replace find_phrase* variants too

measure performance with https://github.com/bodil/smartstring

add examples

  • [X] Conway’s game of life
  • [ ] Chess
  • [ ] Tic tac toe
  • [ ] Procedural generationn

reduce permutation space beyond first atom

  • a X . a X = … or a X . b X = … with a (0..N) and b (0..N) triggers an O(N^2) search on each update.

support backwards predicates in any order

  • currently backwards predicates are evaluated left to right in two passes, so > 2 backwards predicates in the wrong order will fail matching e.g. + C 3 D . % B 2 C . + A 1 B = …
  • backwards predicates need to be evaluated in order based on variable dependencies.
  • could extend ordering based on dependencies to matching in general, including side predicates and normal state matches, to reduce permutations.
  • “you might be able to save a lot of hashmap lookups if you replace a `HashMap<K, V>` with a `HashMap<K, usize>` and a `Slab<V>`. This might be very useful if K is something heavy such as a `String`”

support quiescence rule under stage label i.e. don’t copy left-hand stage for quiescence rule

replace #foo -> stage foo, because # does not have special effects like other symbols

syntax for scheduling some output of a rule to be deleted at the end of the update

  • left up to embedder.

make () = () optional in prefixed blocks

detect infinite loops

selectively disable warnings

wildcard variable: _

support defining own backwards predicates:

  • defined as rule without ‘=’: <test A B . + A B C . required state C
  • can be compiled by replacing instances of <test _ _ in the full rule, making the appropriate variable name substitutions
  • predicate does not consume state, which needs a small change in the matching loop

comment syntax

syntax to check absence of state: ^

move drawing outside of rules - just draw with js by iterating over state

handle frames by ‘injecting’ atom i.e. insert ‘#frame’ atom and let rules handle it

‘derived’ state i.e. able to match on Z where Z is equivalent to X + Y, when only X + Y are present

performance improvement by sorting states by atom indices + jumping to known ranges during matching or do binary search

modulo

improve performance by, for each phrase in a rule, recording the states that could match the phrase. needs to be re-evaluated each time state is added or removed.

  • attempted in 7d27586, worsened performance.