A diagram combination extension
-
hyperpape
- Tengen
- Posts: 4382
- Joined: Thu May 06, 2010 3:24 pm
- Rank: AGA 3k
- GD Posts: 65
- OGS: Hyperpape 4k
- Location: Caldas da Rainha, Portugal
- Has thanked: 499 times
- Been thanked: 727 times
A diagram combination extension
I have written some javascript that takes a bunch of ASCII diagrams and stiches them together into a single SGF. It tries to the do the "right thing" with variations and positions that may be reached from each other*, so that you can get a single game tree from all the diagrams for a Malkovitch game.
I've also written functions that suck up all the diagrams from an entire L19 thread, and one that sticks the resulting sgf into a new window as an eidogo player.
This is all wrapped up as a Chrome extension, is about ready to be released for use.
My question for the admins is about the load on the server. Every time it's invoked, the extension requests every page that's in the thread. Seems like that could be obnoxious.
So I could:
a) publicly release the extension in single page mode without the ability to suck up a whole thread.
b) release it, but tell people to behave by saving and posting the SGF when they use it.
c) just give it to admins/moderators or whatever,
d) investigate storing the data so that every time you visit a L19 thread, the extension passively stores the data it wants, and only requests pages when it needs to do so. This is probably the best long-term solution, but I don't know the relevant APIs. I'd like to learn them, but sometimes I'm a bit slow. It also requires somehow handling cases when you need to update data thanks to an edit to a pre-existing page.
* Right now, this works whether or not move numbers are used or are accurate, but doesn't work if there's a gap where multiple moves are added. That shouldn't be too hard to fix.
I forget exactly how it handles transpositions, but I know the answer is "not intelligently".
Those caveats make it a good time to mention that I'm a total amateur, I've been programming for less than two years, and this is my first project in javascript. Please, be gentle when you see this code. I know it's not very good.
I've also written functions that suck up all the diagrams from an entire L19 thread, and one that sticks the resulting sgf into a new window as an eidogo player.
This is all wrapped up as a Chrome extension, is about ready to be released for use.
My question for the admins is about the load on the server. Every time it's invoked, the extension requests every page that's in the thread. Seems like that could be obnoxious.
So I could:
a) publicly release the extension in single page mode without the ability to suck up a whole thread.
b) release it, but tell people to behave by saving and posting the SGF when they use it.
c) just give it to admins/moderators or whatever,
d) investigate storing the data so that every time you visit a L19 thread, the extension passively stores the data it wants, and only requests pages when it needs to do so. This is probably the best long-term solution, but I don't know the relevant APIs. I'd like to learn them, but sometimes I'm a bit slow. It also requires somehow handling cases when you need to update data thanks to an edit to a pre-existing page.
* Right now, this works whether or not move numbers are used or are accurate, but doesn't work if there's a gap where multiple moves are added. That shouldn't be too hard to fix.
I forget exactly how it handles transpositions, but I know the answer is "not intelligently".
Those caveats make it a good time to mention that I'm a total amateur, I've been programming for less than two years, and this is my first project in javascript. Please, be gentle when you see this code. I know it's not very good.
- Joaz Banbeck
- Judan
- Posts: 5546
- Joined: Sun Dec 06, 2009 11:30 am
- Rank: 1D AGA
- GD Posts: 1512
- Kaya handle: Test
- Location: Banbeck Vale
- Has thanked: 1080 times
- Been thanked: 1434 times
Re: A diagram combination extension
Thanks for asking. It doesn't seem to be much of a problem.
My suggestion would be to have it automatically append the SGF to the end of the thread when it is done. ( And maybe send an automatic PM to your local admin so that he can transfer the SGF to the first post to make it easy to find. )
If the output is saved and clearly available at the beginning of a thread, then it would only have to be run once per game. Even if someone wants to generate an SGF for every Malkovich game, it would only have to be run less than two hundred times.
At worst, it it is a hog, you could write delays in between successive calls to make it play nice.
My suggestion would be to have it automatically append the SGF to the end of the thread when it is done. ( And maybe send an automatic PM to your local admin so that he can transfer the SGF to the first post to make it easy to find. )
If the output is saved and clearly available at the beginning of a thread, then it would only have to be run once per game. Even if someone wants to generate an SGF for every Malkovich game, it would only have to be run less than two hundred times.
At worst, it it is a hog, you could write delays in between successive calls to make it play nice.
Help make L19 more organized. Make an index: https://lifein19x19.com/viewtopic.php?f=14&t=5207
- RBerenguel
- Gosei
- Posts: 1585
- Joined: Fri Nov 18, 2011 11:44 am
- Rank: KGS 5k
- GD Posts: 0
- KGS: RBerenguel
- Tygem: rberenguel
- Wbaduk: JohnKeats
- Kaya handle: RBerenguel
- Online playing schedule: KGS on Saturday I use to be online, but I can be if needed from 20-23 GMT+1
- Location: Barcelona, Spain (GMT+1)
- Has thanked: 576 times
- Been thanked: 298 times
- Contact:
Re: A diagram combination extension
Does it also suck the comments? Getting the text from Malkovich games and generating commented SGF files would be terrific for study purposes.
Geek of all trades, master of none: the motto for my blog mostlymaths.net
- Joaz Banbeck
- Judan
- Posts: 5546
- Joined: Sun Dec 06, 2009 11:30 am
- Rank: 1D AGA
- GD Posts: 1512
- Kaya handle: Test
- Location: Banbeck Vale
- Has thanked: 1080 times
- Been thanked: 1434 times
Re: A diagram combination extension
RBerenguel wrote:Does it also suck the comments? Getting the text from Malkovich games and generating commented SGF files would be terrific for study purposes.
Unfortunately, many comments have diagrams in them. That would be some really tricky proramming to build the full SGF tree.
Help make L19 more organized. Make an index: https://lifein19x19.com/viewtopic.php?f=14&t=5207
- RBerenguel
- Gosei
- Posts: 1585
- Joined: Fri Nov 18, 2011 11:44 am
- Rank: KGS 5k
- GD Posts: 0
- KGS: RBerenguel
- Tygem: rberenguel
- Wbaduk: JohnKeats
- Kaya handle: RBerenguel
- Online playing schedule: KGS on Saturday I use to be online, but I can be if needed from 20-23 GMT+1
- Location: Barcelona, Spain (GMT+1)
- Has thanked: 576 times
- Been thanked: 298 times
- Contact:
Re: A diagram combination extension
I guessed Joaz, but dreaming is possible 
Geek of all trades, master of none: the motto for my blog mostlymaths.net
-
hyperpape
- Tengen
- Posts: 4382
- Joined: Thu May 06, 2010 3:24 pm
- Rank: AGA 3k
- GD Posts: 65
- OGS: Hyperpape 4k
- Location: Caldas da Rainha, Portugal
- Has thanked: 499 times
- Been thanked: 727 times
Re: A diagram combination extension
The Sunday after I posted, my father in law/boss told me that work was about to get hectic. And he was right.
And then bugs bugs bugs bugs! I really didn't plan out what I was doing, just wrote bits of code, so I ended up with a horrible Frankenstein monster. Many bugs are fixed, but there are still some cases where the extension does the wrong thing, so no release. But it's doing the right thing with at least some Malkovitch games, so I can try and get you any particular game that you want I'll try.
P.S. (I miss strong typing. And I maybe even want static typing)
P.P.S (The postscript got me to reading, and introduced a faint bit of doubt about the terms. But forget terms. Whatever it is that you call it when Javascript gives you undefined when you lookup foo.attributeThatFooDoesntHave is one of the things that I dislike.)
And then bugs bugs bugs bugs! I really didn't plan out what I was doing, just wrote bits of code, so I ended up with a horrible Frankenstein monster. Many bugs are fixed, but there are still some cases where the extension does the wrong thing, so no release. But it's doing the right thing with at least some Malkovitch games, so I can try and get you any particular game that you want I'll try.
P.S. (I miss strong typing. And I maybe even want static typing)
P.P.S (The postscript got me to reading, and introduced a faint bit of doubt about the terms. But forget terms. Whatever it is that you call it when Javascript gives you undefined when you lookup foo.attributeThatFooDoesntHave is one of the things that I dislike.)
- Joaz Banbeck
- Judan
- Posts: 5546
- Joined: Sun Dec 06, 2009 11:30 am
- Rank: 1D AGA
- GD Posts: 1512
- Kaya handle: Test
- Location: Banbeck Vale
- Has thanked: 1080 times
- Been thanked: 1434 times
Re: A diagram combination extension
hyperpape wrote:...(I miss strong typing. And I maybe even want static typing)...
http://www.freepascal.org.
Help make L19 more organized. Make an index: https://lifein19x19.com/viewtopic.php?f=14&t=5207
- schultz
- Lives in gote
- Posts: 505
- Joined: Tue Apr 20, 2010 5:31 pm
- GD Posts: 0
- Location: Montana
- Has thanked: 80 times
- Been thanked: 62 times
Re: A diagram combination extension
Joaz Banbeck wrote:hyperpape wrote:...(I miss strong typing. And I maybe even want static typing)...
http://www.freepascal.org.
Pascal? Bah!
I'm a huge Python fan, but that does not have strong typing either. If you're enjoying javascript, I'd recommend checking out Jquery - adds some power to javascript.
KGS: schultz [?].
-
hyperpape
- Tengen
- Posts: 4382
- Joined: Thu May 06, 2010 3:24 pm
- Rank: AGA 3k
- GD Posts: 65
- OGS: Hyperpape 4k
- Location: Caldas da Rainha, Portugal
- Has thanked: 499 times
- Been thanked: 727 times
Re: A diagram combination extension
I think Python actually features strong dynamic typing, if I understand the terms right (big if!). It doesn't do the thing I most dislike, giving undefined for "foo.missingAttribute" (which makes sense, since I learned Python first, I'm myopic and want other languages to be Python).schultz wrote:I'm a huge Python fan, but that does not have strong typing either. If you're enjoying javascript, I'd recommend checking out Jquery - adds some power to javascript.
- cyclops
- Lives in sente
- Posts: 801
- Joined: Mon May 10, 2010 3:38 pm
- Rank: KGS 7 kyu forever
- GD Posts: 460
- Location: Amsterdam (NL)
- Has thanked: 353 times
- Been thanked: 107 times
- Contact:
Re: A diagram combination extension
hyperpape wrote: "foo.missingAttribute"
I found out who "John Doe" is but I am still missing a clue about foo, even after 15 year C++ experience.
BTW I like hyper's idea a lot!
- RBerenguel
- Gosei
- Posts: 1585
- Joined: Fri Nov 18, 2011 11:44 am
- Rank: KGS 5k
- GD Posts: 0
- KGS: RBerenguel
- Tygem: rberenguel
- Wbaduk: JohnKeats
- Kaya handle: RBerenguel
- Online playing schedule: KGS on Saturday I use to be online, but I can be if needed from 20-23 GMT+1
- Location: Barcelona, Spain (GMT+1)
- Has thanked: 576 times
- Been thanked: 298 times
- Contact:
Re: A diagram combination extension
Cyclops: http://en.wikipedia.org/wiki/Foo (I've read the story many times in many sources, the wiki's is good enough to get an idea
)
Geek of all trades, master of none: the motto for my blog mostlymaths.net
-
hyperpape
- Tengen
- Posts: 4382
- Joined: Thu May 06, 2010 3:24 pm
- Rank: AGA 3k
- GD Posts: 65
- OGS: Hyperpape 4k
- Location: Caldas da Rainha, Portugal
- Has thanked: 499 times
- Been thanked: 727 times
Re: A diagram combination extension
So, I've started working on this again, and putting a few things on github (https://github.com/hyperpape/js-sgftools). The code that actually puts diagram fragments together into a tree of variations isn't there yet, but it could be soonish.