508 |
GTK.Widget data_widget; |
GTK.Widget data_widget; |
509 |
|
|
510 |
GTK.ScrolledWindow scrolled_data_window; |
GTK.ScrolledWindow scrolled_data_window; |
|
array(GTK.Window) all_windows = ({}); |
|
511 |
GTK.Image gtk_image; |
GTK.Image gtk_image; |
512 |
GDK.Image gdk_image; |
GDK.Image gdk_image; |
513 |
GTK.Clist clist; |
GTK.Clist clist; |
516 |
|
|
517 |
mapping(string:array(string)) worms = ([]); |
mapping(string:array(string)) worms = ([]); |
518 |
mapping(string:array(string)) dragons = ([]); |
mapping(string:array(string)) dragons = ([]); |
519 |
|
int worms_initialized = 0; |
520 |
|
int dragons_initialized = 0; |
521 |
|
|
522 |
string name; |
string name; |
523 |
string result; |
string result; |
542 |
int boardsize = (int) send_command("query_boardsize"); |
int boardsize = (int) send_command("query_boardsize"); |
543 |
on_board_click_callback = callback; |
on_board_click_callback = callback; |
544 |
|
|
545 |
foreach (send_command("worm_stones") / "\n", string worm) |
setup_board(boardsize); |
546 |
worms[(worm / " ")[0]] = worm / " " - ({""}); |
|
547 |
|
scrolled_data_window = GTK.ScrolledWindow(); |
548 |
|
scrolled_data_window->set_policy(GTK.POLICY_AUTOMATIC, |
549 |
|
GTK.POLICY_AUTOMATIC); |
550 |
|
|
551 |
|
clist = GTK.Clist(3); |
552 |
|
scrolled_data_window->add(clist); |
553 |
|
handle_testcase(); |
554 |
|
} |
555 |
|
|
556 |
|
static void setup_board(int boardsize) |
557 |
|
{ |
558 |
goban = Goban(boardsize, 600); |
goban = Goban(boardsize, 600); |
559 |
goban->add_stones("WHITE", send_command("list_stones white") / " "); |
goban->add_stones("WHITE", send_command("list_stones white") / " "); |
560 |
goban->add_stones("BLACK", send_command("list_stones black") / " "); |
goban->add_stones("BLACK", send_command("list_stones black") / " "); |
561 |
Image.Image im = goban->draw_board(); |
Image.Image im = goban->draw_board(); |
562 |
|
|
563 |
gdk_image = GDK.Image(0)->set(im); |
gdk_image = GDK.Image(0)->set(im); |
564 |
gtk_image = GTK.Image(gdk_image); |
gtk_image = GTK.Image(gdk_image); |
565 |
goban_widget = GTK.EventBox()->add(gtk_image); |
goban_widget = GTK.EventBox()->add(gtk_image); |
569 |
button_pressed_on_board); |
button_pressed_on_board); |
570 |
goban_widget->signal_connect_new("key_press_event", |
goban_widget->signal_connect_new("key_press_event", |
571 |
key_pressed_on_board); |
key_pressed_on_board); |
572 |
|
} |
573 |
|
|
|
scrolled_data_window = GTK.ScrolledWindow(); |
|
|
scrolled_data_window->set_policy(GTK.POLICY_AUTOMATIC, |
|
|
GTK.POLICY_AUTOMATIC); |
|
574 |
|
|
575 |
all_windows = ({}); |
void new_testcase(array(string) fulltest_, string testcase_command_) |
576 |
|
{ |
577 |
clist = GTK.Clist(3); |
werror("Loading new testcase.\n"); |
578 |
scrolled_data_window->add(clist); |
worms_initialized = 0; |
579 |
|
dragons_initialized = 0; |
580 |
// thread_create(handle_testcase); |
result = ""; |
581 |
handle_testcase(); |
worms = ([]); |
582 |
|
dragons = ([]); |
583 |
|
|
584 |
|
fulltest = fulltest_; |
585 |
|
testcase_command = testcase_command_; |
586 |
|
|
587 |
|
load_testcase(); |
588 |
|
werror("%s\n", send_command("showboard")); |
589 |
|
int boardsize = (int) send_command("query_boardsize"); |
590 |
|
|
591 |
|
werror("Loaded new testcase.\n"); |
592 |
|
goban = Goban(boardsize, 600); |
593 |
|
goban->add_stones("WHITE", send_command("list_stones white") / " "); |
594 |
|
goban->add_stones("BLACK", send_command("list_stones black") / " "); |
595 |
|
redraw_board(); |
596 |
} |
} |
597 |
|
|
598 |
|
|
599 |
static void load_testcase() |
static void load_testcase() |
600 |
{ |
{ |
601 |
foreach(fulltest, string testline) { |
foreach(fulltest, string testline) { |
605 |
} |
} |
606 |
} |
} |
607 |
|
|
608 |
static void handle_testcase() |
void handle_testcase() |
609 |
{ |
{ |
610 |
traces = ({}); |
traces = ({}); |
611 |
engine->trace_callback = collect_traces; |
engine->trace_callback = collect_traces; |
612 |
result = send_command(testcase_command); |
result = send_command(testcase_command); |
613 |
engine->trace_callback = 0; |
engine->trace_callback = 0; |
|
|
|
|
// Due to a bug in the examine_position caching, we can't do |
|
|
// this before a genmove call. |
|
|
foreach (send_command("dragon_stones") / "\n", string dragon) |
|
|
dragons[(dragon / " ")[0]] = dragon / " " - ({""}); |
|
|
|
|
614 |
redraw_board(); |
redraw_board(); |
615 |
} |
} |
616 |
|
|
619 |
traces += ({s}); |
traces += ({s}); |
620 |
} |
} |
621 |
|
|
622 |
|
void get_dragons() |
623 |
|
{ |
624 |
|
foreach (send_command("dragon_stones") / "\n", string dragon) |
625 |
|
dragons[(dragon / " ")[0]] = dragon / " " - ({""}); |
626 |
|
dragons_initialized = 1; |
627 |
|
} |
628 |
|
|
629 |
|
static void get_worms() |
630 |
|
{ |
631 |
|
foreach (send_command("worm_stones") / "\n", string worm) |
632 |
|
worms[(worm / " ")[0]] = worm / " " - ({""}); |
633 |
|
worms_initialized = 1; |
634 |
|
} |
635 |
|
|
636 |
|
|
637 |
void add_markup(int mode) |
void add_markup(int mode) |
638 |
{ |
{ |
639 |
goban->clear_markup(); |
goban->clear_markup(); |
665 |
|
|
666 |
if (parent->dragon_status_button->get_active()) |
if (parent->dragon_status_button->get_active()) |
667 |
{ |
{ |
668 |
|
if (!dragons_initialized) |
669 |
|
get_dragons(); |
670 |
foreach (dragons; string dragon; array(string) stones) |
foreach (dragons; string dragon; array(string) stones) |
671 |
{ |
{ |
672 |
string status = get_worm_or_dragon_data("dragon", "status", |
string status = get_worm_or_dragon_data("dragon", "status", |
678 |
} |
} |
679 |
else if (parent->dragon_safety_button->get_active()) |
else if (parent->dragon_safety_button->get_active()) |
680 |
{ |
{ |
681 |
|
if (!dragons_initialized) |
682 |
|
get_dragons(); |
683 |
foreach (dragons; string dragon; array(string) stones) |
foreach (dragons; string dragon; array(string) stones) |
684 |
{ |
{ |
685 |
string safety = get_worm_or_dragon_data("dragon", "safety", |
string safety = get_worm_or_dragon_data("dragon", "safety", |
691 |
} |
} |
692 |
else if (parent->worm_status_button->get_active()) |
else if (parent->worm_status_button->get_active()) |
693 |
{ |
{ |
694 |
|
if (!worms_initialized) |
695 |
|
get_worms(); |
696 |
foreach (worms; string worm; array(string) stones) |
foreach (worms; string worm; array(string) stones) |
697 |
{ |
{ |
698 |
string attack = get_worm_or_dragon_data("worm", "attack_code", |
string attack = get_worm_or_dragon_data("worm", "attack_code", |
1137 |
string send_command(string command) |
string send_command(string command) |
1138 |
{ |
{ |
1139 |
string result; |
string result; |
|
//all_windows->set_cursor(GDK.Watch); |
|
1140 |
result = engine->send_command(command)->text; |
result = engine->send_command(command)->text; |
|
//all_windows->set_cursor(GDK.TopLeftArrow); |
|
1141 |
return result; |
return result; |
1142 |
} |
} |
1143 |
|
|
1213 |
GTK.Notebook data_notebook; |
GTK.Notebook data_notebook; |
1214 |
GTK.Notebook selector_notebook; |
GTK.Notebook selector_notebook; |
1215 |
|
|
1216 |
|
GTK.Widget testcase_label; |
1217 |
|
|
1218 |
GTK.RadioButton worm_data_button; |
GTK.RadioButton worm_data_button; |
1219 |
GTK.RadioButton dragon_data1_button; |
GTK.RadioButton dragon_data1_button; |
1220 |
GTK.RadioButton dragon_data2_button; |
GTK.RadioButton dragon_data2_button; |
1256 |
GTK.CheckButton sgf_traces_button, sgf_viewer_button; |
GTK.CheckButton sgf_traces_button, sgf_viewer_button; |
1257 |
GTK.Entry sgf_filename_entry, sgf_viewer_entry; |
GTK.Entry sgf_filename_entry, sgf_viewer_entry; |
1258 |
GTK.Table sgf_stuff; |
GTK.Table sgf_stuff; |
1259 |
GTK.Button new_engine_button; |
GTK.Button new_testcase_button, new_engine_button; |
1260 |
GTK.Entry engine_path_entry; |
GTK.Entry new_testcase_entry, engine_path_entry, engine_name_entry; |
|
GTK.Entry engine_name_entry; |
|
1261 |
|
|
1262 |
string delta_territory_move = "PASS"; |
string delta_territory_move = "PASS"; |
1263 |
string move_influence_move = "PASS"; |
string move_influence_move = "PASS"; |
1284 |
} |
} |
1285 |
testcase_name = testcase; |
testcase_name = testcase; |
1286 |
|
|
1287 |
GTK.Widget testcase_label = (GTK.Label(full_testcase * "\n") |
testcase_label = (GTK.Label(full_testcase * "\n") |
1288 |
->set_justify(GTK.JUSTIFY_LEFT)); |
->set_justify(GTK.JUSTIFY_LEFT)); |
1289 |
|
|
1290 |
main_window = GTK.Window(GTK.WindowToplevel); |
main_window = GTK.Window(GTK.WindowToplevel); |
1291 |
controller_notebook = GTK.Notebook(); |
controller_notebook = GTK.Notebook(); |
1462 |
->attach_defaults(sgf_viewer_button, 0, 1, 1, 2) |
->attach_defaults(sgf_viewer_button, 0, 1, 1, 2) |
1463 |
->attach_defaults(sgf_viewer_entry, 1, 2, 1, 2); |
->attach_defaults(sgf_viewer_entry, 1, 2, 1, 2); |
1464 |
|
|
1465 |
|
new_testcase_entry = GTK.Entry(); |
1466 |
|
new_testcase_entry->set_text("owl:1"); |
1467 |
|
new_testcase_entry->set_editable(1); |
1468 |
|
new_testcase_button = GTK.Button("Load new testcase"); |
1469 |
|
new_testcase_button->signal_connect_new("clicked", new_testcase); |
1470 |
engine_path_entry = GTK.Entry(); |
engine_path_entry = GTK.Entry(); |
1471 |
engine_path_entry->set_text("../interface/gnugo"); |
engine_path_entry->set_text("../interface/gnugo"); |
1472 |
engine_path_entry->set_editable(1); |
engine_path_entry->set_editable(1); |
1551 |
if (single_window_mode) |
if (single_window_mode) |
1552 |
engines_page->pack_start(engine_name_entry, 0, 0, 0); |
engines_page->pack_start(engine_name_entry, 0, 0, 0); |
1553 |
engines_page->pack_start(GTK.Alignment(1.0, 0.0, 0.0, 0.0) |
engines_page->pack_start(GTK.Alignment(1.0, 0.0, 0.0, 0.0) |
1554 |
->add(new_engine_button), 0, 0, 0); |
->add(new_engine_button), 0, 0, 0) |
1555 |
|
->pack_start(new_testcase_entry, 0, 0, 0) |
1556 |
|
->pack_start(new_testcase_button, 0, 0, 0); |
1557 |
controller_notebook->append_page(engines_page->set_border_width(12), |
controller_notebook->append_page(engines_page->set_border_width(12), |
1558 |
GTK.Label("engines")); |
GTK.Label("engines")); |
1559 |
|
|
1803 |
else |
else |
1804 |
{ |
{ |
1805 |
c1 = sprintf("analyze_semeai %s %s", |
c1 = sprintf("analyze_semeai %s %s", |
1806 |
first_vertex, |
first_vertex, vertex); |
|
vertex); |
|
1807 |
c2 = sprintf("analyze_semeai %s %s", vertex, |
c2 = sprintf("analyze_semeai %s %s", vertex, |
1808 |
first_vertex); |
first_vertex); |
1809 |
// FIXME: We should use a semeai node counter rather |
// FIXME: We should use a semeai node counter rather |
1821 |
} |
} |
1822 |
} |
} |
1823 |
|
|
1824 |
|
|
1825 |
|
static void new_testcase() |
1826 |
|
{ |
1827 |
|
string new_testcase = new_testcase_entry->get_text(); |
1828 |
|
werror("Trying to load new testcase %s.", new_testcase); |
1829 |
|
if (!excerpt_testcase(new_testcase, viewers[0]->engine)) |
1830 |
|
{ |
1831 |
|
werror("Failed to load testcase.\n"); |
1832 |
|
return; |
1833 |
|
} |
1834 |
|
testcase_name = new_testcase; |
1835 |
|
main_window->set_title(testcase_name); |
1836 |
|
testcase_label->set_text(full_testcase * "\n"); |
1837 |
|
viewers->new_testcase(full_testcase, testcase_command); |
1838 |
|
viewers->handle_testcase(); |
1839 |
|
} |
1840 |
|
|
1841 |
|
|
1842 |
// The engine parameter is only needed to find out the color to |
// The engine parameter is only needed to find out the color to |
1843 |
// move when an sgf file is given. Since there can be multiple |
// move when an sgf file is given. Since there can be multiple |
1844 |
// viewers we shouldn't use this engine object for anything else |
// viewers we shouldn't use this engine object for anything else |