On Thu, 2012-10-25 at 17:40 +0200, bagrat lazaryan wrote: > i'm afraid i rushed a little in offering my solution. it seems it isn't as > trivial a task as it appeared to be at first. as for now, my solution isn't > handling correctly the doubles. (it gave me "13/9 13/5 9/5" on (13, 9, 13, > 9, 9, 5, 9, 5) instead of "13/5(2)".) i didn't succeed in coming up with a > quick fix so i will also have to put it off till the weekend or, given that > indeed most of the functionality required should be already present, wait > for your solution. anyways, if you need any help on this will be glad to > contribute.
I solved that problem with regular expressions resp. substitutions, see http://git.savannah.gnu.org/cgit/gibbon.git/tree/src/gibbon-position.c currently after line 1112 in function gibbon_position_format_move(). My approach depends on the point pairs involved in a move on being sorted, so that movements with the rearmost checkers appear first. Then I convert the integer pairs into a string, for example something like "a/c c/e f/h h/j" (for "24/22 22/20 19/17 17/15"). The rest is done by the glib regex engine, for example s/\/([a-z]) \1\//\//g compresses the above string into "a/e f/j". Inserting the '*' for blot hits or grouping identical movements with "(2)", "(3)", or "(4)" works essentially the same, only it's more complicated. Maybe buggy, maybe inefficient, but I still like my function. ;) Guido -- Империя ООД | Imperia OOD ул. „Княз-Борис-I“ № 86, София 1000 | ul. "Knyaz-Boris-I" № 86, Sofia http://www.imperia.bg/ _______________________________________________ Bug-gnubg mailing list Bug-gnubg@gnu.org https://lists.gnu.org/mailman/listinfo/bug-gnubg