Computer Chess Club Archives


Search

Terms

Messages

Subject: Ambiguous moves in algebraic notation

Author: Russell Reagan

Date: 01:44:19 06/28/02


I'm currently trying to add algebraic notation to my program, since it currently
only does coordinate notation. I have everything figured out except how to
handle an ambiguous move. For example, in the following position, my program
would interpret the move f1e5 as Ne5, when in algebraic notation it should be
Nfe5.

[D]4k2r/8/8/8/2N5/5N2/8/4K3 w k - 0 1

My move struct has a toMove() method (C++) and it currently has no knowledge of
the position it's being made in. So how am I supposed to be able to do this
extra checking without knowing what the rest of the position looks like? How
about adding a static pointer to my position struct and have the move struct
access the position via that?

Also, it seems like a lot of extra work to determine if there is an ambiguous
move. Is there any way to make it simpler? I think it looks much better than
coordinate notation, but this final step of adding support for ambiguous moves
seems like a lot of extra work for the rare occurance of such a move.

Currently my move struct looks like this:

struct MOVE
{
// constructors removed
	SQUARE *	from;
	SQUARE *	to;
	int		type;
	int		promote;

	PIECE *		captured;
	CASTLINGRIGHTS	prevCastlingRights;
	int		prevEpSquare;
	int		prevFiftyMoveCounter;

	string	toString(int);
};

Here's an example of how my toString() method works (using coordinate notation).

string MOVE::toString(int notation)
{
	string move;

	if(notation == COORDINATE)
	{
		move += from->toString();
		move += to->toString();
	}

	else if(notation == ALGEBRAIC)
	{

	}

	return move;
}

I have pointers to the squares so that I can just call their toString() methods,
although I suppose if I had a static POSITION * added into my MOVE struct, I
wouldn't need pointers and could use indexes into the position.

Any advice is appreciated, even if there's no shortcut and I have to just code
all of the special cases in.

While I'm at it, is there anything wrong with my current MOVE struct approach of
having pointers to squares instead of indexes into a position?

Thanks,
Russell



This page took 0.01 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.