GridLok PLT Spring 2016 Final Project players{ Julian Edwards, - - PowerPoint PPT Presentation

gridlok
SMART_READER_LITE
LIVE PREVIEW

GridLok PLT Spring 2016 Final Project players{ Julian Edwards, - - PowerPoint PPT Presentation

GridLok PLT Spring 2016 Final Project players{ Julian Edwards, Laura Hu, Alice Hwang, Bryan Yu } The Language Our goal: The purpose of GridLok is to more easily facilitate the creation of grid-based games, such as


slide-1
SLIDE 1

GridLok

PLT Spring 2016 Final Project

slide-2
SLIDE 2

players{ “Julian Edwards”, “Laura Hu”, “Alice Hwang”, “Bryan Yu” }

slide-3
SLIDE 3

The Language

slide-4
SLIDE 4

Our goal:

The purpose of GridLok is to more easily facilitate the creation of grid-based games, such as Tic-Tac-Toe, Minesweeper, or even Chess, along with their user interface. Our language implements various unique for- loops to make it easier to code for different parts of the board. Additionally, GridLok makes use of the SDL C library to render the images for the game user interface.

slide-5
SLIDE 5

Language specifics:

game board dimensions image players turnOrder piece name

  • nTurn
  • nClick

setup winCondition loseCondition drawCondition return visible def set if else for place in row col surrounding AND OR all print place removePiece remove click changeType break setVisibility

slide-6
SLIDE 6

For loops:

Format: Use: for pieceID in row(int){...} for pieces in a row r for pieceID in col(int){...} for pieces in a column c for pieceID surrounding(int,int){...} for pieces surrounding a coordinate (x,y) for (intID,intID) surrounding(int,int){...} for coordinates surrounding a coordinate (x,y) for intID(int x,int y){...} for loop over a range of ints (x,y) for(intID,intID) in board{...} for loop over all coordinates of a board for intID(int,int), intID(int,int){...} nested for loops for ranges of ints for all pieceID in board{...} for all spaces of a board

slide-7
SLIDE 7

Source Code

slide-8
SLIDE 8

tictactoe.gl Scanner Parser Semantic Check C Code Gen Token stream AST SAST gcc yay!

slide-9
SLIDE 9

scanner.mll

Total: 67 Lines

slide-10
SLIDE 10

parser.mly

Total: 173 Lines

slide-11
SLIDE 11

ast.ml

Total: 129 Lines

slide-12
SLIDE 12

sast.ml

Total: 82 Lines

slide-13
SLIDE 13

semant.ml

Total: 328 Lines

slide-14
SLIDE 14

codegen.ml

Total: 549 Lines

slide-15
SLIDE 15

gridlok.ml

Total: 8 Lines

slide-16
SLIDE 16

Compiling a .gl file

slide-17
SLIDE 17

gridlok.sh

./gridlok.sh [.gl file] [optional executable name]

  • If executable name not given, defaults to test
slide-18
SLIDE 18

Testing

slide-19
SLIDE 19

run_tests.sh

./run_tests.sh

  • Checks tests/ directory and takes all files starting

with test_ or fail_ and ending with .gl

  • For test_ files:

○ Makes executable, then runs it and redirects stdout to a .out file of the same filename in tests/output/ directory

  • For fail_ files:

○ Same as test_ files, but redirects stderr to the .out file

  • Checks diff between the .out file in the tests/

directory and the .out file in the tests/output/ directory

  • If no difference, deletes .diff file and returns OK

message

  • If there is a difference, keeps .diff file and returns

FAILED message

  • All test messages are logged in test.log file
slide-20
SLIDE 20

Example Code

slide-21
SLIDE 21

Tic-tac-toe

slide-22
SLIDE 22

Minesweeper

slide-23
SLIDE 23

GridLok vs. Java

543 Lines?! 130

slide-24
SLIDE 24

GridLok vs. Command Line C++

  • 192 Lines?! 80
  • NO GUI?! WHAT IS THIS S&$%?
slide-25
SLIDE 25

Future Ideas

  • Standard library of pieces, boards,

games, movement functions, etc.

  • Picking up pieces
  • Improve final conditions
  • Additional game settings (timers, etc…)
  • More GUI features
slide-26
SLIDE 26

Lessons learned

  • Start early
  • Ask the TA questions frequently
  • Start early
  • Jane Street is not for us
  • Start early
  • Good thing we like each other
slide-27
SLIDE 27

winCondition{ def str grade{“A”} print{“Thank you!”} return {true} }