37
Interactive Fiction Language (IFL)

Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

Interactive FictionLanguage

(IFL)

Page 2: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

Team Introduction

Project Manager: John LiuLanguage Guru: Matthew SuozzoSystem Architect: Michael Yan

System Integrator: Qian YuSystem Tester: Heather Fisher

Page 3: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

Interactive Fiction = ?

● Text Adventure

● Story-Driven

● Interactive

Page 4: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

Goals of our IF Language

● Easily Create Interactive Fiction

● Minimal Programming Experience Needed

Page 5: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

Our User

● Familiar with programming concepts

● Mostly a Game Designer○ (instead of coder)

Page 6: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

Goals of our IF Language

● Easily Create Interactive Fiction

● Minimal Programming Experience Needed

● Decouple Roles of Writer & Programmer○ eg. Dialogue Trees

Page 7: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

Language Design

Matthew Suozzo

Page 8: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

Buzzwords

Page 9: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

What we Got

4 Object Types (TLTs)

Item Trait

SettingCharacter

Page 10: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

What we Got

4 Primitive Types

String TF (bool)

DecimalInteger

Page 11: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

Language Structure

● Program is list of defined types (TLTs)ITEM Apple:{block}:{statements}

● PLAYER Character is like main method

STARTS : ConstructorACTIONS : Actions available in gameFUNCTIONS : Functions available in the codeDIALOGUE : Defines Dialogue

Page 12: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

Syntax / StatementsADD item TO charREMOVE item FROM charSET val TO 3PRINT str . "str"MOVE char TO locEXECUTE func WITH arg1INITIATE DIALOGUE AT #LABEL#INCREASE val BY 3DECREASE val BY 1NUMBER OF item IN charGOTO #LABEL#USING "diag.txt"EXIT

IF case1:{statements}

ELSE IF case2:{statements}

ELSE:{statements}

ADD {STRING s="hello"}

Page 13: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

Sample Code SnippetCHARACTER maid:

“I am a maid of the house.”START:

USES “Text.txt”ADD apple TO SELF

ACTIONS:“talk”

IF SELF HAS apple:INITIATE DIALOGUE AT #LABEL A#

ELSE:INITIATE DIALOGUE AT #LABEL D#

DIALOGUE:#LABEL A#:

IF LAST_INPUT EQUALS “1”:GOTO #LABEL B#

ELSE IF LAST_INPUT EQUALS “2”:GOTO #LABEL C#

#LABEL B#:IF LAST_INPUT EQUALS “1”:

REMOVE appleADD apple TO PLAYERGOTO #LABEL C

ELSE IF LAST_INPUT EQUALS “2”:EXIT

Page 14: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

Sample Code Snippet#LABEL A#Maid: Hi, can I help you?(1) Ask where you are(2) Ask for an item

#LABEL B#Maid: You are in the bedroom of a old house.(1) Ask for an item(2) Exit

#LABEL C#The maid gives you an apple(1) Ask where you are(2) Exit

#LABEL D#Maid: Hi, can I help you?(1) Ask where you are

#LABEL E#Maid: You are in the bedroom of a old house.(1) Exit

Page 15: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

DEMO!

Michael Yan

Page 16: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

System Architecture

Michael Yan

Page 17: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

CHARACTER John:START:

MOVE SELF TO IFLACTIONS:

"talk"PRINT "Hello"

[CHARACTER, John:START:MOVE SELF TO IFLEND_BLOCKACTIONS:"talk"PRINT "Hello"END_BLOCK

]

Page 18: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

LexToken(CHARACTER,'CHARACTER',1,0)LexToken(ID,'John',1,10)LexToken(COLON,':',1,14)LexToken(START,'START',2,16)LexToken(COLON,':',2,21)LexToken(MOVE,'MOVE',3,23)LexToken(ID,'SELF',3,28)LexToken(TO,'TO',3,33)LexToken(ID,'IFL',3,36)LexToken(END_BLOCK,'END_BLOCK',4,40)

[CHARACTER, John:START:MOVE SELF TO IFLEND_BLOCKACTIONS:"talk"PRINT "Hello"END_BLOCK

]

Page 19: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

('John', None,

('START', ('MOVE',

('OBJ', 'SELF'),('OBJ','IFL')

),('ACTIONS',

('talk', ('PRINT',

('Hello') )

), None, None)

def p_move(p):'move : MOVE object_chain TO

object_chain'

p[0] = (p[1], p[2], p[4])

Page 20: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

ProgramTLT (John)

startStatement

(MOVE) ('OBJ', SELF) ('LOC', IFL)

actionsAction (talk)

StatementPRINT ('Hello')

('John', None,

('START', ('MOVE',

('OBJ', 'SELF'),('OBJ','IFL')

),('ACTIONS',

('talk', ('PRINT',

('Hello') )

), None, None)

Page 21: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

class John:def __init__(self):

self.location = 'IFL'def talk():

print 'Hello'

CHARACTER John:START:

MOVE SELF TO IFLACTIONS:

"talk"PRINT "Hello"

Page 22: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

System Integration

Qian Yu

Page 23: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

How The Pieces Fit

compiler.py

ifl_lex.py semantic_analyzer.pyifl_yacc.py generator.py

./ifl your_file.ifl

game/*

preprocessor.py

Page 24: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

What's Actually Generated?

● a game/ directory

● a .py class file for each object type (Item, Character, Trait, Setting)

● a main game file (game.py) that actually

runs the game

Page 25: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

Execution Environment

● game.py● instantiate and setup characters and

settings● Enter into read-evaluate-print-loop (REPL)

○ Get User Command○ Search for Command in Action List of Current

Setting○ Call Appropriate Functions○ Print Results○ Update Availables Actions○ Repeat

Page 26: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

Development Environment

● Python Lex/Yacc (PLY)

● Git and Github for Version Control

● IDE/Debugger: PyCharm

● Terminal for Running and Testing

Page 27: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

Testing

Heather Fisher

Page 28: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

Testing Process

● Unit Test

● Test as we go

Page 29: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

Test Suite

Page 30: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

Sample Test Program

● Will this program work?

Page 31: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

Results

● Missing ADD{INTEGER max = 100} TO SELF

Page 32: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

Why Testing is Important

● Test early and test often!

● You never know what will break your code

Page 33: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

Project Management

John Liu

Page 34: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

Project Process

● Waterfall Methodology to Agile Development

● Python & Java to Python Only

● Team Organization○ Weekly Meetings, Google Hangout, Instant Messaging○ Google Docs, Github

Page 35: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

Lessons Learned

● Taking Advantage of Version Control (Git)

● Group Development vs Working Individually

● Communicate, Communicate, Communicate!

Page 36: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

Possible Expansion

● Expand Character Encoding

● Support for Libraries

● Dialog Tree markup

● More Customization Options○ Support for Multiplayer / Networking

Page 37: Interactive Fiction Language - Columbia Universityaho/cs4115_Spring-2013/lectures/13... · 2013. 11. 27. · Sample Code Snippet #LABEL A# Maid: Hi, can I help you? (1) Ask where

The End

IFL: Do you have any questions?(1) Yes(2) No>> _