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

Member Avatar for masterofpuppets

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 :)

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.