YAD wrote:

> Paul Lutus wrote:
>> I'm making an assumption here, that you want to find a winning pattern.
> I want to calculate several things (at different times), including
> whether a player has two in a row, and whether a player has two blank
> squares that will win the game (two pairs in a row that require
> different squares to be completed).
> Since that's a total of six functions, I figured combining rows & cols
> into one function would be the simplest way to reduce the total amount
> of code.

If speed is your primary goal (referring to later content in your post),
then minimizing the number of functions may not be so important.
 
>> def find_winner(array)
>>    w = test_rows(array) \
>>        || test_rows(array.transpose) \
>>        || test_diagonals(array)
> 
> This looks like the simplest way to do it.  The only concern I would
> have with this solution is performance in searching a whole tree of
> possible future grids.

Given the speed requirement, this might be a case where (at risk of sounding
sacrilegious) you would test various approaches in Ruby until you came up
with an obviously efficient method, then converted the algorithm into C or
C++. In this case Ruby would serve as a quick prototyping tool (but a
comparatively slow execution tool).

As to "possible future grids", if you factor out mirror reflections and
transpositions, there really aren't that many unique board configurations
in this game. Compare this to the Japanese game Go, which is still not
well-represented in a computer program.

-- 
Paul Lutus
http://www.arachnoid.com