buggnubg - Bugs: bug #53976, Could a Python script advance the...

 
 

bug #53976: Could a Python script advance the display to the next comment entry?

Submitted by:  Tom Martin <tom_martin>
Submitted on:  Fri 25 May 2018 12:41:44 AM UTC  
 
Originator Name:  Tom Martin Item Group:  Feature Request
Category:  Command line interface Release:  1.05-Release
Privacy:  Public Operating System:  Win 8.1
OS Type:  64Bit Processor Type:  Any
Severity:  3 - Normal Open/Closed:  Open
Assigned to:  None Priority:  5 - Normal
Status:  None

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

( Jump to the original submission)

Sat 16 Jun 2018 05:09:33 PM UTC, comment #8: 

I've discovered a function that makes interactive Python use (via GNUBG's command line) a lot more valuable when reviewing saved files.  Calling gnubg.match()['games'][-1]['game'][-1] returns info about the current position.  This allows for all sorts of interesting functions, some of which I'll soon be implementing.

I'm open to suggestions but the two features I'll code first is skipping uncommented actions and providing a continuous stream of SGFs to automatically handle EOFs.  So all you'll need to do is provide a starting point when you run the script the very first time (or whenever you want), type the script name via the command line after starting GNUBG, then do <down arrow><enter> to retrieve a new position.  The script will transparently cycle through as many SGFs as it needs and maintain the file position unless you decide to supply a new one.

So naturally I regret claiming there was no concept of "current position".  The use of -1 solves everything!

Tom Martin <tom_martin>
Wed 06 Jun 2018 07:47:27 PM UTC, comment #7: 

Rather than using Cmark, another method is to simply unmark all decisions that are of no interest to you.  Do this with the commands "annotate move clear" or "annotate cube clear".  You can either paste (<ctrl-V>) the command or use <arrow><enter> to repeat commands already issued (<down arrow> presents the last command executed while <up arrow> yields the "oldest" command if more than one are present). 

The big question is how to handle take/drop decisions.  With Cmarking you're obligated to mark the double itself, which is actually superior since you get to make both parts of the cube decision.  You can do that with "annotate" as well, but you'll have to mark the double as bad (or similar) and that might not be acceptable since that assessment is shown in the analysis window.  If so, you'll need to stick with the drop/take part of the decision that was initially marked by GNUBG.  A sympathetic developer might note the value of an "annotate cube mark" command that would mark the decision but not alter the display.  And naturally "annotate move mark" would also be a nice addition for those positions you got right through pure luck.

This approach is easier to program and if anyone wants it, I'll make it available here.

Tom Martin <tom_martin>
Thu 31 May 2018 02:52:29 AM UTC, comment #6: 

Since the below may encourage people to save interesting positions (one way or another), they should note that it's not for the faint-hearted.  I'd always wondered why there wasn't a big demand for this until I actually started doing it myself.  The problem is that it's very hard on the ego if you save truly challenging positions. 

My guess is that exceeding a yearly improvement rate of 5% is phenomenal if you're Intermediate or above.  Naturally you'll get more than that right in your review sessions, but much of that success can be attributed to dumb luck.  What I'm saying is that if you get (say) 20% correct in 2018, don't expect 30% in 2019 unless you're either a genius or saving easy stuff.

But if you can handle consistent failure, it's the best way to learn.

Tom Martin <tom_martin>
Thu 31 May 2018 01:48:42 AM UTC, comment #5: 

As you suggested, it turns out that the Python interface is designed strictly for batch mode.  It's actually easy to run Python scripts from the command line but there's no way to know the current position.  I was able to programmatically identify every move that I wanted to view, but I couldn't determine which one(s) I'd already seen.  In other words, there doesn't seem to be a  way to determine the current move/game.

I only researched the above because I was uneasy about using the largely undocumented Cmark command.  I tried guessing at its syntax with gnubg.command but gave up after a few unsuccessful tries.  A couple hours on the web gave me no clues and I suspected that digging into GNUBG code would have revealed that Python lacked the ability to use it effectively.

So the answer is to simply manually Cmark the positions I want to see.  That's easy for cubes, but for moves you have to select one first.  That's also easy, of course, but because Cmarking adds a "+" to whichever move(s) we choose, we may want to scroll down to select a move that won't normally be seen.

This manual solution is fine and I thank you for steering me towards it.  If any readers are wondering about the wisdom of saving positions instead of matches/sessions, it depends on how patient you are.  Currently it's pretty awkward but Frank Berger at BGBlitz is planning on developing a nice interface that will work well with GNUBG's saved positions.  It won't be in the next major release but he said it will be in the following one, so we're talking 2-3 years or so.   And maybe that "other software" has similar plans but I very much doubt it.

Tom Martin <tom_martin>
Sat 26 May 2018 05:37:30 PM UTC, comment #4: 

It looks like my best shot is to start with the code at the bottom of scripts/gnubg.py.  As far as I can see, there's nothing outside of the scripts directory that I need to know about.

Tom Martin <tom_martin>
Fri 25 May 2018 09:26:03 PM UTC, comment #3: 

Thanks, Philippe.  If it works, this sounds like the best solution.  I'd run into problems with Cmarking in the past but I can't remember what they were so I'll assume the design is good.

Does anyone have a good starting point?  I've looked through the Python directory and read the README file, but am still a long way from creating a decent script.  I think learning the language will be the least of my worries.

By the way, I thought running a script for each comment entry wouldn't be too awkward because it's just <up arrow> <enter> in the command window each time.  But using Cmark is clearly better.

Tom Martin <tom_martin>
Fri 25 May 2018 07:37:08 PM UTC, comment #2: 

I cannot help with the python programming, but running a script repeatedly while browsing the match seems awkward.

What you could do is hijack the cmark feature : have your python script load the match file ; follow the moves list and if there is a comment attached to a move or a cube decision put a cmark on it ; save the match back.

Then you can load the match from the GUI and go from comment to comment with the Go to next CMarked button.

Philippe Michel <plm>
Project Member
Fri 25 May 2018 12:49:49 AM UTC, comment #1: 

By the way, undocking the panes doesn't help as that hides the commentary for unknown reasons.

Tom Martin <tom_martin>
Fri 25 May 2018 12:41:44 AM UTC, original submission:  

A while back I thought I was smart enough to modify the code to add a new "go to next comment" feature.  Ha!

But modifying the code was never a good idea anyway since it would have been too difficult to get people to agree to add it to the code base.  Instead, could I develop a Python script that could run from the command line?

Here's what I'm trying to do - I've reviewed many sessions and made comments on positions that are worthy of study for me.
What I'm currently doing is going to the next error until I find a comment (or cube offering, in which case I go back to the previous roll).  It's not bad but it's slower than it should be and it risks getting a hint from the commentary.

Far better would be to write a Python script that anyone could use that would reposition the session to the next comment.  Is it possible?  I've never used Python but it shouldn't be too hard to learn. 

Tom Martin <tom_martin>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by plm (Posted a comment)
  • -email is unavailable- added by tom_martin (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

     

     

    No changes have been made to this item

    Back to the top


    Powered by Savane 3.5