CSCI1300 Notes 7: An Educational Gamelet


For a couple of decades people have thought that computer game technology should be able to produce great learning experiences. Despite a few successes like Robot Odyssey [which you can play in the lab, if you want], in which players learn a lot about digital logic while escaping from the sewers of a metropolis of the future, little has actually been done with the idea. For your team projects this term you'll be exploring one aspect of this matter, creating a program that presents an educational gamelet. I'm calling it a "gamelet", rather than a game, to distinguish it from the full 3D worlds that many computer games present today. Lots of gamelets, like PacMan or Snood, get played as much or more than any of the big games, so making educational gamelets could be as important as producing educational games of the 3D kind, but it's a different kind of task. For us, it's more do-able.


The game we'll use is a variant of a game called "tic tac toe products" (we'll abbreviate it TTTP). I haven't been able to determine who invented it. I learned about it from Andee Rubin, who works on educational software and related issues at TERC, a thinktank in Cambridge, MA. It's a two-player game that works like this...I'm describing the original version first, even though it's NOT what we'll be using, because it's easier to describe, and it's easier to see how the play goes.


There's a 6x6 grid, labelled with numbers, like this, with the numbers from 1-9 written in a row underneath:







































            1   2   3   4   5   6   7   8   9


There are two markers that can be used to pick out two numbers in the row (paper clips are often used.)


The first player puts one of the markers on any desired number in the row. The second player then places the other marker on any desired number in the row, and then puts an O in the square of the grid that contains the product of the two marked numbers (note that both markers can be on the same number.)


The first player then must move one of the markers to any new number, and then puts an X in the square of the grid that contains the product of the two marked numbers.


The second player does the same thing, marking a square with O. Neither player can move the markers in such a way that the product formed has already been used.


The winner is the first player to get 4 of their markers in a row, vertically, horizontally, or diagonally. If a player cannot move the game is a draw.


The main educational value of this game is that it provides a lot of practice in multiplying and factoring. Secondarily, there is some strategy involved in playing well (but it is not clear how much intellectual benefit there is in learning to play strategy games; in general, skills learned in one setting are often found not to transfer to new situations, so it is not clear that learning the strategy of this game helps you in other games, let alone in any real-world problem situations.)


We're going to create a variant of this game that focuses on more advanced skills: multiplying and factoring polynomials. Instead of 9 digits, in our game we'll have 12 binomials:


-2x-1, -2x+1, -x-2,-x-1,-x+1,-x+2, x-2,x-1,x+1,x+2,2x-1,2x+1


If my analysis is correct (I'll check this as we go forward, but trust me for now) there are 42 distinct products formed by multiplying pairs of these binomials, for example 4x2+4x+1 (the square of the first one) or x2-1 (the product of x+1 and x-1). We'll arrange these products in a grid of 6 columns by 7 rows, in the following order. Number the binomials as listed above, 1-12. The product of binomial 1 x binomial 1 will go in the upper left hand corner (row 0, column 0), the product of binomial 1x binomial 2 will go in the next space in that row (row 0, column 1), and so on, moving to the next row when the row 0 is filled. When we have all the products of binomial 1, we'll next place the products of binomial 2. BUT if a product is already in the grid, we ignore it. For example, we won't be putting binomial 2 x binomial 1 in the grid, because it's the same as the product binomial 1 x binomial 2, which is already in the grid.


Because our products will be polynomials with three terms, and hence spread out horizontally, and because our grid will be square, not rectangular, I'm decreeing that we'll use a different winning pattern from the original game. In the original, you have to form four marks in a row, horizontally, vertically, or diagonally. Seeing diagonals in a non-square grid is hard. So in our game the winning pattern is four marks that form a 2x2 block.


Otherwise the rules of our game are the same as the original. Let's call our game FactorBlocks, or FB for short.


For your team projects you'll be writing an FB player so that someone can play FB without having a human opponent. You'll be able to do as much strategy development as you and your teammates want to do. For all I know, you will be able to develop an unbeatable FB strategy.


Start thinking about who you want to team up with for the final competition. This exercise would be a good one in which to try out a possible team before committing to work with people for the final project.


Exercise. For now, let's warm up by writing a program that lets two people play FB against each other, with the computer managing the game. Your program should display the board (including the  row of 12 binomials) and prompt the players for their moves. After the first two moves, which place the two markers, specifying a move means saying which marker you are moving and what number you are moving it to.


So, your mission is, write a program that just does what was just described, and shows the current positions of the markers and the X's and O's on the grid.


Because this is intended as a design exercise, I don't want to give you too many suggestions about how to do this. But because this assignment feeds into the game tournament assignments that are coming up, I need to specify some things (otherwise you'll have to make a lot of changes later.)




(Requirement 1) You must use the following struct definitions in your program


struct move


      int marker; // this will always be 0 or 1, depending on which of the two                  //markers is being moved

      int digit; // this will be a number, 0-11, indicating which of the 12                     //binomials the marker is being move to


struct gamestate


      int movenumber; //this will be 0 for the first move, 1 for the second,

                        //and so on

      int board[7][6]; //each entry contains 0 for X, 1 for 0, 2 for vacant

      int markers[2];//markers[0] contains the number of the binomial the first                 //marker is on; markers[1] has the other



(Requirement 2) The first player has the X's and makes moves 0,2,4, etc. The second player has the O's and makes moves 1,3,5, etc.


(Requirement 3) Remember that moves 0 and 1 are different from the rest. On move 0 the player MUST place marker 0 , and on move 1 the player MUST place marker 1. Thereafter a player can move either marker.


(Requirement 4) You have to show the binomials in the order given above, and you have to place the product polynomials in the grid as described above.


Here is some background information and hints you may find useful.


About two-dimensional arrays. Notice the funny declaration of board in struct gamestate. That's a two-dimensional array of ints. To use it you provide two subscripts, not one. The first subscript specifies the row, and the second the column. So if you have


struct gamestate g;


g.board[0][0] holds the contents of the square in row 0, column 0 in the game grid, g.board[0][1] holds the contents of the square in row 0, column 1, g.board[5][3] holds the contents of  the square in row 5, column 3, and so forth.


If you want to pass a two-dimensional array as a parameter, you must declare the parameter in such a way that the compiler sees how long each row is (it needs that information to calculate the addresses of elements of the array from the subscripts.) Your declaration will work if you include both dimensions when you declare the parameter, or if you omit just the first one, as in these examples:


sometype somefunction(int board[6][6]);

sometype somefunction(int board[][6]);


Drawing text on the screen: Use the outtextxy() function in the graphics library to draw the polynomials, X's, and O's on the screen. Don't worry for now about showing the exponents properly; we'll accept x2 instead of x2.


Erasing: To erase something, draw a black rectangle (or use whatever color you use for the background) over it, using the bar() function in the graphics library.


Converting numbers to strings: If you want to convert a number to a string, use the function sprintf(), which is like printf() except that it takes an added first argument, which is a string that it puts what you "print" into, converted to characters. For example:


#include <stdio.h>

int main()


     char astring[10];

     int num=333;



     return 0;



Important: Use good design practice, and be sure your solution reflects this (and the other requirements on the Style Sheet.) Your program should show a clear decomposition of the problem into functions that are all simple and clear. This program is complex enough that it will be much easier to write it the right way than to kluge something together!



Optional Add-ons


Make your program display the exponents properly.


Enhance your program so that it detects and rejects illegal moves (that is, moves in which the corresponding grid square is already occupied.


Enhance your program a facility that detects when a player has won the game. (You'll probably need this for the tournament, Notes 8, but you don't have to complete this now.)



What to submit: Include a listing of your program, a screen shot showing the compilation, and a screen shot showing a game in progress.


Be sure to include your time report with your submission.


To learn more: There is a wealth of material about computers, games, and education on the Web. Can you find writings by Andee Rubin, Maria Klawe, Henry Jenkins, or Kurt Squire on educational games? See what you can find about the state of the art in computer chess play. Do computers play chess the way humans do? What is "modding" in the gaming world? Could you create educational games, not just gamelets, by modding? If the site is up, has notes from a class I taught with Alex Repenning last Spring. One of the tools we used was a system Alex has developed called AgentSheets ( in which students were able to build a Sokoban game in a couple of hours. It's a good gamelet implementation environment. Robot Odyssey is available on the Apple II in the lab. You can also download the game, and an emulator to play it on, on the Web.