Sudoku Game Design Language (SGDL) Language Reference Manual Team Members: Sijue Tan [email protected] Yigang Zhang [email protected] Yu Shao [email protected] Rongzheng Yan [email protected] William Chan [email protected] COMS 4115 Programming Languages and TranslatorsCOMS 4115 Programming Languages and TranslatorsCOMS 4115 Programming Languages and TranslatorsCOMS 4115 Programming Languages and Translators Professor Stephen A. EdwardsProfessor Stephen A. EdwardsProfessor Stephen A. EdwardsProfessor Stephen A. Edwards October October October October 22 22 22 22, , , , 2010201020102010 Co Co Co Columbia Universitlumbia Universitlumbia Universitlumbia Universityyyy1. Introudction Nowadays, Sudoku game is becoming more and more popular aroung the world. Sudoku, oringinated in Japan, is a logic-based, number placement puzzle. The oringinal Sudoku game is based on a grid, which is comprised of nine columns and nine rows. Each row or column on the grid has all of the digits from one to nine. Most of the time, the grid is partially given. Sudoku players have to complete the puzzle based their mathmatic and logic reasoning skills. The SGDL is a language designed to create a Sudoku Game. The language is easy for programmer to manipulate the matrix and the element in it, to set rules for the game and to examine the rationality of the initialization. SGDL’s syntax is modeled after C/C++ and will be built on top of those languages. A SGDL format file will be the input file and the compiler will produce a C source file as output file that can then be compiled by any C/C++ compiler.SDGL saved Sudoku fans from spending their time to learn comlicate programming development techniques, what they only need is the SDGL language which is easily understandable, then they don't have to study anything else to design a Sudoku game. By using SDGL, user could create great Sudouku games using the built-in methods. SDGL also maintain the potential of extending the language further to enable programmers to develop word games such as word search puzzles and crossword puzzles. 2. Lexical conventions 2.1 Comments The token “/* “ will introduce a comment. The “*/” will end the comment. 2.2 Key Words int bool string grid if-else for while not andor true false Print (<data type>) Scan (<data type>) Random ( ) left right Random() is reserved for making sudoku game designs more extensible. 2.3 Identifier An identifier is a sequence of letters and digits; the first character must be alphabetic. The underscore ‘‘_’’ counts as alphabetic. Upper and lower case letters are considered different. No more than the first eight characters are significant, and only the first seven for external identifiers. 2.4 Constant There are several kinds of constants, as follows: 2.4.1 Integer constants An integer constant is a sequence of digits. The language only takes decimal. 2.4.2 String constants String constants are sequence of characters surrounded by quote marks “”. Characters are also part of the string constants. 3 Types 3.1 Primitive Data Types 3.1.1 String The String type is comprise of a sequence of charactrers. Also, strings are constant. Once you set up values for this type you cannot change them. 3.1.2 Integer A basic type that contains a 32 bit signed integer, with a range of -2147483648 to 21474836473.1.3 Boolean There are two possible values for the boolean type: either true or false. Also, true is any nonzero integer value and false can be represented as zero. 3.1.4 Array An array type is a matrix of a primitive type. Array (<arrayname>, <#row>, <#col>); // <#rol> refers to the number of rows to be created in the array, and <#col> refers to the number of columns to be created in the array. Example: Array (x, 2, 3); x ~ [ 1,2,3,2,3,4]; // This creates the array [ 1 2 3 2 3 4 ]. 3.2 Object Type 3.2 .1 Grid The Grid type represents the basic element of sudoku game Properties: Cell (<row#>, <column#>) // refers to the cell specified by the parameters. Returns the value of that cell. Example: int a ; a ~ object.cell( 6,6); Row (<row#>) // the value surrounded by the “()” refers to the specific row. Returns a one-dimensional array containing all the values in that row. Example: array (r, 1, 4); r ~ object.row(6) ; Column (<column#>) // the value surrounded by the “()” refers to the specific column. Returns a one-dimensional array containing all the values in that column. Example: array (c, 4, 1); c~ object.column(6); Diagonal (<left | right>) // refers to the two diagonals in the grid. “Left” refers the diagonal starting at the upper left-hand corner, while the “right” refers to the diagonal starting atthe upper right-hand corner. Returns a one-dimensional array that contains all the values in that diagonal. Example: array (d, 1, 4); d~ object.diagonal(left); Block (<row#>, <column#>) // sub-square of the grid. The block is referenced by the parameters indicating the location of the upper left corner cell in the block. Returns an array with the same dimensions as the block and containing the values of each cell in the block. Example: array (e, 3, 3); e ~ object.block ( 3, 4 ); Band (<band#>) // refers to a particular row of blocks. The value in the parentheses refers to the band number, starting with band 0 at the top and band n at the bottom. Returns an array with row size equal to the blocks’ row size and the column size is the sum of all the column sizes of the blocks. The elements in the array will contain each cell’s value, that includes each cell value, from upper left corner to the the bottom right corner, of each block. Example: array (f, 3, 9); f ~ object.band(2); Stack (<stack#>) // refers to a particular column of blocks. The value in the parentheses refers to the stack number, starting with stack 0 on the left and stack n on the right. Returns an array with column size equal to the blocks’ column size and the row size is the sum of all the row sizes of the blocks. The elements in the array will contain each cell’s value, from the upper left corner to the the bottom right corner, of each block. Example:
View Full Document