|
-
Jan 21st, 2006, 10:26 AM
#1
Thread Starter
Hyperactive Member
mirroring coörds [ab] => [sb]; [bq] => [rq]
Hi,
Here I am again. With another annoying question.
In short I have a string containing coordinates in the following format:
";B[..];W[..];B[..];W[..]"
This is according to the SGF specifications (but not that important)
They represent moves from an asian boardgame. The [] signs hold the 2D coordinates. Each "." is a character from a - s. (The board is a 19x19 matrix). Sometimes there is a ";" sign in between 2 moves but not always. Also the capital characters in between the coordinates: B and W can also have different forms. The first one of the coordinates has to be mirrored so that a "a" becomes an "s", a "b" becomes a "r", a "c" becomes a "q", etc ...
In short:
Only the "[" and "]" sign are always in place.
Only the first coordinate has to be mirrored. (We are mirroring horizontal).
And coordinates are in the range of a to s.
Some examples to make it clear:
ex1: ;B[aa] should become ;B[sa]
ex2: [bs] should become [rs]
ex3: ;W[cb] should become ;W[qb]
ex4: ;W[bb]AB[bc] should become ;W[rb]AB[rc]
I was wondering about doing it with some replace functions or a loop, allthough I'm pretty sure there is a perl way to do it too. What would you do?
____________________________________________
Please rate my messages. Thank you!
____________________________________________
Bram Vandenbon
http://www.bramvandenbon.com
-
Jan 21st, 2006, 10:28 AM
#2
Thread Starter
Hyperactive Member
Re: mirroring coörds [ab] => [sb]; [bq] => [rq]
lol, I just realized I allready have a function for this :-) lol, so, Nevermind!
____________________________________________
Please rate my messages. Thank you!
____________________________________________
Bram Vandenbon
http://www.bramvandenbon.com
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|