1. Moderator
Join Date
Dec 2004
Location
Posts
3,928

I have a grid with cells 1 through 150 (15 columns by 10 rows) . I want to detect if the cells are diagonally BUT I don't want to go off the edge of the grid to do it. For example, cell 115 is diagonal to 83 (on the grid) and cell 106 is diagonal to 74 (but I want it to return false for 106 to 74 because you have to go off the edge of the grid.

Here's what I'm using...

If Int((OrgPieceIndex - Index) / 16) = ((OrgPieceIndex - Index) / 16) Then
and
If Int((OrgPieceIndex - Index) / 14) = ((OrgPieceIndex - Index) / 14) Then

(Teddy - I have to ask this again as I'm having problems with the equation.)

Join Date
Nov 2004
Location
out on a limb
Posts
13,692
I think it would be smarter to allocate the cell indexes as rows of say 20 (even though you dont use them

a devious trick would be to have a border all the way round the data set you want to use

000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019
020 021..039
....etc
220 221............................................... .....................239

000..019 are ghost/guard cells.. have blank or false values
020 & 036,037,038,039 likewise
220..239 likewise

that way round you always have a valid reference for the 'other' cell.

failing that I think you would have to call a function which would trap the that proposed cell is out of bounds

3. Moderator
Join Date
Dec 2004
Location
Posts
3,928
I wish I could but I 1-150 is an array and I have other events programmed on which cell(1) to cell(150).... are selected. I'd have to redo a lot of programming already done to re-configure it to a different array with a border array. I will do this as a last resort but I was hoping there was an equation I could use with the existing array/cells.

I could add another array BorderCells(1)....BorderCells(15), BorderCell(16), BorderCell(30),etc... but I'm not sure how I could use that to detect diagonally and if it crosses that BorderCell.
Last edited by pkstormy; 07-04-07 at 11:56.

4. King of Understatement
Join Date
Feb 2004
Location
One Flump in One Place
Posts
14,912
There is a guy on SQLTeam planning on putting together SQL Chess. He has written article #1. Essentially, what you require is exactly the same as a bishop's moves yes?
See if it is any use - might give you more ideas (for example he models his board in a table rather than an array - might be easier to use....).

http://www.sqlteam.com/article/sqlch...inking-in-sets

HTH

5. Moderator
Join Date
Dec 2004
Location