On Sunday 06 March 2005 01:47 pm, James Britt wrote: > Jim Weirich wrote: > > def hash > > @x.object_id + @y.object_id > > end > > Isn't this the same value as > > @y.object_id + @x.object_id Yes. As Joel points out that to some degree you expect things to occasionally hash the the same value. If too many things hash to the same value, then your hash array will slow down. For small boards, it probably doesn't matter, but not only do [1,2] and [2,1] map to the same hash, but so would [0,3] and [3,0]. In fact, all diagnols running from the lower left to the upper right have the same hash value on all their cells. So x+y suggestion, while working, is rather suboptimal. How about this ... def hash @x + 1000*@y end (I dropped the object_id call because it looks like we are mapping from fixnums). -- -- Jim Weirich jim / weirichhouse.org http://onestepback.org ----------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)