Gaijinco said:
Hi my name is Carlos Obregón and I'm currently a profesor of C/C++
programming at the CUMD in Bogotá Colombia.
This last term I ask my students to develop an implementation of the
minesweeper game with ASCII graphics and input via keyboard.
I'm trying to look for other games suitable to those restrictions.
Does anyone knows a good candidate?
This isn't really a great deal to do with C, but I do get fed up with
all the "you can't do spit in C" nonsense, and encouraging teachers to
teach standard C can't be a bad thing.
So yes, I have a game for you. I don't know what this game is called,
but it's easily doable within your restrictions. If you can play
Minesweeper (specify a location on the grid), you can play this. Here's
the game:
You have a grid, m * n cells in size. Clearly, this grid is composed of
four corner cells each having two neighbour cells, 2(m + n - 2) - 4
edge cells each having three neighbour cells, and (m-2)(n-2) internal
cells, each having four neighbour cells.
Let each cell have three characteristics - an owner, a capacity, and a
population. The owner is one of { None, Human, Computer }, and the
capacity is equal to the number of neighbour cells. We'll deal with
population in a second. The display should be somehow capable of
conveying both the ownership of a cell and its current population,
simultaneously. We'll cover that again in a minute.
All cells start with a population of 1. A cell can never be empty.
Human and computer take turns. Who starts? Up to you.
In each turn, the player simply selects a cell. That's all! It must be
either a cell that the player owns, or a neutral cell. (Equivalently,
it must not be a cell owned by the opposing player.) If a player
selects a neutral cell, he gains ownership of that cell.
The act of selecting a cell adds 1 to its population. If the resulting
population remains within the capacity of the cell, nothing happens.
Otherwise, the cell "explodes", and ALL the units of population that it
is storing (except one) are distributed equally amongst its neighbours,
adding 1 to their populations. This may in turn cause /them/ to
explode, distributing /their/ populations around the cells. Whenever a
cell explodes, the player gains ownership of all its neighbour cells.
Example from top left corner of board:
+-----+-----+-----+-----+-----+--...
| H | C | N | N | N |
| | | | | |
| 2 | 3 | 1 | 1 | 1 |
+-----+-----+-----+-----+-----+--...
| N | C | C | N | N |
| | | | | |
| 1 | 4 | 2 | 1 | 1 |
+-----+-----+-----+-----+-----+--...
| H | H | H | H | C |
| | | | | |
| 2 | 1 | 3 | 1 | 2 |
+-----+-----+-----+-----+-----+--...
| | | | | |
Computer selects the cell one-down one-right from the top left (the
details of the co-ordinate system for cell selection and of course the
way in which you display the grid is entirely up to you).
Since the selected cell has four neighbours, it has a capacity of 4. But
it also has a population of 4. So selecting it causes it to "explode",
with the following result:
+-----+-----+-----+-----+-----+--...
| H | C | N | N | N |
| | | | | |
| 2 | 4 | 1 | 1 | 1 |
+-----+-----+-----+-----+-----+--...
| C | C | C | N | N |
| | | | | |
| 2 | 1 | 3 | 1 | 1 |
+-----+-----+-----+-----+-----+--...
| H | C | H | H | C |
| | | | | |
| 2 | 2 | 3 | 1 | 2 |
+-----+-----+-----+-----+-----+--...
| | | | | |
Note that the computer has gained two cells as a direct result of this
explosion - one that was previously neutral, and one from the human. We
now note that there is a cell on the top row that has a population (4)
exceeding its capacity (3). (The capacity is 3 because the cell has
only three neighbours.) So we must now explode this cell, with the
following result:
+-----+-----+-----+-----+-----+--...
| C | C | C | N | N |
| | | | | |
| 3 | 1 | 2 | 1 | 1 |
+-----+-----+-----+-----+-----+--...
| C | C | C | N | N |
| | | | | |
| 2 | 2 | 3 | 1 | 1 |
+-----+-----+-----+-----+-----+--...
| H | C | H | H | C |
| | | | | |
| 2 | 2 | 3 | 1 | 2 |
+-----+-----+-----+-----+-----+--...
| | | | | |
The computer has gained another couple of cells here. And now the corner
cell exceeds its capacity, so we must explode that too:
+-----+-----+-----+-----+-----+--...
| C | C | C | N | N |
| | | | | |
| 1 | 2 | 2 | 1 | 1 |
+-----+-----+-----+-----+-----+--...
| C | C | C | N | N |
| | | | | |
| 3 | 2 | 3 | 1 | 1 |
+-----+-----+-----+-----+-----+--...
| H | C | H | H | C |
| | | | | |
| 2 | 2 | 3 | 1 | 2 |
+-----+-----+-----+-----+-----+--...
| | | | | |
All quiet again after the excitement, and it's the other player's turn.
Eminently programmable in ISO C. You might want to try to combine the
ownership and population information into a single symbol (e.g. 1234
for human 1234, ABCD for computer 1234, and . for neutral 1), as this
would save you from needing grid lines.