Index: engine/aftermath.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/aftermath.c,v retrieving revision 1.32 diff -u -r1.32 aftermath.c --- engine/aftermath.c 2 Sep 2002 14:19:22 -0000 1.32 +++ engine/aftermath.c 10 Sep 2002 15:12:57 -0000 @@ -895,7 +895,7 @@ } play_move(move, color_to_play); if (aftermath_sgftree) - sgftreeAddPlay(aftermath_sgftree, NULL, color_to_play, I(move), J(move)); + sgftreeAddPlay(aftermath_sgftree, color_to_play, I(move), J(move)); moves++; DEBUG(DEBUG_AFTERMATH, "%d %C move %1m (nodes %d, %d total %d, %d)\n", movenum, color_to_play, move, get_owl_node_counter() - owl_nodes, Index: engine/board.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/board.c,v retrieving revision 1.48 diff -u -r1.48 board.c --- engine/board.c 11 Aug 2002 12:13:02 -0000 1.48 +++ engine/board.c 10 Sep 2002 15:13:04 -0000 @@ -516,8 +516,8 @@ message, location_to_string(str), count_variations, hashdata.hashval[0]); } - sgftreeAddPlayLast(sgf_dumptree, NULL, color, I(pos), J(pos)); - sgftreeAddComment(sgf_dumptree, NULL, buf); + sgftreeAddPlayLast(sgf_dumptree, color, I(pos), J(pos)); + sgftreeAddComment(sgf_dumptree, buf); } if (count_variations) @@ -561,8 +561,8 @@ else gg_snprintf(buf, 100, message, sbuf1, sbuf2, count_variations, value); - sgftreeAddPlayLast(sgf_dumptree, NULL, color, I(pos), J(pos)); - sgftreeAddComment(sgf_dumptree, NULL, buf); + sgftreeAddPlayLast(sgf_dumptree, color, I(pos), J(pos)); + sgftreeAddComment(sgf_dumptree, buf); } if (count_variations) @@ -612,13 +612,13 @@ * captures. SGF FF[4] compliant browsers should have no problem * with this, though. */ - sgftreeAddPlayLast(sgf_dumptree, NULL, color, -1, -1); - sgftreeAddComment(sgf_dumptree, NULL, "tenuki (ko threat)"); - sgftreeAddPlayLast(sgf_dumptree, NULL, OTHER_COLOR(color), -1, -1); - sgftreeAddComment(sgf_dumptree, NULL, "tenuki (answers ko threat)"); + sgftreeAddPlayLast(sgf_dumptree, color, -1, -1); + sgftreeAddComment(sgf_dumptree, "tenuki (ko threat)"); + sgftreeAddPlayLast(sgf_dumptree, OTHER_COLOR(color), -1, -1); + sgftreeAddComment(sgf_dumptree, "tenuki (answers ko threat)"); - sgftreeAddPlayLast(sgf_dumptree, NULL, color, I(pos), J(pos)); - sgftreeAddComment(sgf_dumptree, NULL, buf); + sgftreeAddPlayLast(sgf_dumptree, color, I(pos), J(pos)); + sgftreeAddComment(sgf_dumptree, buf); } if (count_variations) @@ -755,7 +755,7 @@ if (sgf_dumptree) { char buf[100]; gg_snprintf(buf, 100, "(next variation: %d)", count_variations); - sgftreeAddComment(sgf_dumptree, NULL, buf); + sgftreeAddComment(sgf_dumptree, buf); sgf_dumptree->lastnode = sgf_dumptree->lastnode->parent; /* After tryko() we need to undo two pass nodes too. Since we have * no other way to identify ko moves, we skip all pass nodes. Index: engine/cache.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/cache.c,v retrieving revision 1.15 diff -u -r1.15 cache.c --- engine/cache.c 4 Sep 2002 07:23:45 -0000 1.15 +++ engine/cache.c 10 Sep 2002 15:13:07 -0000 @@ -809,7 +809,7 @@ if (message) sprintf(buf + strlen(buf), " (%s)", message); - sgftreeAddComment(sgf_dumptree, NULL, buf); + sgftreeAddComment(sgf_dumptree, buf); } /* Write two group reading (connection or semeai) trace data to an SGF @@ -840,7 +840,7 @@ if (message) sprintf(buf + strlen(buf), " (%s)", message); - sgftreeAddComment(sgf_dumptree, NULL, buf); + sgftreeAddComment(sgf_dumptree, buf); } /* Index: engine/combination.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/combination.c,v retrieving revision 1.32 diff -u -r1.32 combination.c --- engine/combination.c 4 Sep 2002 07:23:45 -0000 1.32 +++ engine/combination.c 10 Sep 2002 15:13:09 -0000 @@ -594,7 +594,7 @@ if (retval != 0) { if (sgf_dumptree) /* FIXME: Better message. */ - sgftreeAddComment(sgf_dumptree, NULL, "attack found"); + sgftreeAddComment(sgf_dumptree, "attack found"); return retval; } } @@ -687,7 +687,7 @@ } if (sgf_dumptree) /* FIXME: Better message. */ - sgftreeAddComment(sgf_dumptree, NULL, "attack found"); + sgftreeAddComment(sgf_dumptree, "attack found"); } if (attack_point) Index: engine/gnugo.h =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/gnugo.h,v retrieving revision 1.63 diff -u -r1.63 gnugo.h --- engine/gnugo.h 9 Sep 2002 21:20:11 -0000 1.63 +++ engine/gnugo.h 10 Sep 2002 15:13:14 -0000 @@ -473,8 +473,8 @@ void report_pattern_profiling(void); /* sgffile.c */ -void sgffile_debuginfo(SGFNode *node, int value); -void sgffile_output(SGFNode *root); +void sgffile_add_debuginfo(SGFNode *node, int value); +void sgffile_output(SGFTree *tree); void sgffile_printboard(SGFTree *tree); void sgffile_recordboard(SGFNode *node); Index: engine/interface.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/interface.c,v retrieving revision 1.27 diff -u -r1.27 interface.c --- engine/interface.c 9 Sep 2002 21:20:11 -0000 1.27 +++ engine/interface.c 10 Sep 2002 15:13:19 -0000 @@ -458,7 +458,7 @@ gameinfo_play_move(Gameinfo *ginfo, int i, int j, int color) { gnugo_play_move(i, j, color); - sgftreeAddPlay(&ginfo->game_record, 0, color, i, j); + sgftreeAddPlay(&ginfo->game_record, color, i, j); ginfo->to_move = OTHER_COLOR(color); } Index: engine/readconnect.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/readconnect.c,v retrieving revision 1.35 diff -u -r1.35 readconnect.c --- engine/readconnect.c 3 Jun 2002 15:00:59 -0000 1.35 +++ engine/readconnect.c 10 Sep 2002 15:13:28 -0000 @@ -1705,7 +1705,7 @@ board_size - I(moves[i]), scores[i], &chars); pos += chars; } - sgftreeAddComment(sgf_dumptree, NULL, buf); + sgftreeAddComment(sgf_dumptree, buf); } } @@ -2343,7 +2343,7 @@ board_size - I(moves[i]), distances[i], &chars); pos += chars; } - sgftreeAddComment(sgf_dumptree, NULL, buf); + sgftreeAddComment(sgf_dumptree, buf); } Index: engine/reading.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/reading.c,v retrieving revision 1.67 diff -u -r1.67 reading.c --- engine/reading.c 23 Aug 2002 06:56:48 -0000 1.67 +++ engine/reading.c 10 Sep 2002 15:13:39 -0000 @@ -2816,7 +2816,7 @@ moves.pos[k].name, moves[k].value, &chars); pos += chars; } - sgftreeAddComment(sgf_dumptree, NULL, buf); + sgftreeAddComment(sgf_dumptree, buf); } for (k = 0; MAX_READING_MOVES; k++) { @@ -2828,8 +2828,7 @@ if (k > 3 + skipped && k > 12 - stackp + skipped) { if (sgf_dumptree) { if (trymove(moves[k].pos, next_color, namebuf, str, 0, 0)) { - sgftreeAddComment(sgf_dumptree, NULL, - "move trimmed to reduce variations"); + sgftreeAddComment(sgf_dumptree, "move trimmed to reduce variations"); popgo(); } } @@ -2850,7 +2849,7 @@ sprintf(buf, "tactical_pat komaster: %d %s new_komaster: %d %s ko_move: %d", komaster, location_to_string(kom_pos), new_komaster, location_to_string(new_kom_pos), ko_move); - sgftreeAddComment(sgf_dumptree, NULL, buf); + sgftreeAddComment(sgf_dumptree, buf); } if (stackp > 100) { @@ -5574,7 +5573,7 @@ board_size - I(moves->pos[i]), moves->score[i], &chars); pos += chars; } - sgftreeAddComment(sgf_dumptree, NULL, buf); + sgftreeAddComment(sgf_dumptree, buf); } } Index: engine/sgffile.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/sgffile.c,v retrieving revision 1.19 diff -u -r1.19 sgffile.c --- engine/sgffile.c 9 Sep 2002 21:20:11 -0000 1.19 +++ engine/sgffile.c 10 Sep 2002 15:13:39 -0000 @@ -46,47 +46,52 @@ */ void -sgffile_debuginfo(SGFNode *node, int value) +sgffile_add_debuginfo(SGFNode *node, int value) { int m, n; char comment[24]; - if (outfilename[0]) { - for (m = 0; m < board_size; ++m) - for (n = 0; n < board_size; ++n) { - if (BOARD(m, n) && (output_flags & OUTPUT_MARKDRAGONS)) - switch (dragon[POS(m, n)].crude_status) { - case DEAD: - sgfLabel(node, "X", m, n); - break; - case CRITICAL: - sgfLabel(node, "!", m, n); - break; - } - if (potential_moves[m][n] > 0.0 && (output_flags & OUTPUT_MOVEVALUES)) { - if (potential_moves[m][n] < 1.0) - sgfLabel(node, "<1", m, n); - else - sgfLabelInt(node, (int) potential_moves[m][n], m, n); - } + if (!outfilename[0]) + return; + + for (m = 0; m < board_size; ++m) + for (n = 0; n < board_size; ++n) { + if (BOARD(m, n) && (output_flags & OUTPUT_MARKDRAGONS)) { + switch (dragon[POS(m, n)].crude_status) { + case DEAD: + sgfLabel(node, "X", m, n); + break; + case CRITICAL: + sgfLabel(node, "!", m, n); + break; + } + } + + if (potential_moves[m][n] > 0.0 && (output_flags & OUTPUT_MOVEVALUES)) { + if (potential_moves[m][n] < 1.0) + sgfLabel(node, "<1", m, n); + else + sgfLabelInt(node, (int) potential_moves[m][n], m, n); } - if (value) { - sprintf(comment, "Value of move: %d", value); - sgfAddComment(node, comment); } + + if (value > 0 && (output_flags & OUTPUT_MOVEVALUES)) { + sprintf(comment, "Value of move: %d", value); + sgfAddComment(node, comment); } } /* - * Write sgf tree to output file specified with -o option + * Write sgf tree to output file specified with -o option. + * This can safely be done multiple times. */ void -sgffile_output(SGFNode *root) +sgffile_output(SGFTree *tree) { if (outfilename[0]) - writesgf(root, outfilename); + writesgf(tree->root, outfilename); } @@ -118,8 +123,7 @@ sgf_dumptree = tree; sgftree_clear(sgf_dumptree); - node = sgftreeCreateHeaderNode(sgf_dumptree, board_size, 0.0); - sgftreeSetLastNode(sgf_dumptree, node); + sgftreeCreateHeaderNode(sgf_dumptree, board_size, 0.0); sgffile_printboard(sgf_dumptree); } Index: interface/main.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/interface/main.c,v retrieving revision 1.46 diff -u -r1.46 main.c --- interface/main.c 9 Sep 2002 21:20:11 -0000 1.46 +++ interface/main.c 10 Sep 2002 15:13:48 -0000 @@ -940,6 +940,9 @@ break; case MODE_LOAD_AND_SCORE: + if (mandated_color != EMPTY) + gameinfo.to_move = mandated_color; + if (!infilename) { fprintf(stderr, "gnugo: --score must be used with -l\n"); exit(EXIT_FAILURE); Index: interface/play_ascii.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/interface/play_ascii.c,v retrieving revision 1.24 diff -u -r1.24 play_ascii.c --- interface/play_ascii.c 9 Sep 2002 21:20:11 -0000 1.24 +++ interface/play_ascii.c 10 Sep 2002 15:13:50 -0000 @@ -459,9 +459,9 @@ *passes = 0; gnugo_play_move(i, j, gameinfo->to_move); - sgffile_debuginfo(curnode, move_val); + sgffile_add_debuginfo(curnode, move_val); curnode = sgfAddPlay(curnode, gameinfo->to_move, i, j); - sgffile_output(sgftree.root); + sgffile_output(&sgftree); gameinfo->to_move = OTHER_COLOR(gameinfo->to_move); } @@ -490,9 +490,9 @@ TRACE("\nyour move: %m\n\n", i, j); init_sgf(gameinfo, sgftree.root); gnugo_play_move(i, j, gameinfo->to_move); - sgffile_debuginfo(curnode, 0); + sgffile_add_debuginfo(curnode, 0); curnode = sgfAddPlay(curnode, gameinfo->to_move, i, j); - sgffile_output(sgftree.root); + sgffile_output(&sgftree); last_move_i = i; last_move_j = j; @@ -522,9 +522,9 @@ (*passes)++; init_sgf(gameinfo, sgftree.root); gnugo_play_move(-1, -1, gameinfo->to_move); - sgffile_debuginfo(curnode, 0); + sgffile_add_debuginfo(curnode, 0); curnode = sgfAddPlay(curnode, gameinfo->to_move, -1, -1); - sgffile_output(sgftree.root); + sgffile_output(&sgftree); gameinfo->to_move = OTHER_COLOR(gameinfo->to_move); if (force) { @@ -617,7 +617,7 @@ sgftreeWriteResult(&sgftree, gameinfo->to_move == WHITE ? -1000.0 : 1000.0, 1); - sgffile_output(sgftree.root); + sgffile_output(&sgftree); case END: case EXIT: case QUIT: @@ -872,8 +872,8 @@ if (tmpstring) { /* discard newline */ tmpstring[strlen(tmpstring)-1] = 0; - /* make sure we are saving proper handicap */ - init_sgf(gameinfo, sgftree.root); + /* make sure we are saving proper handicap */ + init_sgf(gameinfo, sgftree.root); writesgf(sgftree.root, tmpstring); printf("You may resume the game"); printf(" with -l %s --mode ascii\n", tmpstring); @@ -941,7 +941,7 @@ if (tmpstring) { /* discard newline */ tmpstring[strlen(tmpstring)-1] = 0; - init_sgf(gameinfo,sgftree.root); + init_sgf(gameinfo, sgftree.root); writesgf(sgftree.root, tmpstring); } else @@ -965,7 +965,7 @@ } } sgftreeWriteResult(&sgftree, estimate_score(NULL, NULL), 1); - sgffile_output(sgftree.root); + sgffile_output(&sgftree); passes = 0; showdead = 0; /* Play a different game next time. */ Index: interface/play_gmp.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/interface/play_gmp.c,v retrieving revision 1.10 diff -u -r1.10 play_gmp.c --- interface/play_gmp.c 9 Sep 2002 21:20:11 -0000 1.10 +++ interface/play_gmp.c 10 Sep 2002 15:13:50 -0000 @@ -48,7 +48,6 @@ int mycolor; /* who has which color */ int yourcolor; - SGFNode *curnode = NULL; /* current SGFNode */ mycolor = gameinfo->computer_player; @@ -60,8 +59,6 @@ ge = gmp_create(0, 1); TRACE("board size=%d\n", gnugo_get_boardsize()); - curnode = sgftree.root; - /* Leave all the -1's so the client can negotiate the game parameters. */ if (chinese_rules) gmp_startGame(ge, -1, -1, 5.5, -1, -1); @@ -132,8 +129,8 @@ if (message == gmp_err) { fprintf(stderr, "GNU Go: Sorry, error from gmp client\n"); - sgfAddComment(curnode, "got error from gmp client"); - sgffile_output(sgftree.root); + sgftreeAddComment(&sgftree, "got error from gmp client"); + sgffile_output(&sgftree); return; } @@ -147,8 +144,9 @@ j - k); break; } - sgfAddComment(curnode, "undone"); - curnode = curnode->parent; + sgftreeAddComment(&sgftree, "undone"); + /* FIXME: Add a function in sgftree.c to do this. */ + sgftree.lastnode = sgftree.lastnode->parent; to_move = OTHER_COLOR(to_move); } continue; @@ -156,17 +154,17 @@ if (message == gmp_pass) { ++passes; - curnode = sgfAddPlay(curnode, to_move, -1, -1); + sgftreeAddPlay(&sgftree, to_move, -1, -1); gnugo_play_move(-1, -1, yourcolor); - sgffile_output(sgftree.root); + sgffile_output(&sgftree); } else { /* not pass */ passes = 0; - curnode = sgfAddPlay(curnode, to_move, i, j); + sgftreeAddPlay(&sgftree, to_move, i, j); TRACE("\nyour move: %m\n\n", i, j); gnugo_play_move(i, j, yourcolor); - sgffile_output(sgftree.root); + sgffile_output(&sgftree); } } @@ -174,23 +172,23 @@ /* Generate my next move. */ moveval = gnugo_genmove(&i, &j, mycolor); gnugo_play_move(i, j, mycolor); - sgffile_debuginfo(curnode, moveval); + sgffile_add_debuginfo(sgftree.lastnode, moveval); if (moveval < 0) { /* pass */ - curnode = sgfAddPlay(curnode, to_move, -1, -1); + sgftreeAddPlay(&sgftree, to_move, -1, -1); gmp_sendPass(ge); ++passes; } else { /* not pass */ - curnode = sgfAddPlay(curnode, to_move, i, j); + sgftreeAddPlay(&sgftree, to_move, i, j); gmp_sendMove(ge, j, i); passes = 0; TRACE("\nmy move: %m\n\n", i, j); } - sgffile_debuginfo(curnode, 0); - sgffile_output(sgftree.root); + sgffile_add_debuginfo(sgftree.lastnode, 0); + sgffile_output(&sgftree); } to_move = OTHER_COLOR(to_move); @@ -214,7 +212,7 @@ score = gnugo_estimate_score(&lower_bound, &upper_bound); sgfWriteResult(sgftree.root, score, 1); - sgffile_output(sgftree.root); + sgffile_output(&sgftree); while (!time_to_die) { message = gmp_check(ge, 1, &j, &i, &error); Index: interface/play_solo.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/interface/play_solo.c,v retrieving revision 1.16 diff -u -r1.16 play_solo.c --- interface/play_solo.c 9 Sep 2002 21:20:12 -0000 1.16 +++ interface/play_solo.c 10 Sep 2002 15:13:51 -0000 @@ -34,12 +34,10 @@ #include "random.h" #include "gg_utils.h" -SGFTree sgftree; -SGFNode *curnode; - void play_solo(Gameinfo *gameinfo, int moves) { + SGFTree sgftree; int passes = 0; /* num. consecutive passes */ int move_val; double t1, t2; @@ -61,7 +59,7 @@ gnugo_set_komi(5.5); sgftree_clear(&sgftree); - curnode = sgftreeCreateHeaderNode(&sgftree, gnugo_get_boardsize(), gnugo_get_komi()); + sgftreeCreateHeaderNode(&sgftree, gnugo_get_boardsize(), gnugo_get_komi()); sgf_write_header(sgftree.root, 1, random_seed, 5.5, level, chinese_rules); /* Generate some random moves. */ @@ -73,8 +71,8 @@ } while (!gnugo_is_legal(i, j, gameinfo->to_move)); gnugo_play_move(i, j, gameinfo->to_move); - curnode = sgfAddPlay(curnode, gameinfo->to_move, i, j); - sgfAddComment(curnode, "random move"); + sgftreeAddPlay(&sgftree, gameinfo->to_move, i, j); + sgftreeAddComment(&sgftree, "random move"); gameinfo->to_move = OTHER_COLOR(gameinfo->to_move); } while (--n > 0); } @@ -86,9 +84,9 @@ move_val = gnugo_genmove(&i, &j, gameinfo->to_move); gnugo_play_move(i, j, gameinfo->to_move); - sgffile_debuginfo(curnode, move_val); - curnode = sgfAddPlay(curnode, gameinfo->to_move, i, j); - sgffile_output(sgftree.root); + sgffile_add_debuginfo(sgftree.lastnode, move_val); + sgftreeAddPlay(&sgftree, gameinfo->to_move, i, j); + sgffile_output(&sgftree); gameinfo->to_move = OTHER_COLOR(gameinfo->to_move); if (move_val < 0) { @@ -116,7 +114,7 @@ score = gnugo_estimate_score(&lower_bound, &upper_bound); sgfWriteResult(sgftree.root, score, 1); - sgffile_output(sgftree.root); + sgffile_output(&sgftree); #if 0 if (t2 == t1) @@ -151,6 +149,7 @@ void load_and_analyze_sgf_file(Gameinfo *gameinfo) { + SGFTree sgftree; int i, j; int next; int move_val; @@ -167,11 +166,11 @@ i, j); gnugo_play_move(i, j, next); - curnode = sgftreeNodeCheck(&sgftree, 0); - curnode = sgfAddPlay(curnode, next, i, j); - sgfAddComment(curnode, "load and analyze mode"); - sgffile_debuginfo(curnode, move_val); - sgffile_output(sgftree.root); + sgftreeNodeCheck(&sgftree, 0); + sgftreeAddPlay(&sgftree, next, i, j); + sgftreeAddComment(&sgftree, "load and analyze mode"); + sgffile_add_debuginfo(sgftree.lastnode, move_val); + sgffile_output(&sgftree); } @@ -189,7 +188,6 @@ const char *scoringmode) { int i, j, move_val; - int until; float result; char *tempc = NULL; char dummy; @@ -198,20 +196,16 @@ int next; int pass = 0; SGFTree score_tree; - SGFNode *node; sgftree_clear(&score_tree); - node = sgftreeCreateHeaderNode(&score_tree, board_size, komi); - sgftreeSetLastNode(&score_tree, node); + sgftreeCreateHeaderNode(&score_tree, board_size, komi); sgffile_printboard(&score_tree); next = gameinfo->to_move; - node = node->child; doing_scoring = 1; reset_engine(); if (!strcmp(scoringmode, "finish") || !strcmp(scoringmode, "aftermath")) { - until = 9999; do { move_val = genmove_conservative(&i, &j, next); if (move_val >= 0) { @@ -225,11 +219,11 @@ next == WHITE ? "white (O)" : "black (X)"); } play_move(POS(i, j), next); - sgffile_debuginfo(node, move_val); - node = sgfAddPlay(node, next, i, j); - sgffile_output(score_tree.root); + sgffile_add_debuginfo(score_tree.lastnode, move_val); + sgftreeAddPlay(&score_tree, next, i, j); + sgffile_output(&score_tree); next = OTHER_COLOR(next); - } while (movenum <= until && pass < 2); + } while (movenum <= 10000 && pass < 2); if (pass >= 2) { /* Calculate the score */ @@ -251,7 +245,7 @@ winner = '0'; } fputs(text, stdout); - sgfAddComment(node, text); + sgftreeAddComment(&score_tree, text); if (sgfGetCharProperty(tree->root, "RE", &tempc)) { if (sscanf(tempc, "%1c%f", &dummy, &result) == 2) { fprintf(stdout, "Result from file: %1.1f\n", result); @@ -274,11 +268,10 @@ } } sgfWriteResult(score_tree.root, score, 1); - sgffile_output(score_tree.root); + sgffile_output(&score_tree); } } doing_scoring = 0; - if (strcmp(scoringmode, "aftermath")) { /* Before we call estimate_score() we must make sure that the dragon Index: interface/play_test.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/interface/play_test.c,v retrieving revision 1.11 diff -u -r1.11 play_test.c --- interface/play_test.c 9 Sep 2002 21:20:12 -0000 1.11 +++ interface/play_test.c 10 Sep 2002 15:13:51 -0000 @@ -86,7 +86,7 @@ */ while (node) { replay_node(node, color_to_replay); - sgffile_output(tree.root); + sgffile_output(&tree); node = node->child; } } @@ -170,7 +170,7 @@ location_to_string(POS(i, j)), gnugo_is_pass(i, j) ? 0 : potential_moves[i][j]); sgfAddComment(node, buf); - sgffile_debuginfo(node, 0); + sgffile_add_debuginfo(node, 0); } /* Finally, do play the move from the file. */ Index: sgf/sgftree.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/sgf/sgftree.c,v retrieving revision 1.9 diff -u -r1.9 sgftree.c --- sgf/sgftree.c 4 Sep 2002 07:23:46 -0000 1.9 +++ sgf/sgftree.c 10 Sep 2002 15:14:12 -0000 @@ -77,13 +77,11 @@ * Return the node where the stone was added. */ -SGFNode * -sgftreeAddStone(SGFTree *tree, SGFNode *node, int color, int movex, int movey) +void +sgftreeAddStone(SGFTree *tree, int color, int movex, int movey) { - node = sgftreeNodeCheck(tree, node); + SGFNode *node = sgftreeNodeCheck(tree, NULL); sgfAddStone(node, color, movex, movey); - - return node; } @@ -91,14 +89,11 @@ * Add a move to the gametree. */ -SGFNode * -sgftreeAddPlay(SGFTree *tree, SGFNode *node, int color, int movex, int movey) +void +sgftreeAddPlay(SGFTree *tree, int color, int movex, int movey) { - node = sgftreeNodeCheck(tree, node); - node = sgfAddPlay(node, color, movex, movey); - tree->lastnode = node; - - return node; + SGFNode *node = sgftreeNodeCheck(tree, NULL); + tree->lastnode = sgfAddPlay(node, color, movex, movey); } @@ -107,19 +102,15 @@ * ones rather than before. */ -SGFNode * -sgftreeAddPlayLast(SGFTree *tree, SGFNode *node, int color, - int movex, int movey) +void +sgftreeAddPlayLast(SGFTree *tree, int color, int movex, int movey) { - node = sgftreeNodeCheck(tree, node); - node = sgfAddPlayLast(node, color, movex, movey); - tree->lastnode = node; - - return node; + SGFNode *node = sgftreeNodeCheck(tree, NULL); + tree->lastnode = sgfAddPlayLast(node, color, movex, movey); } -SGFNode * +void sgftreeCreateHeaderNode(SGFTree *tree, int boardsize, float komi) { SGFNode *root = sgfNewNode(); @@ -127,8 +118,7 @@ sgfAddPropertyInt(root, "SZ", boardsize); sgfAddPropertyFloat(root, "KM", komi); tree->root = root; - - return root; + tree->lastnode = root; } @@ -136,15 +126,14 @@ * Add a comment to a gametree. */ -SGFNode * -sgftreeAddComment(SGFTree *tree, SGFNode *node, const char *comment) +void +sgftreeAddComment(SGFTree *tree, const char *comment) { + SGFNode *node; assert(tree && tree->root); - node = sgftreeNodeCheck(tree, node); + node = sgftreeNodeCheck(tree, NULL); sgfAddComment(node, comment); - - return node; } @@ -152,15 +141,14 @@ * Place text on the board at position (i, j). */ -SGFNode * -sgftreeBoardText(SGFTree *tree, SGFNode *node, int i, int j, const char *text) +void +sgftreeBoardText(SGFTree *tree, int i, int j, const char *text) { + SGFNode *node; assert(tree->root); - node = sgftreeNodeCheck(tree, node); + node = sgftreeNodeCheck(tree, NULL); sgfBoardText(node, i, j, text); - - return node; } @@ -168,15 +156,14 @@ * Place a character on the board at position (i, j). */ -SGFNode * -sgftreeBoardChar(SGFTree *tree, SGFNode *node, int i, int j, char c) +void +sgftreeBoardChar(SGFTree *tree, int i, int j, char c) { + SGFNode *node; assert(tree->root); - node = sgftreeNodeCheck(tree, node); + node = sgftreeNodeCheck(tree, NULL); sgfBoardChar(node, i, j, c); - - return node; } @@ -184,13 +171,11 @@ * Place a number on the board at position (i, j). */ -SGFNode * -sgftreeBoardNumber(SGFTree *tree, SGFNode *node, int i, int j, int number) +void +sgftreeBoardNumber(SGFTree *tree, int i, int j, int number) { - node = sgftreeNodeCheck(tree, node); + SGFNode *node = sgftreeNodeCheck(tree, NULL); sgfBoardNumber(node, i, j, number); - - return node; } @@ -198,13 +183,11 @@ * Place a circle mark on the board at position (i, j). */ -SGFNode * -sgftreeTriangle(SGFTree *tree, SGFNode *node, int i, int j) +void +sgftreeTriangle(SGFTree *tree, int i, int j) { - node = sgftreeNodeCheck(tree, node); + SGFNode *node = sgftreeNodeCheck(tree, NULL); sgfTriangle(node, i, j); - - return node; } @@ -212,13 +195,11 @@ * Place a circle mark on the board at position (i, j). */ -SGFNode * -sgftreeCircle(SGFTree *tree, SGFNode *node, int i, int j) +void +sgftreeCircle(SGFTree *tree, int i, int j) { - node = sgftreeNodeCheck(tree, node); + SGFNode *node = sgftreeNodeCheck(tree, NULL); sgfCircle(node, i, j); - - return node; } @@ -226,13 +207,11 @@ * Place a square mark on the board at position (i, j). */ -SGFNode * -sgftreeSquare(SGFTree *tree, SGFNode *node, int i, int j) +void +sgftreeSquare(SGFTree *tree, int i, int j) { - node = sgftreeNodeCheck(tree, node); + SGFNode *node = sgftreeNodeCheck(tree, NULL); sgfSquare(node, i, j); - - return node; } @@ -240,13 +219,11 @@ * Place a (square) mark on the board at position (i, j). */ -SGFNode * -sgftreeMark(SGFTree *tree, SGFNode *node, int i, int j) +void +sgftreeMark(SGFTree *tree, int i, int j) { - node = sgftreeNodeCheck(tree, node); + SGFNode *node = sgftreeNodeCheck(tree, NULL); sgfMark(node, i, j); - - return node; } @@ -254,11 +231,11 @@ * Start a new variant. Returns a pointer to the new node. */ -SGFNode * -sgftreeStartVariant(SGFTree *tree, SGFNode *node) +void +sgftreeStartVariant(SGFTree *tree) { - node = sgftreeNodeCheck(tree, node); - return sgfStartVariant(node); + SGFNode *node = sgftreeNodeCheck(tree, NULL); + tree->lastnode = sgfStartVariant(node); } @@ -266,12 +243,11 @@ * Start a new variant as first child. Returns a pointer to the new node. */ -SGFNode * -sgftreeStartVariantFirst(SGFTree *tree, SGFNode *node) +void +sgftreeStartVariantFirst(SGFTree *tree) { - node = sgftreeNodeCheck(tree, node); - return sgfStartVariantFirst(node); - + SGFNode *node = sgftreeNodeCheck(tree, node); + tree->lastnode = sgfStartVariantFirst(node); } Index: sgf/sgftree.h =================================================================== RCS file: /cvsroot/gnugo/gnugo/sgf/sgftree.h,v retrieving revision 1.10 diff -u -r1.10 sgftree.h --- sgf/sgftree.h 4 Sep 2002 07:23:46 -0000 1.10 +++ sgf/sgftree.h 10 Sep 2002 15:14:12 -0000 @@ -134,29 +134,24 @@ void sgftree_clear(SGFTree *tree); int sgftree_readfile(SGFTree *tree, const char *infilename); -SGFNode *sgftreeAddPlay(SGFTree *tree, SGFNode *node, int color, - int movex, int movey); -SGFNode *sgftreeAddPlayLast(SGFTree *tree, SGFNode *node, int color, - int movex, int movey); -SGFNode *sgftreeAddStone(SGFTree *tree, SGFNode *node, - int color, int movex, int movey); -void sgftreeWriteResult(SGFTree *tree, float score, int overwrite); +void sgftreeAddPlay(SGFTree *tree, int color, int movex, int movey); +void sgftreeAddPlayLast(SGFTree *tree, int color, int movex, int movey); +void sgftreeAddStone(SGFTree *tree, int color, int movex, int movey); +void sgftreeWriteResult(SGFTree *tree, float score, int overwrite); SGFNode *sgftreeNodeCheck(SGFTree *tree, SGFNode *node); -SGFNode *sgftreeCircle (SGFTree *tree, SGFNode *node, int i, int j); -SGFNode *sgftreeSquare (SGFTree *tree, SGFNode *node, int i, int j); -SGFNode *sgftreeTriangle(SGFTree *tree, SGFNode *node, int i, int j); -SGFNode *sgftreeMark (SGFTree *tree, SGFNode *node, int i, int j); -SGFNode *sgftreeAddComment(SGFTree *tree, SGFNode *node, const char *comment); -SGFNode *sgftreeBoardText(SGFTree *tree, SGFNode *node, int i, int j, - const char *text); -SGFNode *sgftreeBoardChar(SGFTree *tree, SGFNode *node, int i, int j, char c); -SGFNode *sgftreeBoardNumber(SGFTree *tree, SGFNode *node, - int i, int j, int number); -SGFNode *sgftreeStartVariant(SGFTree *tree, SGFNode *node); -SGFNode *sgftreeStartVariantFirst(SGFTree *tree, SGFNode *node); -SGFNode *sgftreeCreateHeaderNode(SGFTree *tree, int boardsize, float komi); -void sgftreeSetLastNode(SGFTree *tree, SGFNode *lastnode); +void sgftreeCircle(SGFTree *tree, int i, int j); +void sgftreeSquare(SGFTree *tree, int i, int j); +void sgftreeTriangle(SGFTree *tree, int i, int j); +void sgftreeMark(SGFTree *tree, int i, int j); +void sgftreeAddComment(SGFTree *tree, const char *comment); +void sgftreeBoardText(SGFTree *tree, int i, int j, const char *text); +void sgftreeBoardChar(SGFTree *tree, int i, int j, char c); +void sgftreeBoardNumber(SGFTree *tree, int i, int j, int number); +void sgftreeStartVariant(SGFTree *tree); +void sgftreeStartVariantFirst(SGFTree *tree); +void sgftreeCreateHeaderNode(SGFTree *tree, int boardsize, float komi); +void sgftreeSetLastNode(SGFTree *tree, SGFNode *lastnode); /* ---------------------------------------------------------------- */