| 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ |
| 2 | * This is GNU Go, a Go program. Contact gnugo@gnu.org, or see * |
| 3 | * http://www.gnu.org/software/gnugo/ for more information. * |
| 4 | * * |
| 5 | * Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, * |
| 6 | * 2008 and 2009 by the Free Software Foundation. * |
| 7 | * * |
| 8 | * This program is free software; you can redistribute it and/or * |
| 9 | * modify it under the terms of the GNU General Public License as * |
| 10 | * published by the Free Software Foundation - version 3 or * |
| 11 | * (at your option) any later version. * |
| 12 | * * |
| 13 | * This program is distributed in the hope that it will be useful, * |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 16 | * GNU General Public License in file COPYING for more details. * |
| 17 | * * |
| 18 | * You should have received a copy of the GNU General Public * |
| 19 | * License along with this program; if not, write to the Free * |
| 20 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * |
| 21 | * Boston, MA 02111, USA. * |
| 22 | \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
| 23 | |
| 24 | #ifndef _GG_UTILS_H_ |
| 25 | #define _GG_UTILS_H_ |
| 26 | |
| 27 | #include <stdarg.h> |
| 28 | |
| 29 | #ifdef HAVE_CONFIG_H |
| 30 | #include <config.h> |
| 31 | #endif |
| 32 | |
| 33 | #if TIME_WITH_SYS_TIME |
| 34 | # include <sys/time.h> |
| 35 | # include <time.h> |
| 36 | #else |
| 37 | # if HAVE_SYS_TIME_H |
| 38 | # include <sys/time.h> |
| 39 | # else |
| 40 | # include <time.h> |
| 41 | # endif |
| 42 | #endif |
| 43 | |
| 44 | #ifdef __MINGW32__ |
| 45 | #include <windows.h> |
| 46 | #include <winsock.h> |
| 47 | #include <io.h> |
| 48 | #endif |
| 49 | |
| 50 | #ifdef HAVE_WINSOCK_IO_H |
| 51 | #include <winsock.h> |
| 52 | #include <io.h> |
| 53 | #endif |
| 54 | |
| 55 | void gg_init_color(void); |
| 56 | void write_color_char(int c, int x); |
| 57 | void write_color_string(int c, const char *str); |
| 58 | |
| 59 | void gg_vsnprintf(char *dest, unsigned long len, const char *fmt, |
| 60 | va_list args); |
| 61 | void gg_snprintf(char *dest, unsigned long len, const char *fmt, ...); |
| 62 | |
| 63 | double gg_gettimeofday(void); |
| 64 | double gg_cputime(void); |
| 65 | |
| 66 | float gg_normalize_float(float x, float a); |
| 67 | int gg_normalize_float2int(float x, float a); |
| 68 | void gg_sort(void *base, size_t nel, size_t width, |
| 69 | int (*compar)(const void *, const void *)); |
| 70 | |
| 71 | #define MAX_INTERPOLATION_STEPS 20 |
| 72 | struct interpolation_data |
| 73 | { |
| 74 | int sections; |
| 75 | float range_lowerbound; |
| 76 | float range_upperbound; |
| 77 | float values[MAX_INTERPOLATION_STEPS + 1]; |
| 78 | }; |
| 79 | |
| 80 | float gg_interpolate(struct interpolation_data *f, float x); |
| 81 | float soft_cap(float a, float b); |
| 82 | |
| 83 | const char *gg_version(void); |
| 84 | |
| 85 | /* prototypes for basic reorientation functions */ |
| 86 | |
| 87 | void rotate(int i, int j, int *ri, int *rj, int bs, int rot); |
| 88 | void inv_rotate(int i, int j, int *ri, int *rj, int bs, int rot); |
| 89 | |
| 90 | void update_random_seed(void); |
| 91 | void set_random_seed(unsigned int seed); |
| 92 | unsigned int get_random_seed(void); |
| 93 | void reuse_random_seed(void); |
| 94 | |
| 95 | |
| 96 | #endif /* _GG_UTILS_H_ */ |
| 97 | |
| 98 | |
| 99 | /* |
| 100 | * Local Variables: |
| 101 | * tab-width: 8 |
| 102 | * c-basic-offset: 2 |
| 103 | * End: |
| 104 | */ |