Hello ,Iam trying to write a programme for the connect -N game :
Your program must allow two people to play Connect-N against each other using a text-based interface. Since this is a text-based game, we do not represent the players as colours(traditionally red and yellow), but instead as numbers: 1 and 2, for player 1 and 2 respectively

Here is an example of a complete game:
Number of rows: 3
Number of columns: 5
Win Length: 3
+-+-+-+-+-+
| |
| |
| |
+-+-+-+-+-+
0 1 2 3 4
Enter column for player 1: 4
+-+-+-+-+-+
| |
| |
| 1 |
+-+-+-+-+-+
0 1 2 3 4
Enter column for player 2: 3
+-+-+-+-+-+
| |
| |
| 2 1 |
+-+-+-+-+-+
0 1 2 3 4
Enter column for player 1: 2
+-+-+-+-+-+
| |
| |
| 1 2 1 |
+-+-+-+-+-+
0 1 2 3 4
Enter column for player 2: 2
+-+-+-+-+-+
| |
| 2 |
| 1 2 1 |
+-+-+-+-+-+
0 1 2 3 4
Enter column for player 1: 2
+-+-+-+-+-+
| 1 |
| 2 |
| 1 2 1 |
+-+-+-+-+-+
0 1 2 3 4
Enter column for player 2: 1
+-+-+-+-+-+
| 1 |
| 2 |
| 2 1 2 1 |
+-+-+-+-+-+
0 1 2 3 4
Enter column for player 1: 3
+-+-+-+-+-+
| * |
| 2 * |
| 2 1 * |
+-+-+-+-+-+
0 1 2 3 4
Player 1 is the winner!
There are some spesific development steps :
1)input and basic board shape You can use the function raw_input for reading input. You should create a function with an appropriate name (e.g. draw_board) for showing the board.
for now your function you can simply take two parameters, n_rows and n_cols, specifying the number of rows and columns. The function need display only the boundary of the board, constructed from '+', '-', '|', and ' ' characters as shown in the example, with the correct number of rows and columns and also the numeric column labels as shown.


2)Your program must now be extended to ensure that the game parameters are sensible.There is a maximum of 19 rows allowed, and a maximum of 10 columns allowed. The winlength must be in a range where a win is possible in at least one direction. The minimum forall three values is 1.

3)The program should be extended so that pieces can be `dropped' in columns, and the turnshould alternate between the two players.First you will need some way of representing a cell of the board in python. A string oflength one might be a good choice, since when displaying a board, a cell is shown as a single character. Then you will need a way of representing a single row of cells. A list of cells might
be a good choice to represent a row. Finally the board might be represented as a list of rows.The empty board, then, can be represented by a list of lists, where each inner list is a list of
strings, and each string contains a single space.

4)Two more major parts are required in this step: Alternating the turns, and dropping apiece. Dropping a piece requires a function to determine where the bottom-most empty cell
is in a column, then placing the appropriate piece in that cell of the board. Turns shouldcontinue to alternate until either a winner has been decided or a draw has been reached|
both game ending conditions are the subject of later sections, so need not be attempted justyet. When testing this section, the autotester will be `nice'; it will not overll columns, putpieces in non-existent columns or reach a win or draw.

5)Ensure columns are in the correct range, and pieces can't be dropped into columns that are
already full.

6)Your program should now be upgraded to detect winning columns ,rows or diagonally.

7)For easier recognition of the winning line/lines, these should be starred.

8)use Internationalisation in the programme.


I am very sorry for being so long.But I really hope that someone can help me to do this problem.

Recommended Answers

All 3 Replies

You forgot your code and or pseudo code.

Also it is good to use the code tags (# button in toolbar) to put output text in post as it gets messed up, even it is not really code. If you put any one formatting in it for any part of text B (bold), for example, it does not take Python formatting:

[B]Here is an example of a complete game:[/B]
Number of rows: 3
Number of columns: 5
Win Length: 3
+-+-+-+-+-+
| |
| |
| |
+-+-+-+-+-+
0 1 2 3 4
Enter column for player 1: 4
+-+-+-+-+-+
| |
| |
| 1 |
+-+-+-+-+-+
0 1 2 3 4
Enter column for player 2: 3
+-+-+-+-+-+
| |
| |
| 2 1 |
+-+-+-+-+-+
0 1 2 3 4
Enter column for player 1: 2
+-+-+-+-+-+
| |
| |
| 1 2 1 |
+-+-+-+-+-+
0 1 2 3 4
Enter column for player 2: 2
+-+-+-+-+-+
| |
| 2 |
| 1 2 1 |
+-+-+-+-+-+
0 1 2 3 4
Enter column for player 1: 2
+-+-+-+-+-+
| 1 |
| 2 |
| 1 2 1 |
+-+-+-+-+-+
0 1 2 3 4
Enter column for player 2: 1
+-+-+-+-+-+
| 1 |
| 2 |
| 2 1 2 1 |
+-+-+-+-+-+
0 1 2 3 4
Enter column for player 1: 3
+-+-+-+-+-+
| * |
| 2 * |
| 2 1 * |
+-+-+-+-+-+
0 1 2 3 4
Player 1 is the winner!

Haha, COSC121 eh

cool COSC121 bro

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.