Skip to content

Commit

Permalink
Version 1.26.1
Browse files Browse the repository at this point in the history
Add own twogtp implementation.
Small bug fixes to comments, log and SGF filenames, and compiler
warnings.
  • Loading branch information
gonmf committed Apr 16, 2023
1 parent 8ed3330 commit 6a84fb8
Show file tree
Hide file tree
Showing 36 changed files with 415 additions and 159 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2020 Gonçalo Mendes Ferreira
Copyright (c) Gonçalo Mendes Ferreira

Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
Expand Down
1 change: 1 addition & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ How to
You can play with Matilda out of the box using a text interface. For a graphical
interface you can connect it with any GTP-speaking program that supports Chinese
rules, like GoGui, available at http://gogui.sourceforge.net/.
Matilda also includes matilda-twogtp for self-play and benchmarking.


Copyright
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ src/inc/config.h to your taste.
You can play with Matilda out of the box using a text interface. For a graphical
interface you can connect it with any GTP-speaking program that supports Chinese
rules, like [GoGui](http://gogui.sourceforge.net/).
Matilda also includes `matilda-twogtp` for self-play and benchmarking.

**Copyright**

Expand Down
5 changes: 4 additions & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ OBJFILES := $(patsubst %.c,%.o,$(SRCFILES))
DEPFILES := $(patsubst %.o,%.d,$(OBJFILES))

PROGRAMS := matilda test gen_opening_book learn_best_plays learn_pat_weights \
gen_zobrist_table
gen_zobrist_table matilda-twogtp

.PHONY: $(PROGRAMS) clean

Expand All @@ -58,6 +58,9 @@ learn_pat_weights: $(OBJFILES) pat_weights/*.c
gen_zobrist_table: $(OBJFILES) zobrist/*.c
@$(CC) $^ $(CFLAGS) $(LDFLAGS) -o $@

matilda-twogtp: $(OBJFILES) twogtp/*.c
@$(CC) $^ $(CFLAGS) $(LDFLAGS) -o $@

%.o: %.c
@$(CC) -c -o $@ $< $(CFLAGS)

Expand Down
2 changes: 2 additions & 0 deletions src/README
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ patterns.
gen_zobrist_table - used to generate a vector of values suitable to be used as a
codification table for Zobrist hashing.

twogtp - used to pit one GTP-speaking program against another, for testing, benchmarking, etc.



Configuration
Expand Down
4 changes: 3 additions & 1 deletion src/dragon.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,9 @@ void estimate_eyes(
unite_dragons(gs[0], gs[i]);
}

dragon_head(gs[0])->eyes++;
if (gsc > 0) {
dragon_head(gs[0])->eyes++;
}

disqualify_square(play_okay, m);
in_nakade[m] = nk;
Expand Down
8 changes: 4 additions & 4 deletions src/file_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ int create_and_open_file(

while (1) {
if (attempt == 1) {
snprintf(filename, filename_size, "%s%s_%02u%02u%02u%02u%02u.%s", data_folder(), prefix,
tm.tm_year % 100, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, extension);
snprintf(filename, filename_size, "%s%s_%04u%02u%02u%02u%02u.%s", data_folder(), prefix,
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, extension);
} else {
snprintf(filename, filename_size, "%s%s_%02u%02u%02u%02u%02u_%u.%s", data_folder(), prefix,
tm.tm_year % 100, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, attempt, extension);
snprintf(filename, filename_size, "%s%s_%04u%02u%02u%02u%02u_%u.%s", data_folder(), prefix,
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, attempt, extension);
}

int fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
Expand Down
6 changes: 3 additions & 3 deletions src/flog.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
Support for logging to file. Logging is made to a file called
matilda_YYMMDD_XXXXXX.log where YYMMDD is the date and XXXXXX is a random
string. When logging a mask of log categories specifies the types of messages to
be written to file. Having a very high degree of detail in very fast matches
matilda_YYYYMMDDhhmm.log where YYYMMDD is the date and hhmm the hours and
minutes. When logging a mask of log categories specifies the types of messages
to be written to file. Having a very high degree of detail in very fast matches
actively hurts the performance.
Writing to files is synchronous (with fsync) to avoid loss of data in case of
Expand Down
2 changes: 1 addition & 1 deletion src/game_record.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void game_record_to_string(
gr->final_score > 0 ? gr->black_name : gr->white_name);
} else {
idx += snprintf(buf + idx, buf_siz - idx, "Winner: %s by %.1f points\n",
gr->final_score > 0 ? gr->black_name : gr->white_name, fabs(gr->final_score) / 2.0);
gr->final_score > 0 ? gr->black_name : gr->white_name, abs(gr->final_score) / 2.0);
}
}

Expand Down
8 changes: 3 additions & 5 deletions src/inc/flog.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
/*
Support for logging to file. Logging is made to a file called
matilda_YYMMDD_XXXXXX.log where YYMMDD is the date and XXXXXX is a random
string. When logging a mask of log categories specifies the types of messages to
be written to file. Having a very high degree of detail in very fast matches
matilda_YYYYMMDDhhmm.log where YYYMMDD is the date and hhmm the hours and
minutes. When logging a mask of log categories specifies the types of messages
to be written to file. Having a very high degree of detail in very fast matches
actively hurts the performance.
Writing to files is synchronous (with fsync) to avoid loss of data in case of
crashes, but it is impossible to guarantee this in all cases.
*/



#ifndef MATILDA_FLOG_H
#define MATILDA_FLOG_H

Expand Down
2 changes: 1 addition & 1 deletion src/inc/version.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#ifndef MATILDA_VERSION
#define MATILDA_VERSION "1.26.0"
#define MATILDA_VERSION "1.26.1"
#endif
1 change: 0 additions & 1 deletion src/pat_weights/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ The weights are 16-bit values that are later scaled by a factor of 1/9 so their
maximum total on a 3x3 neighborship fits 16 bits.
*/


#include "config.h"

#include <unistd.h>
Expand Down
4 changes: 2 additions & 2 deletions src/sgf.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,13 @@ bool import_game_from_sgf2(

str_between(tmp, buf, "PB[", "]");
if (tmp[0]) {
strncpy(gr->black_name, tmp, MAX_PLAYER_NAME_SIZ);
strncpy(gr->black_name, tmp, MAX_PLAYER_NAME_SIZ - 1);
gr->player_names_set = true;
}

str_between(tmp, buf, "PW[", "]");
if (tmp[0]) {
strncpy(gr->white_name, tmp, MAX_PLAYER_NAME_SIZ);
strncpy(gr->white_name, tmp, MAX_PLAYER_NAME_SIZ - 1);
gr->player_names_set = true;
}

Expand Down
4 changes: 4 additions & 0 deletions src/twogtp/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Simple "twogtp" implementation - a program that pits two GTP-speaking programs
against each other, using a third one as referee in case of game end by
consecutive draws.
Please see the example scritps in the root folder twogtp/ on how to use this.
Loading

0 comments on commit 6a84fb8

Please sign in to comment.