290 likes | 441 Views
A Semantic Analyzer for Simple Games Source Codes to Programming Learning. Elanne Cristina O. dos Santos (elannecristina.santos@ifpi.edu.br) Gleison Brito Batista Victor Hugo Vieira de Sousa Esteban Clua. It is formed by a set of java classes!
E N D
A Semantic Analyzer for Simple Games Source Codes to Programming Learning Elanne Cristina O. dos Santos (elannecristina.santos@ifpi.edu.br) Gleison Brito Batista Victor Hugo Vieira de Sousa Esteban Clua
It is formed by a set of java classes! It is using JPlay, this means the execution of the program is concentrated on JPlay classes! Student Program JPlay Motivation Many studies point to difficulties of teaching and learning the algorithms and programming. JPlay was developed in UFF university. It is a framework used for teaching programming and it provides teaching of algorithmic logic through the game development. Context
Problem • The student mayhavedifficulty to undertand some erros thathappenduring the buildingprocess of a program. • Goal • To compare two programs (student program and model program); • To make suggestions about the behaviors differences found in the student program. • The teacher adds and edits the suggestions using comments in the source code of the model. Errors Compilation Results Student Program JPlay
Summary Introduction An Heuristic based on Behaviors Comparison of Programs JPlay Standardization model Classes Pairs Classification Variables Pairs Classification And Comparison of Behavior Trees Results Conclusion
Introduction Our proposal is the development of a analyzer. The analyzerhas a functionofinterpreting a Java program developedthat uses the JPlayandreturnresults of this examination to thestudent. The process is anheuristicand it consistson: transformingalljava classes of thestudentprogramto XML files andtransformingalljava classes ofthemodelprogram to XML files. Comparing the two programs and after it combines the pairs of similar classes. checking standardization in the student program. findingsequencial patterns of Jplay in thestudentprogram. 5. comparingbehaviors of thestudentprogramandbehaviors of the model program.
What is a JPlaySequentialPattern? main() { GameLoopobject = newGameLoop(); } public class GameLoop { ..... while(true) { } } A sequencepattern of JPlayis a codesequence in the program thatmustalwayshappen. JPlay follows a typical code sequence pattern: A main method must be defined in the initialization of the program. Example: In the body of the main method objects are declared, one of these objects must contain a game loop (infinite loop). Example: C. In the class that contains the game loop (infinite loop) objects are declared, then at this point it is possible to check the behavior of these objects.
What is a behavior? The behaviors are foundwhen it happensanassigment, loop orconditional in the program class. In the XML file this is representedby a <behavior> tag. Example:
Classes Pairs Classification There are specific rules to find the first and second pair. In order to classify the first pair of similar classes we establish as a single rule that the class contains the “main” method. After, in order to classify the second pair of similar classes we establish only one rule: if the class contains the game loop. After the analyzer will take the rest of the classes of the program to be processed.
public class Ball extends Sprite { int x, j; boolean m,n; String a,b,c; } public class MyBall extends Sprite { int a, b, c; boolean d,f; } 1 0 3 Weight = 4 Classification Rule from the third pair of similar classes on • The analyzer will search pair of classes that extend from the same super class. For example: • The list of variables will be analyzed.
Standardization model In order to standardizethe student program in accordance to the model program, weproposetheusageofspecificmarkers for eachclassatthemodelprogram. A marker defines the keyword that the analyzer can find the source code. For example: @moveX = true Themarkers are definedbyteacherand it is mustbedeclaredatthebeginningofeachclass in themodelprogram. Just belowof a markerfollows a commentexplainingthe behavior associated. For example: @moveX= true @comment= “The class must has a method to move the object in the x-axis”
Markers Inheritance: Identifies the super class. Constructor: The constructor of the class must be declared. MoveX: A method to move the object on the x axis must be declared. MoveY: A method to move the object on the y axis must be declared. Keyboard:Identifiesthe use ofthe keyboard in thisclass. Mouse: Identifies the use ofthe mouse in thisclass. General Comment:thefirstcommentidentifiesthe general behavior oftheclass. SpecificsComments:Theotherscomments are specificand are associatedwitheachmarker. Just belowof a markerfollows a commentexplainingthe behavior associated. Thecomments are used to informthestudentaboutthebehaviorsoftheclass.
0 1 15 Weight = 1 Variables Pairs Classification After defining all pairs of similar classes, variables of the same type in each of the classes pair should be compared; The variables are compare according to their behaviors. The algorithm compares the variables of the same type using a list of behaviors and then the pair containing the smallest weight is rated as the most similar pair of variables. For example:
Comparison of Behavior Trees Afterthat, similar pairsofvariables are definedandthenanalyzed. In order to compare thesevariables, weproposea treestructure, calledbehavior tree. Thebehaviorstreesofboththevariables are comparedandwhenbehaviorsdifferencesoccur it is possiblethatthestudentprogramhasanerror. For example:
Comment in the program model The comment is defined by teacher in the code of the model program. The comment is inserted immediately after the behavior. For example:
Results In this paper we propose a novel heuristic that checks a JAVA code and guide a student for a specific game development. We developed a validation scenario in a classroom with 10 students of the integrated high school of the Informatics course. The students were proposed to develop a “BrickBreak” game, using JPlay framework. We analyzed the “Ball” and “Bar” classes of the 10 codes developed, based on the model program developed by the teacher.
Results – BrickBreak Game The results analysis presented here are related with two levels of analysis: Checking for standardization between programs and Comparison of the behavior trees. The Ball class has two basic specifications: it must move in the x and y axis and collide with objects. The Bar class also has two specifications: -it should move through the keyboard control, for both right and the left sides; -collide with the Ball.
Results In case of the standardization model the results were marked as: • positive when the analyzer does not detect differences between the student program and the standardization model; • negative when the analyzer detects differences between them.
Results For the behavior trees, we evaluated the results as: • false-positive when the analyzer does not detected differences, but the behavior of the object is not correct. • false-negative when the analyzer detects differences but the behavior of the object is correct. • negative when the analyzer detects differences that really it exists. • positive when the analyzer does not detect differences and the behavior of object is correct.
Students 1 and 4 used one method more than requested in the standardization of model. Suggestion for the student: “You probably defined more methods than the necessary.” In case the student 10 the different is associated to marker “movex”, this means that the class don’t implemented the movement in the x axis. Suggestion for the student: “Theclassmusthas a method to move theball in thex-axis”
In case ofthestudent 10, theprogram istotallyincorrect: Theprogram is notaccording to thestandardizationand it is notpossible compare variables, formpairofvariablesand compare thebehaviorstrees!!! Thusallthecommentsrelating to behaviorsofthe “Ball” class are suggested to thestudent.
Evaluation for the Ball class - Comparison of behavior trees Allthecommentsassociated to assignmentbehaviorsofthe “left” and “up” variables are suggested to thestudent!! In case the student 1:
Thedifferences in these classes are associatedwithmarker “Keyboard”, thismeansthatthe analyzer don’t find the key words “Keyboard” and “keydown” in the code of the classes. The sugestion is: “Please, check if you defined the movement of the bar through the keyboard control.”
In this case, thedifferences are false-negativesbecausethestudentsimplementedthe keyboard control in other classes. Thenthedifferencesdon´tchangethe general behaviorprogram. Thedifferences are negativesbecausethe bar is notreallymovingproperly in theprogram. Allthecommentsassociatedwiththismovement are suggested.
Conclusion This paper presents a novel heuristic strategybased in a analyzer that, interpreting semantically a JPlay code, guide a student for a specific game development process. Our implementations and tests are related to JPlay framework, but the proposal can easily be adapted to other program patterns.
Conclusion The results of the comparison of behavior trees show that the analyzer is not able to be totally accurate, but is able to make a suggestion closer to the truth to the student. The results of analysis according with the standardization between programs are most accurate, how much more standardized the student program, will be found less inaccuracy on comparison of the behavior trees. As future work we intend to improve the efficiency of the algorithm and obtain more results comparisons.
Thank you! elannecristina.santos@ifpi.edu.br