1 / 14

GodPL

GodPL. G amer o r D eity? P rogramming L anguage Konstantin Pozin. Problem Domain. A simple artificial life game: 2D environment Primitive creatures: Briyya (Pl. Briyyot ) Food sources (e.g. apple trees) Hazards (e.g. rocks, poisonous plants) Weather: rain, temperature

keiran
Download Presentation

GodPL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. GodPL Gamer or Deity? Programming Language Konstantin Pozin

  2. Problem Domain A simple artificial life game: • 2D environment • Primitive creatures: Briyya (Pl. Briyyot) • Food sources (e.g. apple trees) • Hazards (e.g. rocks, poisonous plants) • Weather: rain, temperature We want a fast way to program the creatures.

  3. Problem Domain: Creatures • Can move, eat, hit other Briyyot, reproduce, die • Three life stages: Child, Adult, Senior • Two sexes • Genetic traits from 0.0 to 1.0:ColorRed, ColorBlue, ColorGreen, SizeScale, Swiftness, Curiosity, Aggressiveness, Courage, ResistanceToCold, ResistanceToToxin, ResistanceToPain, Strength, Metabolism • Sexual reproduction: gene averaging + error

  4. Problem Domain: Creatures • Drives: Hunger, Boredom, Fear, Pain, (maybe more) • These correspond to probabilities that the creature will choose certain actions at given times • Basic learning (positive or negative attitudes towards categories of in-world objects)

  5. Domain Inspiration • Creatures game, published in 1996 by Mindscape (later Cyberlife Technologies, then Creature Labs) • “one of the first commercial titles to code alifeorganisms from the genetic level upwards using a sophisticated biochemistry and neural network brains” (Wikipedia)

  6. Language Features (1) Imperative, C-style language • Basic control loops • Definitions of methods • Conditions that trigger those methods (event-driven) • Special syntax for time-based triggers

  7. Language Features (2) • Static typing, but with lots of implicit polymorphism • Type system: • Two primitives: float and string • Complex types are categories. An object can belong to more than one category (think of these as multiple interfaces). • GameObject, Briyya, Obstacle, FoodSource, PoisonSource, Shelter, Tree… • Categories cannot be defined by the user

  8. General Program Structure globals: Type1 var1; Type2 var2; ... functions: Type1 foo1(…) { ... } ... triggers: (cond1 && cond2 && cond3) -> { foo1(…); foo2(…); foo3(…); … } ...

  9. Control Flow if (cond1) { … } else if { … } else { … } float f = 0; while (f > 0) { f = f - 1; } foreach(Tree a) { if (me.DistanceTo(a) < 5) { me.MoveTowards(a); return; } }

  10. Time Syntax Expressed as hh:mm:ss (time == 00:03:05) if ((time >= 00:00:00) && (time <= 00:00:10)) every(00:00:05)

  11. Implementation: Runtime System • Microsoft .NET 3.5 on Windows • Written in C# • Using Windows Forms libraries for widgets • Microsoft XNA (managed graphics and game logic library) • Execution based on XNA’s game loop(usually 60 fps)

  12. Implementation: Language • Primary ANTLR grammar for GodPL, generating a C#-based parser that outputs an AST • Secondary ANTLR grammar for AST, generating a C#-based parser that generates valid C# code • C# code compiled at runtime, incorporated into Briyyaclass’s Update() method

  13. Remaining Tasks • Complete GodPL parser (about 10% left) • Write AST parser / C# generator • Complete runtime system (about 60% left) • Some concepts may yet have to be cut out • Sleep

  14. Remaining Design Issues • Create special syntax for probability expressions? • How to deal with arbitrary identifiers (object names, member fields, and methods) • me.X and me.Drives.Hunger are valid • They get rewritten as this.X and this.Drives.Hunger in C# • What about me.GetType().Assembly.GetManifestResourceInfo()…

More Related