Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Ambiguous moves in algebraic notation

Author: Sven Reichard

Date: 02:26:20 06/28/02

Go up one level in this thread


On June 28, 2002 at 05:02:19, Daniel Clausen wrote:

>On June 28, 2002 at 04:44:19, Russell Reagan wrote:
>
>>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?
>
>I didn't like the dependency move->board position. I introduced a class
>'MovePrettyPrinter' which gets a position and a move and can pretty print it.
>
>Sargon

I do a similar thing. I have the following class (a bit simplified and written
from memory):

class SanNotation
{
public:
  SanNotation(const Game&, const Move*);
  SanNotation(const Game&, const std::string&);

  const Move* getMove() const;
  const std::string getString() const;
private:
  // <snip>
};

This class allows conversion from text to move and vice versa. I use it only
when I actually read/write moves, so the execution speed is not crucial. When
building the string, I generate all pseudolegal moves and check if, e.g., Ne5
uniquely determines the move in question. If that fails, I try adding the file,
then the rank, then both, until I get a unique move.

The only problem arises for promoting moves, because here you have (or at least
I have) 4 moves with the same source square. I haven't found an elegant solution
for this yet; currently, after counting the matching moves in this case, I
divide the number by 4.

The other direction is more straighforward and stupid: Generate all moves, find
their SAN string, and see which one fits. This depends on totally standard
conforming input, but for now it works.

Sven.



This page took 0 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.