Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
GAME PROGRAMMING PROJECTS Art Gittleman Californis State University Long Beach [email protected] One-semester course. Diverse group of students, some causual some serious gamers. Goal: Give all students game-development basics. Allow serious gamers to excel. Tools: Microsoft XNA Game Studio 2.0. Uses C#. Provides framework for graphics to enable students to develop a game for the PC or Xbox 360 in one-semester. Text: Microsoft XNA Unleashed, Chad Carter, SAMS, 2007. Projects: Ten projects which develop a 3D board game, in this case to play Jul-Gonu. Extra-credit projects for serious gamers. Projects: 1. Draw three cubes. 2. Use keyboard to select and move cubes. 3. Load 3D models and select with the mouse. 4. Draw a gameboard. 5. Add collision detection of pieces with board. 6. Add a state machine to manage each phase of the game. 7. Add play of the pieces including capture. 8. Complete state machine and game play including win and loss. 9. Add sound. 10. Add artificial intelligence to play against computer. Extra credit project ranged from Tetris clones to original 3D games. 1. Draw three cubes. Define vertices in object space with origin as center. Map 2D texture to each face. Transform to desired position in world space and desired size. 2. Use keyboard to select and move cubes. A,B,C keys select. Arrow keys move in two dimensions. s,w move in third dimension. 3. Load 3D models and select with the mouse. Mouse coordinates give 2D screen position. Unproject these coordinates to the near plane and far plane. See if the ray between these points intersects your model. Move as in project 2. See next figure (from http://creators.xna.com/en-us/sample/picking) 4. Draw a gameboard. Make a 4x4 board using 32 triangles and an index buffer. Use tile image from Minjie (http://creators.xna.com/en-us/minigame/minjie) to create 4x4 board with dark border at the boundary. Learn to mirror texture. 5. Add collision detection of pieces with board. Use the bounding sphere of the model. Find the distance from its center to the board. A collision occurs when that distance is less than the radius of the bounding sphere. See http://geometryalgorithms.com/Archive/algorithm_0104/algorithm_ 0104.htm 6. Add a state machine to manage each phase of the game. There are states to get instructions, play, pause, signify a win or loss, and others. The textbook has an example and other examples are available online if not using that test. Here students just coordinate the states and do not add any game play other than the piece selection and moves already implemented, 7. Add play of the pieces including capture. In Jul-Gonu we capture a piece by moving our piece to surround it on the left and right or on the top and bottom. It is possible to capture two pieces at once in this way. The arrow keys are now used to move a piece one square at a time in the indicated direction. Comparing the keyboard state to the previous keyboard state will determine is the piece is newly moved. (The game update method is called 60 times per second, faster than players play.) 8. Complete state machine and game play including win and loss. In Jul-Gonu a player loses when reduced to one piece or when the player has no possible moves. The player also loses by moving back and forth three times in succession (over, back, over). This project fully implements the game for two players. The initial board is: 9. Add sound. Project 9 uses Microsoft Cross-Platform Audio Creation Tool (XACT) to add sound to the game. XACT uses WAV files for each sound. It is possible to create various effects but for this project we just require a sound to play while in the start state, whenever a piece moves, and when a win or loss occurs. Adding sound really does jazz up the game. XNA Game Studio 3.0 will not require XACT. 10. Artificial intelligence for the opponent. The computer will search a tree of several possible moves using the minimax algorithm. Using a function that gives the value of the board to the first player, that first player will want to maximize that value while the second player will try to minimize it. See http://ai-depot.com/articles/minimax-explained/. Additional Projects Graphics cards can be programmed to add the lighting, colors, textures, and shading to make high-quality games. XNA provides a BasicEffect class which uses default settings to render scenes. Using HLSL (High Level Shader Language) we can custom program the graphics card. Vertex shaders apply to each vertex while pixel shaders apply to each pixel. The course covers vertex and pixel shaders but so far they have not been incorporated into the projects which use the BasicEffect class. If more time is available an additional project could add custom shaders. Conclusion The game business is huge and commercial games are produced by large teams with big budgets. Relative to these endeavors we have not done much, but relative to a typical upper-division course students find this material challenging and put in substantial effort to complete the projects which give them a base to go further with game programming and the broader area of game development. Students learn the C# language which was mostly new to them. They use graphics, algorithms, and artificial intelligence in a problem solving mode that we hope will build interest in further course in these areas. By structuring the assignments to take one step at a time a wide range of students are successful which is a difficult goal to attain in a subject that integrates ideas from so many areas. (See the course site, http://www.cecs.csulb.edu/~artg/455 for the assignments and other course materials.)