Applying game rules

Rules define legal player moves and make the game balanced. You have to ensure players cannot break the rules or they might be able to cheat.

Unlike some other "put some symbols in a row" games like Tic Tac Toe that let you place your move in every empty spot, in Connect Four you can't place discs everywhere.

In the real world, discs fall down to occupy the lowest available space in each column. Moreover, players can't place a disc on a completely filled column.

Unfortunately, the program does not know we are playing on a vertical board where discs fall, and that a disc is a solid entity that does not physically fit in a fully completed column. The whole game field is just an array, a bunch of indexed numbers.

So these are the ...

Get Flash Game Development by Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.