Permalink
Browse files

Added scaffold method to DescriptionFactory

  • Loading branch information...
siwells committed May 7, 2012
1 parent e06fad1 commit 17072d606dd79722c44416b42945a68a8062056c
Showing with 162 additions and 9 deletions.
  1. +30 −0 dgdl_ebnf_2012.txt
  2. +47 −0 dgdl_example.game.txt
  3. +7 −2 src/dgdl.py
  4. +29 −7 src/main.py
  5. +49 −0 todo.txt
View
@@ -0,0 +1,30 @@
+System ::= ID {[Game]+} | Game
+Game ::= ID {Composition [Regulation]* [Interaction]+}
+Composition ::= {Turns Participants [Player]+ [Store]* [RoleList]?}
+Turns ::= {turns, magnitude:Magnitude, ordering:Ordering[, max:Number]?}
+Magnitude ::= single | multiple
+Ordering ::= strict | liberal
+Participants ::= {players, min:Number, max:Number|undefined}
+Player ::= {player, id:ID [, roles:{ID[, ID]*}]? }
+Store ::= {store, id:ID, owner:{ID[, ID]*}, structure:Structure, visibility:Visibility}
+Structure ::= set | queue | stack
+Visibility ::= public | private
+RoleList ::= {roles, {ID[, ID]*}}
+Regulation ::= {ID, scope:Scope, RuleExpr}
+Scope ::= initial | turnwise | movewise
+Interaction ::= {ID, Content[, Opener]?, RuleExpr}
+Content ::= {[!]?ID[, [!]?ID]*}
+Opener ::= Str
+RuleExpr ::= {Effects [and Rule]* | Rule [else Rule]* [else Effects]?}
+Rule ::= if Condition [and Condition]* then Effects
+Effects ::= Effect[ and Effect]*
+Effect ::= ID{Param[, Param]*}
+Condition ::= ID{Param[, Param]*}
+ID ::= UChar|LChar[UChar|LChar|Num|Link]*
+Param ::= ID | Content
+Num ::= [0-9]+
+Str ::= "[UChar|LChar|Num|Sym]+"
+UChar ::= [A-Z]+
+LChar ::= [a-z]+
+Link ::= '_'
+Sym ::= '' WHICH SYMBOLS TO SUPPORT IN DGDL STRINGS???
View
@@ -0,0 +1,47 @@
+game:
+{
+ id:dgdl_simple
+ turns:{ magnitude:12, ordering:strict },
+ players:{ min:2, max:undefined },
+ player:{ id:black },
+ player:{ id:white },
+ store:{ id:cstore, owner:{white}, structure:set, visibility:public },
+ store:{ id:cstore, owner:{black}, structure:set, visibility:public },
+ rules:
+ {
+ rule:
+ {
+ id:1,
+ scope:movewise,
+ body:
+ {
+ if inspect{in, p, cstore, speaker} then update{cstore, black, p}
+ else if inspect{in, p, cstore, speaker} then update{cstore, black, p}
+ }
+ },
+ rule:{ id:2, scope:movewise },
+ rule:{ id:3, scope:movewise },
+ rule:{ id:4, scope:movewise },
+ rule:{ id:5, scope:movewise }
+ },
+ moves:
+ {
+ move:{ id:assert, content:{p, p, p, p}, opener:"is it the case that" },
+ move:{ id:challenge, content:{p, p, p, p}, "is it the case that" },
+ move:{ id:defend, content:{p, p, p, p}, "is it the case that" },
+ move:{ id:concede, content:{p, p, p, p}, "is it the case that" },
+ move:{ id:question, content:{p, p, p, p}, "is it the case that" }
+
+ move:
+ {
+ id:ASSERT,
+ content:{p, q, r},
+ opener:"It is the case that",
+ body:
+ {
+ if inspect{in, p, cstore, speaker} then update{cstore, black, p}
+ else if inspect{in, p, cstore, speaker} then update{cstore, black, p}
+ }
+ }
+ }
+}
View
@@ -6,13 +6,18 @@ class DescriptionFactory:
"""
def __init__(self):
pass
+
+ def scaffold(self):
+ pass
class DGDLDescription:
"""
A class that represents a DGDL description
"""
- def __init__(self):
- pass
+ def __init__(self, system):
+ self.system = system
+
+
class System:
"""
View
@@ -2,30 +2,52 @@
if __name__ == '__main__':
# print "DGDL"
-
+
turns = Turns(size=12)
- roles = RoleList()
+# roles = RoleList()
part = Participants()
white = Player("white")
white_cstore = Store("cstore", "set", "public", white)
black = Player("black")
black_cstore = Store("cstore", "set", "public", black)
- comp = Composition(turns, part, [black, white], [white_cstore, black_cstore], roles)
+ comp = Composition(turns, part, [black, white], [white_cstore, black_cstore])#, roles)
+
+
regulations = [ Regulation( str(count) ) for count in xrange(1,6) ]
+
+
moves = [Interaction("mv"+str(count), content = ["p","p","p","p"], opener="is it the case that") for count in xrange(1,6) ]
game = Game("dgdl_simple", comp, regulations, moves)
- # print game.fragment()
-
+# print game.fragment()
+
# for mv in moves:
# print mv.fragment()
+ """
+ print "###"
eff1 = Effect("update", "cstore", "black","p")
print eff1.fragment()
con1 = Condition("inspect", "in", "p", "cstore", "speaker")
print con1.fragment()
- rl1 = Rule(conditions=[con1], effects=[eff1])
- print rl1.fragment()
+ rl2 = Rule(conditions=[con1], effects=[eff1])
+ rl1 = Rule(effects=[eff1])
+ print rl1.fragment()
+
+ rls1 = RuleExpr(rule_expr=[rl2, rl2])
+ print rls1.fragment()
+
+ reg1 = Regulation("REG1", "movewise",rls1)
+ print reg1.fragment()
+
+ int1 = Interaction("ASSERT", ["p","q","r"], "It is the case that", rls1)
+ print int1.fragment()
+ """
+
+ system = System("TESTSYS")
+ system.add_game(game)
+ system.add_game(game)
+ system.print_system()
View
@@ -0,0 +1,49 @@
+* A keyword is followed by a colon, e.g. game: or rule:
+* If there is more than one value following a key(word) then curly brackets are used to denote scope
+* Each game has a list of labels that are valid descriptors used in the specification of the game.
+* Add functionality to retrieve the list of labels from the description
+* What is the relation between labels and tokens?
+* Scoping of labels and tokens between games in a system?
+* well-formedness of game descriptions
+* remove commas?
+* how to represent tokens, locutions, and arguments?
+* SYMBOLS IN STRINGS
+* UNIT TESTS - start with basic classes and work way up until we have much better coverage
+* TEST EBNF AGAINST ANTLR NB. Ensure it is a valid ANTLR Grammar
+
+
+
+dgdl_simple{
+ {turns, magnitude:12, ordering:strict},
+ {turns, magnitude:12, ordering:strict},
+ {players, min:2, max:undefined},
+ {player, id:black},
+ {player, id:white},
+ {store, id:cstore, owner:{white}, structure:set, visibility:public},
+ {store, id:cstore, owner:{black}, structure:set, visibility:public},
+ {
+ {1, scope:movewise},
+ {2, scope:movewise},
+ {3, scope:movewise},
+ {4, scope:movewise},
+ {5, scope:movewise}
+ },
+ {
+ {mv1, {p, p, p, p}, "is it the case that"},
+ {mv2, {p, p, p, p}, "is it the case that"},
+ {mv3, {p, p, p, p}, "is it the case that"},
+ {mv4, {p, p, p, p}, "is it the case that"},
+ {mv5, {p, p, p, p}, "is it the case that",
+ {
+ if
+ inspect{in, p, cstore, speaker}
+ then
+ update{remove, cstore, black, p}
+ else if
+ inspect{not_in, p, cstore, speaker}
+ then
+ update{add, cstore, black, p}
+ }
+ }
+ }
+}

0 comments on commit 17072d6

Please sign in to comment.