0

Hi Peepz,

My Connect 4 board is made up of different lists. My task is to write a function that checks whether the game ends in a draw (that means when every spot is taken by a 'X' or an 'O' without fulfilling the winning requirements
If everyspot is filled print 'Draw!'

The easiest way I could imagine is to check whether the first row of the board is fully filled (that means the spaces beneath the top row are filled too)

Unfortunately this time I don't have a clue how to type this down ...

Can anyone help me please?

Thanks in advance

Yours Truly

Edited by sentinel123: n/a

2
Contributors
1
Reply
3
Views
8 Years
Discussion Span
Last Post by masterofpuppets
0

hi,
here's my suggestion,

You can use a boolean variable, 'win' say, and initially set it to false. Then in you check function check to see if player one is victorious, if the check returns true, set win to True and return, else if check returns false, do the same for player two. If check returns false for player 2 as well, then you need to check whether the first row has a "." in it, if it does that means the game is not over yet, otherwise the game ends in draw.

Note that you need to do these checks every time a player makes a move :)

hope this helps :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.