compiler integration into computer science learning games

62
Compiler Integration into Computer Science Learning Games Amanda Chaffin [email protected] Advisor: Dr. Tiffany Barnes [email protected]

Upload: connie

Post on 06-Jan-2016

22 views

Category:

Documents


0 download

DESCRIPTION

Compiler Integration into Computer Science Learning Games. Amanda Chaffin [email protected] Advisor: Dr. Tiffany Barnes [email protected]. Background Game2Learn Ele Mental : The Recurrence Implementation The Study Conclusion Future Work. Motivation Solution Game Creation - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Compiler Integration into Computer Science Learning Games

Compiler Integration into Computer Science Learning Games

Amanda [email protected]

Advisor: Dr. Tiffany [email protected]

Page 2: Compiler Integration into Computer Science Learning Games

Chaffin - G2L platform October 29, 2008

2

OutlineBackgroundGame2LearnEleMental : The

Recurrence ImplementationThe StudyConclusionFuture Work

MotivationSolutionGame CreationLearning Games GoalHypotheses

Page 3: Compiler Integration into Computer Science Learning Games

Chaffin - G2L platform October 29, 2008

3

MotivationRising demand for CS majors (Vesco, 2007)

But enrollments are falling! And many enrolled students leave after CS1-2

Why? (Beaubouef, 2005)

Lack of problem solving skills Miscommunication Homework, lecture, code

Page 4: Compiler Integration into Computer Science Learning Games

Chaffin - G2L platform October 29, 2008

4

SolutionGames for learning computer scienceLess abstract, more familiarProven results –

Students creating games Students learning from games

Page 5: Compiler Integration into Computer Science Learning Games

Chaffin - G2L platform October 29, 2008

5

Game CreationMineSweeper and Asteroids (Becker, 2001)

University of Calgary

Game Programming in CS1 (Bayliss, 2006)

Rochester Institute of Technology

Capstone Courses (Jones, 2000)

Colby College

Page 6: Compiler Integration into Computer Science Learning Games

Chaffin - G2L platform October 29, 2008

6

Learning GamesRevolution (Jenkins 2003)

Neverwinter Nights

MUPPETS (Bierre, et al. 2006) TankBrain

Tactical Iraqi (Johnson, et al. 2007)

Marine Corps

Alice (Mullins, 2008)

Page 7: Compiler Integration into Computer Science Learning Games

Chaffin - G2L platform October 29, 2008

7

GoalTo have students learn computer science

While playing games With maximal skill transfer Without breaking the sense of being in game

In other words, students should write code, if at all, inside the game

Page 8: Compiler Integration into Computer Science Learning Games

Chaffin - G2L platform October 29, 2008

8

HypothesesStudents who play a learning game where

Students can write and compile code inside the game

Will effectively learn computing conceptsStudents who make a learning game

where other students write code will Learn the coding concepts better Be able to teach the concepts

Page 9: Compiler Integration into Computer Science Learning Games

Chaffin - G2L platform October 29, 2008

9

OutlineBackgroundGame2Learn (G2L)EleMental : The

RecurrenceImplementationThe StudyConclusionFuture Work

History of G2L Saving Sera The Catacombs Squee StormHaven3 Wu’s Castle

Limitations

Page 10: Compiler Integration into Computer Science Learning Games

Chaffin - G2L platform October 29, 2008

10

History

Page 11: Compiler Integration into Computer Science Learning Games

Chaffin - G2L platform October 29, 2008

11

Game2Learn GamesRapid prototyping

Saving Sera The Catacombs Squee! The Tournament Wu’s Castle

What we learned Fun != learning It’s all about the

motivation Design of concept most

important

Page 12: Compiler Integration into Computer Science Learning Games

Chaffin - G2L platform October 29, 2008

12

LimitationsNeverwinter Nights Limitations

Cannot change the GUI Compiler integration possible but limited to NWN

Script

RPG Maker 2D platform; not modular enough for robust

development Compiler integration might be possible but would be

limited to Ruby

Page 13: Compiler Integration into Computer Science Learning Games

Chaffin - G2L platform October 29, 2008

13

OutlineBackgroundGame2Learn (G2L)EleMental : The

RecurrenceImplementationThe StudyConclusionFuture Work

Designing G2L Games

DarkWynter Code Design

Game Design : Recursion

VideoInterfacesPre/Post Test

Page 14: Compiler Integration into Computer Science Learning Games

Designing G2L Games (Barnes, 2007)

Choose target concept Design code to illustrate conceptGet players to construct target codeMight need to provide scaffolding codeNeed instructions

Chaffin - G2L platform October 29, 2008

14

Page 15: Compiler Integration into Computer Science Learning Games

DarkWynter Code DesignUsing previous pedagogy, why?

Obvious data structure (tree) Standard algorithm (DFS) Engine supported (real time terrain mods) Scaffolding code

Chaffin - G2L platform October 29, 2008

15

Page 16: Compiler Integration into Computer Science Learning Games

Game Design – Recursionre·cur·sion (rĭ-kûr'zhən)

–noun Mathematics, Computers

See recursion

Chaffin - G2L platform October 29, 2008

16

Page 17: Compiler Integration into Computer Science Learning Games

Game Design – con’tDesigned by Wicked Fly GamesUses Depth First Search Walkthroughs

Build bridges Collect thoughts

Chaffin - G2L platform October 29, 2008

17

Page 18: Compiler Integration into Computer Science Learning Games

Video

Chaffin - G2L platform October 29, 2008

18

Page 19: Compiler Integration into Computer Science Learning Games

Pre & Post Test

MAIN

getProduct()

getProduct()

getProduct()

1) getProduct(3)

2) getProduct()

3) getProduct()

4) result =

5) result = 2

6) result =

public int getProduct(int num) {

int result;if (num == 1) { result = 1;

} else

{ result = num * getProduct(num - 1); }

return result;}

1.What is the value passed to getProduct() in step 2? Answer = 2

2.What is the value of 'result' at step 6?Answer = 6

1.What is the value passed to getProduct() in step 2?

2. What is the value of 'result' at step 6?

Page 20: Compiler Integration into Computer Science Learning Games

Chaffin - G2L platform October 29, 2008

20

OutlineBackgroundGame2Learn (G2L)EleMental : The

RecurrenceImplementationThe StudyConclusionFuture Work

DarkWynter Engine Modifications Nuclex Game Control Architecture

In-Game Compilation CompilerControls Challenge Objects Event System HUD Redevelopment Custom Game Objects AI Modifications Survey Controller Instructions Control

Page 21: Compiler Integration into Computer Science Learning Games

Chaffin - G2L platform October 29, 2008

21

XNA Microsoft’s hobbyist game development

platform using C# and .Net Allows development with Visual Studio

Used to develop DarkWynter UNCC’s Game Studio Class (2007)

Page 22: Compiler Integration into Computer Science Learning Games

Chaffin - G2L platform October 29, 2008

22

DarkWynter ModificationsGoal

Build games that allow for writing and running code within them

DarkWynter allows complete controlModified to allow addition of

Editing window & other forms needed Compiling and running code in the game

Page 23: Compiler Integration into Computer Science Learning Games

Chaffin - G2L platform October 29, 2008

23

Forms: Nuclex Game ControlOpen source XNA modificationAllows multiple form use in XNA

This is not built in; XNA games run in a single form Controls multiple forms through Forms User Control XNA runs in one form, allowing others to be made

Disconnects code window from game update()Overrides onPaint() and controller methods

http://www.nuclex.org/news/2007/05/14/xna-windows-forms-usercontrol

Page 24: Compiler Integration into Computer Science Learning Games

Chaffin - G2L platform October 29, 2008

24

In-Game CompilationRuntime compilation with .Net CodeDom

Code Document Object Model Graph (tree) representation of code

CSharpCodeProvider Implements the ICodeCompiler

• Compiles a CodeDom Tree with C# CompilerParameters.GenerateInMemory

• Allows in-game code to run from memory CompilerParameters.ReferencedAssemblies.Add()

• Allows in-game code to access engine

Reference: http://support.microsoft.com/kb/304655

Page 25: Compiler Integration into Computer Science Learning Games

Chaffin - G2L platform October 29, 2008

25

CompilerControls Architecture

Page 26: Compiler Integration into Computer Science Learning Games

Chaffin - G2L platform October 29, 2008

26

Challenge Objects

Page 27: Compiler Integration into Computer Science Learning Games

Chaffin - G2L platform October 29, 2008

27

Event SystemCreated by WickedFly Games (Katelyn

Doran, UNCC and Drew Hicks, Marietta College) and modified by DarkWynter

Turned the Engine from a FPS to an RPGLoads from Engine.cs using XMLEvents triggered by changing

CurrentGameConditions

Page 28: Compiler Integration into Computer Science Learning Games

Event System Architecture

Chaffin - G2L platform October 29, 2008

28

Page 29: Compiler Integration into Computer Science Learning Games

HUD RedevelopmentDarkWynter was a 4-player game

4 Humans each had own HUD Did not have an update()

For G2L Decoupled from Human, coupled with Renderer Changed to Public Static Added an update loop Changed all add methods to return list location Changed all graphics and text

Chaffin - G2L platform October 29, 2008

29

Page 30: Compiler Integration into Computer Science Learning Games

HUD Updates Con’tRedesigned for Dialogue Events

Update() with a timer that controls the rest ShowDialogue() RemoveDialogue()

Dialogue Events redesigned To accept textures from XML

Chaffin - G2L platform October 29, 2008

30

Page 31: Compiler Integration into Computer Science Learning Games

Chaffin - G2L platform October 29, 2008

31

Custom Game Objects Thoughts()

Collectible items Models created by Wicked

Fly Games

Arrows() Indicators of location Created by Wicked Fly

Games

WaterPlane() Water plane to keep

students on island Custom built Shader

• Blends two textures

Page 32: Compiler Integration into Computer Science Learning Games

AI ModificationsThoughtAI()

Walk in a straight line algorithm Had problems with

• Rotation• XML position loading• Walk speed

Page 33: Compiler Integration into Computer Science Learning Games

Chaffin - G2L platform October 29, 2008

33

Survey ControllerIntegrates pre and post test into gameWhat it does –

Creates a new Form Loads data from XML into the Form Validates answers Writes results to a log

Page 34: Compiler Integration into Computer Science Learning Games

Instructions ControlEducational instructions for the student’s

use to guide through code developmentWhat it does –

Creates a new Form Loads the InstructionSet for the Level from

XML into Form Can be used to prevent students from

compiling code until read

Chaffin - G2L platform October 29, 2008

34

Page 35: Compiler Integration into Computer Science Learning Games

Chaffin - G2L platform October 29, 2008

35

OutlineBackgroundGame2Learn (G2L)EleMental : The

RecurrenceThe StudyConclusionFuture Work

DesignResultsPre and Post TestCompiler ErrorsQualitative

Comparisons

Page 36: Compiler Integration into Computer Science Learning Games

Chaffin - G2L platform October 29, 2008

36

Pilot Study DesignPilot Study

Current CS 2214 and 2215 students recruited via the professor

Study consists of – Demographic survey & pre-test Play game Post test & survey

Data logged by game and automatically (non secure) FTPed

Page 37: Compiler Integration into Computer Science Learning Games

Chaffin - G2L platform October 29, 2008

37

Study Results43 total participants

27 took incorrect pretest 16 took valid pre and post test 1 non computing major 1 freshman, 1 sophomore, 10 juniors, 3

seniors, and 1 post Baccalaureate 13 men, 3 women 5 casual gamers, 4 hardcore, 7 neither

Page 38: Compiler Integration into Computer Science Learning Games

Chaffin - G2L platform October 29, 2008

38

PreTest/PostTest

0

1

2

3

4

5

6

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

Pretest

Posttest

Page 39: Compiler Integration into Computer Science Learning Games

Chaffin - G2L platform October 29, 2008

39

Pre/Post/Compilation Attempts

0

1

2

3

4

5

6

7

0:01:18 0:03:38 0:05:20 0:05:42 0:06:14 0:08:29 0:08:38 0:10:32 0:11:03 0:11:09 0:12:11 0:12:39

Average Time

PreTest

Posttest

Attempts

Page 40: Compiler Integration into Computer Science Learning Games

Chaffin - G2L platform October 29, 2008

40

Qualitative Comparisons

Page 41: Compiler Integration into Computer Science Learning Games

Favorite Aspects of EleMental?

In Game Coding18%

Visualization39%

Education24%

Hints12%

Game Play7%

In Game Coding

Visualization

Education

Hints

Game Play

Page 42: Compiler Integration into Computer Science Learning Games

Study Quotes

“The fact that I write my own code to make the game work.”

“Gaming assignments are better because a lot of people enter

computer science wanting to do things like gaming, and are disappointed because all they get to do in the first few assignments is write code to calculate tax on different stuff.”

“I liked the whole experience of walking through the paths and then

typing the code and then doing it again for repetition.”

“Finding C# is very similar to Java.”

Page 43: Compiler Integration into Computer Science Learning Games

Suggested Game Improvements

Add Audio6%

Improve Mini Map24%

More levels & challenges

9%

Improve Instructions24%

Improve Visualizations

8%

Improve Engine29%

Add Audio

Improve Mini Map

More levels & challenges

Improve Instructions

Improve Visualizations

Improve Engine

Page 44: Compiler Integration into Computer Science Learning Games

Traditional Vs. Game Assignments

Neutral5%

Game73%

Traditional20%

Page 45: Compiler Integration into Computer Science Learning Games

Chaffin - G2L platform October 29, 2008

45

ConclusionWhat we learned

Code concepts Agile development Good code no substitute for proper design! Parsing is HARD!

Limitations Needs Shader 3.0 graphics support Cannot run on laptops

Downloadable through SVN

Page 46: Compiler Integration into Computer Science Learning Games

Future Study Hypothesis – students who play EleMental: The

Recurrence with access to the in game compiler will show significantly higher learning gains than a comparison group that plays without the compiler. Crossover study –

• Half play the game with compiler

• Half play without

• Swap

Chaffin - G2L platform October 29, 2008

46

Page 47: Compiler Integration into Computer Science Learning Games

Future Engine Work Level Creation currently at 5 hours for 2 people Database Address Engine Concerns

Direction Indicators Reconnect XP to HUD Bug Fixes

Expansions into other data structures Heaps Lists Stacks

Chaffin - G2L platform October 29, 2008

47

Page 48: Compiler Integration into Computer Science Learning Games

Thank You!

Amanda Chaffin & Dr. Tiffany Barnes

[email protected]

unc Charlotte

This work was partially supported by the National Science Foundation GrantsNo. CNS-0552631 and CNS-0540523, IIS-0757521, and the UNC Charlotte Diversity in Information Technology Institute.

Page 49: Compiler Integration into Computer Science Learning Games

Chaffin - G2L platform October 29, 2008

49

Works Cited1. Barnes, T., A. Chaffin, E. Powell, H.Lipford. Improving the motivation of CS1 students

through games for learning. Submitted to the Journal of Game Development. Boston, MA. January 2008.

2. Barnes, T., H. Richter, A. Chaffin, A. Godwin, E. Powell. (2007). Game2Learn: Building CS1 Learning Games for Retention. ITiCSE2007: 121-125

3. Barnes, T., H. Richter, A. Chaffin, A. Godwin, E. Powell, T. Ralph, P. Matthews, and H. Jordan. (2006). Game2Learn: A study of games as tools for learning introductory programming. Submitted to SIGCSE2007, Kentucky, USA, March 2006.

4. Barnes, T., H. Richter, A. Chaffin, A. Godwin, E. Powell. (2006). The role of feedback in Game2Learn. Submitted to CHI2007, San Jose, CA, April 2006.

5. Vegso, J. Continued Drop in CS Bachelor's Degree Production and Enrollments as the Number of New Majors Stabilizes. Computing Research News, Vol. 19, No. 2, March 2007.

6. Beaubouef, T., & Mason, J, 2005. Why the high attrition rate for computer science students: Some thoughts and observations. ACM SIGCSE Inroads Bulletin, 37(2), 2005, 103-106.

7. Becker, Katrin. Teaching with games: the Minesweeper and Asteroids experience, Journal of Computing Sciences in Colleges, v.17 n.2, p.23-33, December 2001.

8. Bayliss, Jessica D and Sean Strout, Games as a "flavor" of CS1, Proceedings of the 37th SIGCSE technical symposium on Computer science education, March 03-05, 2006, Houston, Texas, USA

Page 50: Compiler Integration into Computer Science Learning Games

Works Cited Con’t1. Jones, Randolph M. "Design and Implementation of Computer Games: A Capstone Course for

Undergraduate Computer Science Education", Proceedings of the 31st SIGSCE Symposium in Computer Science Education, March 2000, Austin, TX. p260-264

2. Ian Parberry , Timothy Roden , Max B. Kazemzadeh, Experience with an industry-driven capstone course on game programming: extended abstract, Proceedings of the 36th SIGCSE technical symposium on Computer science education, February 23-27, 2005, St. Louis, Missouri, USA

3. Jenkins, Henry, Eric Klopfer, Kurt Squire, and Philip Tan. "Entering the Education Arcade." Source Computers in Entertainment, Volume 1, Issue 1. (October 2003): 17-17. August 27, 2006.

4. Bierre, K., Venture, P., Phelps, A. & Egert, C. (2006). Motivating OOP by blowing things up: An exercise in cooperation and competition in an introductory javaprogramming course. ACM SIGCSE Bulletin, Proceedings of the 37th SIGCSE technical symposium on Computer science education SIGCSE '06, 38(1).

5. Losh, Elizabeth. "In Country with Tactical Iraqi: Trust, Identity, and Language Learning in a Military Video Game." Virtualpolitik. 2006. August 3, 2006. http://virtualpolitik.org/DAC2005.pdf

6. Mullins, P, Whitfield, D., and Conlon, M. 2008. Using Alice 2.0 as a First Language. To appear in CCSC 24th Annual Eastern Conference 2008 (Hood College, Frederick, Maryland, October 10 and 11, 2008).

7. Eagle, M. Barnes T. (2008) Wu’s Castle: Teaching Arrays and Loops in a Game. Proceedings of ACM’s Innovation and Technology in Computer Science Education (ITiCSE 2008), Madrid, Spain, June 30 –July 2, 2008

8. Johnson, W. L., Wang, N., and S. Wu, "Experience with serious games for learning foreign languages and cultures," in SimTecT Conference., Australia, 2007.

Page 51: Compiler Integration into Computer Science Learning Games
Page 52: Compiler Integration into Computer Science Learning Games

Challenge Objects Code

Page 53: Compiler Integration into Computer Science Learning Games

Events : XML SettingsEach Event has

TypeID Parameters Triggers

Page 54: Compiler Integration into Computer Science Learning Games

DarkWynter Architecture

Page 55: Compiler Integration into Computer Science Learning Games

DarkWynter Architecture

Controller

MenuController

GameController

AI/LogicController

// Associate Keys with Delegate functions, using keytimer to control input refresh rate.public GameController( int playerNumber): base(playerNumber){ Add(new KeyboardControl (Keys.W, MoveForward, 10)); Add(new MouseControl (Enums_Engine .ControlType.Motion, Rotate, 0));}

private void MoveForward( ControllerBoolEventArgs args){ args.objectLibrary.humans[playerNumber].Translate( new Vector2(0, 10));}private void Rotate(ControllerVec2EventArgs args){ args.objectLibrary.humans[playerNumber].Rotate(args.value);}

Logical Controllers

Keyboard Control

Mouse Control

Xbox Analog Control

Xbox Digital Control

Hardware Controls

Add call associates Keys with Delegate functions.Any combination of Hardware Controls can be included in a Logical Controller.

Page 56: Compiler Integration into Computer Science Learning Games

DarkWynter ArchitectureMenu System

Engine

MenuSystem

GameScreen GameMenuElement

GameMenuButton

GameMenuLabel

GameMenuValueInput

GameMenuRandomImageDisplay

GameMenuImageScroller

GameMenuOption

GameOverScreen

PauseScreen

SorryScreen

OpeningCreditsScreen

LoadingScreenGameSetup

TitleScreen

InstructionScreen

Cera1

Cera2

Cera3

Cera4

Cera5

GameMenu GameMenuController

Can Have

Handles Current GameMenu'sLoad, Update, and Draw

Page 57: Compiler Integration into Computer Science Learning Games

DarkWynter Architecture

G am e O bjects

G am e O bjectM eta representation of an object in 3D space.

G am eO bject d lls are loaded into the engine abstractly.O verridable default procedures a llow rapid deploym ent and custom ization.

O bject L ibraryM ainta ins type specific lis ts of a ll G am eO bjects.

Regulates the G am eO bject's Load and Update functions.

PlayerTerra in

Load()

Porta l

A rrow

Bom b

C oin

Skysphere

W aterP lane

TriggerP laneLandscape

G PU O bjects

Prop

BulletPartic le

B illboard

Update()

Draw ()

PostDraw ()

ObjectTerrainCollisionResponse()

ObjectObjectCollisionResponse()

XmlNodeObject

MassObject

DrawObject

CollisionEvent-based response to

O bject and Terra in co llis ions.

RenderRegulates G am eO bject D raw

and Postdraw ca lls

Exam ple

G am eO bjectVirtua l Functions

Page 58: Compiler Integration into Computer Science Learning Games

DarkWynter ArchitectureHeads Up Display

Engine Heads Up Display ObjectLibrary

HumanGameEventHandler

HUDMapEvent

StackEventDialogueEvent

Initialize&

Update

Create and UpdateHuman Specific Objects

Draw

Manages Scripted Hud Events

Engine initializes and drives HUD updates through static accessors. Human creates HUD and updates it's own elements. GameEventHandler initializes and handles updates for scripted HUD Events, Scripted events attach to player through object collision response functions (see EventSystem).

Page 59: Compiler Integration into Computer Science Learning Games

DarkWynter ArchitectureEvent System

GameEventHandler

GameEvent

EventConditions

DialogueEvent

TerrainEvent

HUDMapEvent

AIEvent

LevelChangeEvent

StackEvent

Loaded from Xml

Game-Event Types

Events are triggered by modifying the public static CurrentGameConditions .

Updating CGC conditions auto-checks potential matches between CGC and the Xml-defined GameEvents..(aka - Static Board Evaluation)

The Event System fires matched events, then removes them from the list.

Updates the HUD with the new dialog

Sets the new position for the AI to go to

Builds the terrain between a predetermined set of points

Builds the stack on the HUD based on Player.mass.CurrentPosition

Updates the location map on HUD to reflect Nodes traveledDrops events and reloads level

CurrentGameConditions

Set by Runtime

<-- Comparison -->

Page 60: Compiler Integration into Computer Science Learning Games

DarkWynter ArchitectureRenderer

Engine

Render

Draw

ObjectLibrary

GameObject

Attach Delegates to ObjectLibrary.Update Graphics Device Settings.

Execute Draw Sequence

Calls order-dependent Draw delegates.Return all GameObjects drawn in the current frame.

Independent draw component

Renderer manages graphics device setup and shutdown operations for Engine through delegates, allowing Engine to manage the internal draw order of the following order-dependent categories.

Object Library - GameObjects or 3D World-space objectsSprites - Billboards or 2D World-space objectsHeads Up Display - 2D Screen-space objects

Page 61: Compiler Integration into Computer Science Learning Games

DarkWynter ArchitectureCompiler and Challenges

CompilerControl

Engine

XML

ChallengeAbstract

Challenge0

Challenge1

Challenge2

Challenge3

Public static accessorsused to control

Engine mechanicsfrom Application.

CSharpCompiler

Compile andreturn Results

The CompilerControl loads the Challenges from XML. Compilation is triggered by user button-click, which sends the student code to the CSharpCompiler. The CSharpCompiler compiles the code in memory (though it canbe compiled to an exe or a dll) and returns the CompilerResults to the CompilerControl,

Running the compiled code is also triggered by user button-click which calls the CS harpCompiler.execute() function, invoking the code in memory.

Aside from compilation, Challenges may verify student code through parsing (it will not run unless the code matches the parsing) allowing validation of code-style before triggering the first set of Events.

Page 62: Compiler Integration into Computer Science Learning Games

DarkWynter Architecture

UCAD

Main

GameControl

Bottom

Default and User-Defined Control Toolkit

Left

CompilerControl

Right

LevelEditor

Instructions || Levels || Tools || Get Involved...