levb
New Member
Posts: 18
|
Post by levb on May 26, 2014 22:15:47 GMT -8
GDL is pretty low-level. This is good for players, because parsing and interpreting is easier. But it's inconvenient for humans who write game rules.
Has anybody considered creating a high-level language that would translate into GDL?
|
|
|
Post by sumedhghaisas on May 27, 2014 13:52:56 GMT -8
Yes. It is in my mind for days. Writing a big game will be lot messy in GDL. But yet I have no more ideas to follow. Like what sort of additions to have in this high-level language...
|
|
|
Post by Steve Draper on May 27, 2014 13:57:50 GMT -8
Yes. It is in my mind for days. Writing a big game will be lot messy in GDL. But yet I have no more ideas to follow. Like what sort of additions to have in this high-level language... Concepts of number would be one thing to usefully abstract, rather than having to rely on successor relationships explicitly encoded in GDL. Of course all numbers would have to be bounded since ultimately they would have to compile into successor-based representations in GDL.
|
|
levb
New Member
Posts: 18
|
Post by levb on May 29, 2014 21:31:07 GMT -8
I can think of
Built-in arithmetic, where of course numbers will be distinct from the built-in numbers in GDL Support for libraries of relations and/or functions
Ability to quantify variables as "exists" instead of "any". Consider this definition
(<= (hasPiece ?x ?y) (true (cell ?x ?y ?anyPlayer ?anyType))) This enables us to write (not (hasPiece ?x ?y))
It should be possible to just write (not (exist ?anyPlayer ?anyType (true(cell ?x ?y ?anyPlayer ?anyType))))
Functional syntax. Consider this excerpt from checkers:
(<= (legal2 black (move ?x1 ?y1 ?x2 ?y2)) (true (cell ?x1 ?y1 black ?anyType)) (or (nextFile ?x1 ?x2) (nextFile ?x2 ?x1)) (nextRank ?y2 ?y1) (empty ?x2 ?y2))
A small simplification could be (<= (legal2 black (move ?x1 ?y1 ?x2 prevRank(?y1) )) (true (cell ?x1 ?y1 black ?anyType)) (or (nextFile ?x1 ?x2) (nextFile ?x2 ?x1)) (empty ?x2 prevRank(?y1)))
|
|
|
Post by alandau on May 31, 2014 17:02:11 GMT -8
The only thing I've really found myself wanting is a generic way to count the number of true sentences matching a given input, something like:
(<= whiteWinning (count ?numWhitePieces (true (cell ?x ?y white))) (count ?numBlackPieces (true (cell ?x ?y black))) (greaterThan ?numWhitePieces ?numBlackPieces))
You could also make a case for shorthand for adding a successor function. This could also be part of a larger feature to allow "library imports" for constructing larger games from more pieces.
Arithmetic definitions for other things (greater than, sums, products) are fairly compact once the successor function is in place, and good rules engines can precompute everything that's not state-dependent, so I doubt there's much of a performance difference vs. native arithmetic.
|
|
|
Post by sumedhghaisas on Jun 8, 2014 16:40:49 GMT -8
Another simple thing to add to this higher level language is support for 'and'ing. Parser can use simple and-elimination to remove this 'and'. This can be very helpful in situations like - (<= (test1 ?x) (test3 ?x) (test4 ?x) (test5 ?x)) (<= (test2 ?x) (test3 ?x) (test4 ?x) (test5 ?x)) it can be simply written as (<= ((test1 ?x) (test2 ?x)) (test3 ?x) (test4 ?x) (test5 ?x))
|
|
levb
New Member
Posts: 18
|
Post by levb on Jun 9, 2014 10:32:02 GMT -8
You could work around like so:
(<= (ttt ?x) (test3 ?x) (test4 ?x) (test5 ?x)) (<= (test1 ?x) (ttt ?x)) (<= (test2 ?x) (ttt ?x))
|
|
levb
New Member
Posts: 18
|
Post by levb on Jun 9, 2014 10:38:17 GMT -8
Come to think of it, this would be more intuitive:
if ( (test3 ?x) (test4 ?x) ) { (test1 ?x) (<= (test2 ?x) (test5 ?x)) ; if x satisfies test3, test4 and test5, then x also satisfies test2 }
This would be syntactic sugar, not imperative programming!
|
|
|
Post by Steve Draper on Jun 9, 2014 11:02:06 GMT -8
Come to think of it, this would be more intuitive: if ( (test3 ?x) (test4 ?x) ) { (test1 ?x) (<= (test2 ?x) (test5 ?x)) ; if x satisfies test3, test4 and test5, then x also satisfies test2 } This would be syntactic sugar, not imperative programming! Too suggestive. I prefer something like: (<= ( (<= (test1 ?x) ) (<= (test2 ?x) (test5 ?x) ) ) (test3 ?x) (test4 ?x) )
|
|