1 / 73

Levels and Scripts

Levels and Scripts. Script Engine. A symbol table, which contains all the symbols and information about type, scope, etc. A lexical analyzer, which is a function that converts a character stream (i.e. the source file) into tokens (i.e. keywords, operators, etc.)

maegan
Download Presentation

Levels and Scripts

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. Levels and Scripts

  2. Script Engine • A symbol table, which contains all the symbols and information about type, scope, etc. • A lexical analyzer, which is a function that converts a character stream (i.e. the source file) into tokens (i.e. keywords, operators, etc.) • A parser, which takes the token stream and builds a syntax tree from it. • A semantic checker, which checks the syntax tree for semantic errors • An intermediate code generator, which converts the syntax tree into intermediate code • An optimizer (optional) which optimizes the intermediate code • A code generator, which generates bytecode from the intermediate code Last but not least, the virtual machine on which the bytecode is to be executed.

  3. http://www.flipcode.com/archives/Implementing_A_Scripting_Engine-Part_1_Overview.shtmlhttp://www.flipcode.com/archives/Implementing_A_Scripting_Engine-Part_1_Overview.shtml

  4. Layered Avatar Behavior Model and Script User • Overall structure Context Menu Interface (Display) Domain Interface Layer Avatar-Object Interaction Model Recording 1st Translator (Task-to-High) Task-Level Behavior Script Translating Motion Sequence Layer High-level Motion Script Avatar-Object Interaction Model Translating Context Implementation Layer Application Layer 2nd Translator (High-to-Primitive) Primitive Motion Script Primitive Motion Script Executable Behaviors Geometric Information MotionList Avatar Low-level Animation Data Object Low-level Animation Data Avatar Low-level Animation Data Object Low-level Animation Data Application Application

  5. Avatar-Object Interaction Model(1/2) • Basic Object Structure • Proposed model has multiple objects below the ObjectList element • An object is composed of three elements • Context : object state, access privilege, controlpoint and domain type • ExecutableBehaviors : all executable behaviors for user interface menu • MotionList : motion sequence to complete a behavior ObjectList Object+ Context Executable Behaviors MotionList Basic XML DTD sturcture

  6. Avatar-Object Interaction Model(2/2) Avatar-Object Interaction Model Selectable Behaviors Context Behaviors Selection User State ControlPoint Select a Behavior AcessGroup Domain Behaviors List Task Planning Executable Behaviors Generating Motions MotionList … Motion List

  7. Context Element(1/5) • State Element • Describes internal object states by pair of variable and value attributes • Variable has affective motion and current state methods • Affective motion defines post-state value, and corresponding motion which changes the state • Current state function is defined in XSLT script that processes state element to make boolean result output of current state value • Behavior menu and motion sequence are decided according to changes of state variables value

  8. Context Element(2/5) • IF • (1) Event Motion = Affective Motion • (2) State Function = TRUE • THEN • (1) Make up of Variable list which satisfy conditions • (2) Set each variable Value to Post_State • (3) Output boolean result by State Function Variable : DoorState Affective Motion Event Motion Motion Name close Post State closed ‘close’ Value closed Result State State Functions IsClosed ‘True’ V V V Interaction State Changes V V Door Object

  9. Context Element(3/5) • ControlPoint Element • Spatial reference points around a object where avatar stands and interact with it • Depending on the behaviors and object states, a object may have various points • A point is consisted of position, direction and contact elements • The elements has coarse references to represent spatial location at high-level • Human readable • Independent from physical geometric object models • Used for behavior sub-tasking and motion sequencing

  10. y Contact z x Position Direction Context Element(4/5) • Position • Relative 5 basic and 4 composed positions for each objects • Standard axis is –z for front on zy-plane • Direction • Object relative 4 basic and composed directions to determine avatar’s orientation • Rotation axis is y and zero degree for forward direction • Contact • designate a specific part of the object when the avatar makes contact with the object • The corners of the bounding box of 3D objects and the center point of the surface

  11. Context Element(5/5) • Access Group Element • Object behavior can be accessed by several user types • Each user type has different purpose and usage • Each group has different access to behavior interface • DomainType Element • Not only internal state of object, but also external domain state can effect behavior interaction. • The same object can behave as a different semantic object • e.g. A car object in traffic simulation domain and assembly training domain • DomainType element defines name of domain for checking current domain type.

  12. Layered Script Language User • Overall structure Context Menu Interface (Display) Domain Interface Layer Avatar-Object Interaction Model Recording 1st Translator (Task-to-High) Task-Level Behavior Script Translating Motion Sequence Layer High-level Motion Script Translating Application Layer 2nd Translator (High-to-Primitive) Primitive Motion Script Primitive Motion Script Geometric Information Avatar Low-level Animation Data Object Low-level Animation Data Avatar Low-level Animation Data Object Low-level Animation Data Application Application

  13. Task-level Behavior Script(1/2) • Task-level Behavior Script • Presents object and avatar behaviors using XML DTD • Records and saves user action in temporal sequence • Extensible representation for behavior set • Objects in a domain makeup the usable behavior set • Cf) existing script which has pre-defined behavior DTD • Independent from rendering environments • Doesn’t present appearance of avatar model, positional information of virtual objects, so on.

  14. Door Enter Domain Object Pool Computer Next page Text Highlight Screen Point Computer Prev.page Hello I’m... User Text Typing User Selection Task-level Behavior Script = Object Behavior Narration Task-level Behavior Script(2/2) • Definition of Task-level Avatar-Object Behavior Script • Template-based Avatar-Object Behavior Representation • Domain behavior set is flexibly defined by object instances • Task-level Behavior = (Object, Executable-Behavior, Narration)

  15. High-level Motion Script(1/2) • High-level Motion Script • Bridges between task-level script and primitive motion script • Independent from both interface domain and application domain • Parameterized motion support • Synchronization, speed, target, repeat, intensity, decay, etc • Abstract values rather than physical

  16. High-level Motion Script(2/2) • Structure of high-level script DTD

  17. Primitive Motion Script • Primitive motion • Supported by rendering engine or motion library • Represented in physical parameter values ex) Geometric values such as coordinates of avatar and objects, radian value of avatar direction, etc • Parameters are transmitted to animation engine to play animation scenario on screen

  18. Script Translators(1/4) • Task-level Behavior Script Translator • Translates task-level behavior script into high-level motion script • Consisted of motion sequences to perform task-level behaviors • Motion planning by task planner and generate the sequences ex) <get target=“box”/> 1. <highLevelMotion name=“walk” …> 2. <highLevelMotion name=“bend_body”…> 3. <highLevelMotion name=“grab”…> • Uses logical application domain knowledge • According to formal translation model, script of each domains is converted to a high-level motion script

  19. Script Translators(2/4) • Formal Task Translation Model • Identification of target • find location of target object(Lo) • Locomotive motion (Ml) • identification of present avatar location (La) • spatial distance between La and Lo • generate Lm, if La ≠ Lo • Manipulative motion (Mm) • generate Mm for Lo • Verbal information (Vi) • generate verbal speech for avatar behavior if available • Speed and intensity parameters • parameterize Mm and Ml for speed, intensity and duration

  20. Task-level Script Translator High-level Motion Task-level Behavior Spatial Information Generator Ex) task-level behavior script <task name="bye" target="students"> Let's do it next time!</task> Temporal Information Generator Locomotion Generator Intensity Controller Script Translators(3/4) • Procedure modules Ex) Generated high-level motion <highLevelMotion name="wave" type="gesture"> <spatialParam> <direction type="object"> <objectName>students</objectName> </direction> </spatialParam> <temporalParam> <speed>normal</speed> <repeat>default</repeat> <duration>default</duration> </temporalParam> <degreeParam> <intensity>normal</intensity> <decay>default</decay> <priority>normal</priority> </degreeParam> <verbalParam> <speech>Let's do it next time!</speech> </verbalParam> </highLevelMotion>

  21. Primitive Motion Script <primitiveMotion name="right_hand_point"> <target> <coord x="-200" y="-1" z="95"/> </target> <destination> <from x="-100" y="9" z="0"/> <to x="-100" y="9" z="0"/> </destination> <direction>-143</direction> <speed>15</speed> <intensity>15</intensity> <repeat>1</repeat> <duration>40</duration> <speech>this is …</speech> </primitiveMotion> High-level Motion Script High-level Motion Trasnlator Virtual Space Object Geometry Analyzer Object Geometry Script Translators(4/4) • High-level Motion Script Translator • Major module : Object geometric information analyzer • Calculates location, size, and direction of virtual objects • Current status of avatar position and posture • Translates abstract parameters of high-level script to physical values

  22. System Implementation(1/2) • Creating a scenario script

  23. System Implementation(2/2) • Running a scenario script in different environments • Different physical properties of virtual objects • Applying same task-level script to other applications OpenGL Application 2D Web Application(MSAgent)

  24. Script Compiler print "Please enter your name > "; input name; if (name == "Jan") { // string comparison name = "my creator"; // string assignment happy = "yes"; } print "Thank you, " + name + "!\n" + // string concatenation "You've just made a simple program very happy!"; "if" {return IF;} "=" {return ASSIGN;} ";" {return END_STMT;} {IDENT} {Identifier (); /* identifier: copy name */ return ID;} {STR} {StringConstant (); /* string constant: copy contents */ return STRING;} "//" {EatComment();} /* comment: skip */ \n {lineno++;} /* newline: count lines */ {WSPACE} {} /* whitespace: (do nothing) */ . {return ERROR_TOKEN;} /* other char: error, illegal token */

  25. Challenge: Design Levels • 60 levels = 6 groups of 10 • Easy to hard within a group • Each group features different devices 60 levels, structured as 6 ramps of 10 puzzles each. Puzzles within a ramp start easy and get harder. Each ramp has a different visual theme and emphasizes a different mix of features, to keep the game from getting too repetitive.

  26. Building Levels • Tell a Story • Paint a Picture • Create a Mood • Use Math • Exploit features • Lay a Trap

  27. Building Levels: Tell a Story #17 Run Like Crazy Some puzzles are structured as a linear sequence of events. For this puzzle started by drawing a board that wraps a long narrow corridor into a small space.

  28. Building Levels: Tell a Story #17 Run Like Crazy This puzzle features an autodetonator, shown in red here, which blows up automatically in a preset amount of time unless you touch it to reset it. The basic drama of this puzzle is that you must run to the autodetonator, then push it back a long way so it blows up a bomb.

  29. Building Levels: Tell a Story #17 Run Like Crazy I then compounded the puzzle by adding obstacles along the three legs of the journey. Moving spikes that raise and lower out of the game cause you to have to wait a bit before you can get to the autodetonator -- frustrating when you have to get there quickly.

  30. Building Levels: Tell a Story #17 Run Like Crazy Next you must push the autodetonator onto a moving platform that travels slowly to the right, then push it off. Again, timing is critical if you are to execute this move before the autodetonator blows up.

  31. Building Levels: Tell a Story #17 Run Like Crazy I added one more spike in the right leg of the journey..

  32. Building Levels: Tell a Story #17 Run Like Crazy Finally there is the end game. One bombs only blow up themselves, so the ending position must be an autodetonator surrounded by one bombs. Because two of the 1 bombs are against walls they cannot be pushed away from, there is only one possible ending position.

  33. Building Levels: Paint a Picture #48 Ice Rink. Initial pattern. Another way to invent a puzzle is to start with a pretty pattern, then try playing it. Here are three opening positions I considered for the puzzle Ice Rink. They look similar, but behave very differently. You cannot stop moving on ice until you hit a wall or reach solid ground.

  34. Building Levels: Paint a Picture #49 Diamond. Initial pattern. Here are three patterns I considered for a puzzle called Diamond, which features a patch of ice surrounded by solid ground. After drawing the opening patterns I played them to see if they could be solved. If they were not solvable, I then had to decide how to modify the pattern.

  35. Building Levels: Paint a Picture #60 The… Final pattern. For the final puzzle I decided to aim for a pretty final position that would spell the word “End”. This is what I originally hoped for..

  36. Building Levels: Paint a Picture #60 The… Initial pattern. The actual final puzzle required many modifications to the boards and pieces to make sure that the puzzle only had one solution. Shown here is the final beginning position.

  37. Building Levels: Paint a Picture #57 Pinball. Overall picture. One of the features of Charlie Blast is bumpers, which rebound bombs pushed into them. Bumpers reminded me of pinball bumpers, so I built this puzzle to look like a pinball machine, complete with a moving beltway for returning a queue of balls into play.

  38. Building Levels: Create a Mood #16 Long Haul Some puzzles create distinct moods. Long haul, for instance, creates a frantic suspenseful mood as you must run further and further away from an autodetonator with a very short fuse in order to reposition bombs that are further and further away.

  39. Building Levels: Create a Mood #16 Long Haul It is easy to see that the autodetonator and 1 bomb cannot move, so the solution must be to create a chain of 3 bombs reaching from one end to the other.

  40. Building Levels: Create a Mood #16 Long Haul Or is it really that easy? A bit of analysis will show that the previous solution cannot be achieved, so a modified chain like this is necessary.

  41. Building Levels: Use Math #39 Peninsula Puzzle designers often mine mathematics for ideas. Shown above is a puzzle based on the mathematical idea of a tour. The goal is to draw a closed path that visits every square once, using all the red lines. The unique solution is shown at right.

  42. Building Levels: Use Math #39 Peninsula I decided to make a puzzle for Charlie Blast that used the idea of a tour. Suppose the tiles above are all breakaway tiles, which means you can only step on them once. How would you push all three one bombs off the bottom edge of the square? One solution is shown at right.

  43. Building Levels: Use Math #39 Peninsula After a bit of work I came up with this more difficult tour puzzle. The goal is to push all three 1 bombs off the bottom edge of the square by walking a single path. The unique solution requires that you visit every square exactly once.

  44. Building Levels: Use Math #39 Peninsula Here’s the final puzzle. The purple electric bombs act like 2 bombs, except if one electric bomb blows up, the other also blows up. Since the electric bomb along the bottom edge cannot be pushed up toward the 1 bombs, the three 1 bombs must be pushed down to surround it.

  45. Building Levels: Exploit Features #30 Moving Ground Another strategy is to exploit a feature. Shown above are two states of the same board, built entirely of moving platforms. The tall rectangles move left and right, while the wide rectangles move up and down. The green arrows show how the 2 bomb could be pushed.

  46. Building Levels: Exploit Features #30 Moving Ground Here is the final puzzle. The ground at the bottom is stable, while the ground at the top is moving. The goal is clear: build a chain of bombs between the immovable detonator at left and 1 bomb at right. But getting there requires a hair-raising ride around the platforms.

  47. Building Levels: Exploit Features #30 Moving Ground This puzzle is easier to analyze if we collapse time and push all the platforms together so all adjacencies are present at the once. The green arrows show all paths that bombs can follow as they move around the platforms. Removing the dead ends, we discover the loop at right.

  48. Building Levels: Lay a Trap #58 Tadpole Finally, puzzles can trick you into pursuing the wrong line of reasoning. For the puzzle Tadpole, I started by observing that a puzzle involving a 2 bomb, detonator and six 1 bombs must end with the 2 bomb and detonator surrounded by the 1 bombs.

  49. Building Levels: Lay a Trap #58 Tadpole With that analysis in mind, this puzzle appears to be simple: push the autodetonator into the pocket, seal the opening with a 1 bomb, then sit back and watch the fireworks.

  50. Building Levels: Lay a Trap #58 Tadpole By adding a couple of spikes I gave the puzzle a new wrinkle.

More Related