-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
next: Support more sgf properties #376
Conversation
60a86f4
to
c8fa385
Compare
Ok, I'll update all unmerge code. |
@zsalch I won't have time to give you a detailed review today (it's coming next ^^'), but I can already tell you that I would like to see some tests for the additional sgf properties you want to support. |
@OlivierBlanvillain |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @zsalch!
@@ -367,4 +420,158 @@ private static String generateNode(Board board, BoardHistoryNode node) throws IO | |||
|
|||
return builder.toString(); | |||
} | |||
|
|||
public static boolean isListProperty(String key) { | |||
for (String k : listProps) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the same as listProps.contains(key)
. Given that it's so short you might want to remove the method altogether and simply do listProps.contains(key)
instead...
Same for isMarkupProperty
below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The listProps is a String[]. It seems no contains function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed... What about 'Arrays.asList(listProps).contains(key)`?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think directly loop search should be faster.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not :)
https://gist.github.com/OlivierBlanvillain/266d5176d559a66e47973f321162c770
JVM performance is a complicated subject...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strict! Fixed.
moveY, | ||
LizzieFrame.OpenSansRegularBase, | ||
moves[1], | ||
(float) (stoneRadius * 1.4), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double labelRadius = stoneRadius * 1.4;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
(float) (stoneRadius * 1.4), | ||
(int) (stoneRadius * 1.4)); | ||
} else if ("TR".equals(key)) { | ||
// Triangle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can remove these comments, it's already clear enough from the method name, drawTriangle
! (same for the calls below)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
public void reopen(int size) { | ||
size = (size == 13 || size == 9) ? size : 19; | ||
if (size != BOARD_SIZE) { | ||
BOARD_SIZE = size; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you mutate it here it really has to be lower cased: boardSize
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
* @return | ||
*/ | ||
public static void addProperties(Map<String, String> props, String propsStr) { | ||
if (propsStr != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment than above, can propsStr
ever be null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same above
StringBuilder tagBuilder = new StringBuilder(); | ||
StringBuilder tagContentBuilder = new StringBuilder(); | ||
|
||
for (int i = 0; i < propsStr.length(); i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very low level... Any reason not to use a regular expression?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't found a regular expression that can simple process sgf like following.
;CA[gb2312]AB[pe][pq][oq][nq][mq][cp][dq][eq][fp]AW[dc][cf][oc][qo][op][np][mp]
[ep][fq]AP[MultiGo:4.4.4]SZ[19]AB[qd]MULTIGOGM[1]
But maybe can change how to write the "KM[%s]PW[%s]PB[%s]DT[%s]AP[Lizzie: %s]".
} | ||
|
||
/** | ||
* Add the properties |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be useful do document that this done by mutating the props
map, same comment for the other added methods in SGFParser.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
LGTM, thanks! |
Support more sgf properties, such as node properties (TR, SQ, CR, MA, LB, MN and AW/AB/AE of Move) and general properties.