BGGL Board Game Generator Language COMS W4115 Programming Languages and Translators Professor Stephen Edwards Final Report cs columbia edu Matt Chu mwc2110 Steve Moncada sm2277 Hrishikesh Tapaswi hat2107 Vitaliy Shchupak vs2042 1 Contents 1 Introduction 1 1 Overview 1 2 Goals 1 3 BGGL Specific Language Conventions 1 3 1 Game 1 3 2 Board 1 3 3 Piece 1 3 4 Rule 1 3 5 Move 2 Tutorial 2 1 Getting Started 2 1 1 Environment Considerations 2 1 2 Running a BGGL Program 2 2 BGGL Basics 2 3 Example Tic tac toe 3 Language Reference Manual 3 1 Lexical Conventions 3 1 1 Comments 3 1 2 Identifiers 3 1 3 Keywords 3 1 4 Numbers 3 1 5 String Literals 3 1 6 Other Tokens 3 2 Types 3 3 Expressions 3 3 1 Primary Expressions 3 3 2 Array Element Lookup Operator 3 3 3 Multiplicative Operators 3 3 4 Additive Operators 3 3 5 Relational and Equality Operators 3 3 6 Unary Operator 3 3 7 Logical Operators 3 3 8 Assignment Operator 3 4 Statements 3 4 1 Expression Statements 3 4 2 Conditional Statements 3 4 3 Iterative Statements 3 4 4 Return Statements 3 5 Functions 3 5 1 Overview 2 4 4 4 4 4 4 5 5 5 6 6 6 6 6 8 11 11 11 11 11 12 12 12 12 13 13 13 13 14 14 14 14 15 15 15 15 15 16 16 16 4 5 6 7 8 3 5 2 Declaration 3 5 3 Invocation 3 6 BGGL Specific Language Constructs 3 6 1 Program Layout 3 6 2 Board Coordinate Conventions 3 6 3 Rule Syntax Conventions 3 6 4 Move Syntax Conventions 3 6 5 Test Syntax Conventions Project Plan 4 1 Responsibilities 4 2 Our Code 4 3 Development Environment 4 3 1 ANTLR 4 3 2 Java 1 5 4 3 3 Eclipse 4 3 4 Subversion SVN 4 3 5 JUnit 4 1 4 4 Project Timeline Important Dates Architecture Project Tests 6 1 Test Suites 6 2 Example Chinese Checkers Lessons Learned Complete Code Listing 8 1 Project Log 3 17 17 17 17 18 19 19 20 21 21 21 22 22 23 23 23 23 23 24 25 25 27 32 33 123 Chapter 1 Introduction 1 1 Overview Coding any of the familiar board games using a standard object oriented programming language like C or Java would prove decidedly tedious Even the most expert OOLuser would waste a large amount of time specifying the often repetitive characteristics of traditional board games BGGL seeks to dramatically cut down on the time a board game programmer would traditionally spend tweaking the class structure of his code while significantly enhancing the way gameplay terms i e rules are implemented Programmers using BGGL will never spend time devising the most efficient board game framework instead they ll start with a palette of boards regions pieces and rules and begin implementing their idea immediately 1 2 Goals The goal of BGGL is to abstract board games traditional frameworks and provide the programmer with a rich set of language constructs that can be used to intuitively implement the rules and flow of a game Throughout the development of BGGL the abstraction and reduction of non essential or monotonous tasks as a primary focus Ideally BGGL will not only be used by programmers seeking to mimic the functionality of existing board games electronically but utilized as an instrument for developing new games Indeed what we find most exciting about BGGL s potential relates most closely to the development of new games BGGL will quickly elucidate possible pitfalls and inspire potential enhancements 1 3 BGGL Specific Language Conventions 1 3 1 Game A game in BGGL is the equivalent of the main method in traditional programming languages Inside the game block the BGGL compiler expects to find variable initialization console input output control flow and Piece movements 1 3 2 Board The BGGL board variable is the region on which all other BGGL types perform their tasks Most other components reference the board in some way The board is initialized inside the game block of a bggl file Using a combination of empty pieces invalid pieces and existing user defined pieces any type of board is possible By this we mean boards of any shape may be specified as the Chinese checkers example will demonstrate below Currently the BGGL does not explicitly support certain complex board configurations as the internal global variable board is represented as two arraylike structures hence rectangular 4 1 3 3 Piece Pieces in BGGL are very simple Their name is basically their only attribute as the board keeps track of piece location and BGGL moves and rules dictate whether or not a piece may be manipulated in some meaningful board game manner 1 3 4 Move A move in BGGL is defined by a special tuple syntax delimited by colons A move acts on a piece and consequently the board in one of three ways 1 adding a piece to the board 2 removing a piece from the board or 3 moving a piece from one board coordinate to another Using the custom syntax most moves get their inputs interactively from the user or from the specific context of each game block The BGGL interpreter does automatic bounds checking on each move as it is executed 1 3 5 Rule Rules in BGGL test piece movement They are specialized versions of functions but are syntactically very similar A rule returns a boolean in BGGL by performing a series of tests on a certain piece movement specified in a rule block by a 4 tuple which is discussed at length below 5 Chapter 2 Tutorial 2 1 Getting Started 2 1 1 Environment Considerations BGGL requires a Java 1 5 environment to run We found that the best way to execute BGGL code would be to write scripts for compilation and execution These scripts were tested on the three major operating systems and each compiled and ran smoothly 2 1 2 Running a BGGL Program To run the BGGL demo which contains three brief programs prime number validator tic tac toe and Chinese checkers cd into the bggl bin directory and run the file named run demo sh 2 2 BGGL Basics Every BGGL game has four key components rules a game block the specification of a board and moves The tic tac toe example in section 2 3 illustrates the application of these four components RULES Rules are specialized functions in BGGL which define allowable piece movements They act just like functions but their syntax is a little different Each rule may be defined as follows rule identifier target piece list return test length direction jump emptysquare where target piece list is a comma separated list of preivously initialized pieces length is an integer which specifies how many valid squares a piece a may move direction is one of three keywords diag ortho orthodiag or an array of custom movement values jump is a boolean which specifies if a piece must jump another piece to make …
View Full Document
Unlocking...