khetai 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 152a53d7588c5ecc8b763bf457852092ddebc3b10b2de158aa25695b1ce8436e
4
- data.tar.gz: 59de4c1797063aa6d952cdc3c954b093e63a5ad874c605d891532da32fb7cd77
3
+ metadata.gz: c47fe1f761953801fa38ca71116b99e2a8aa96a67b0878a722674efdedbe3ca9
4
+ data.tar.gz: 9333855a0a63b63ec6a0e40dba571e2ef7423d496947c3344207468c86649135
5
5
  SHA512:
6
- metadata.gz: a59d6d2ee6d67b3938e9fe2caa8270094dbd88f2a36efbef9c70824da7684b61baca3b64ece435d659b2c83e54940c644b67acfd1efbcbdfef2a0d32355a36c1
7
- data.tar.gz: b92b7efea628fc6cc072b9ff74dfd3a9156c6ef1a9bec5fcc1e86d801254e1fd445d914f00c43399afa3b1ab4e3190dd435703c7798e811ad3645831cc06f059
6
+ metadata.gz: 3b54d3fcb018ab5ce843203e9abe4ad850ebf89aae61e47677f3f13bf3911a3f9b405aa76794ab61f62cbecf8db6c7b991ab282e8565452499106696b3f3cdce
7
+ data.tar.gz: 23bbe28c2875f9c7a8344e6c441554cabfa3ce4a0728a79941761169f9e36d97aaff4ac81354577a5696c7bd6908e14c5924af6c85a1eb7de2a2823c86f7ec7d
data/.clang-format ADDED
@@ -0,0 +1,14 @@
1
+ BasedOnStyle: LLVM
2
+ IndentWidth: 4
3
+ BraceWrapping:
4
+ AfterClass: false
5
+ AfterControlStatement: false
6
+ AfterEnum: false
7
+ AfterFunction: false
8
+ AfterNamespace: false
9
+ AfterStruct: false
10
+ AfterUnion: false
11
+ BeforeCatch: false
12
+ BeforeElse: false
13
+ IndentBraces: false
14
+ ColumnLimit: 0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- khetai (0.2.2)
4
+ khetai (0.3.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -51,16 +51,19 @@ The internals of the gem are written in C, located in `ext/khetai`.
51
51
  $ bundle exec rake build
52
52
  $ gem install pkg/khetai-<version>.gem
53
53
 
54
- Once tested and verified, bump the version number in `lib/khetai/version.rb`
54
+ Once tested and verified, bump the version number in `lib/khetai/version.rb` and commit changes.
55
55
 
56
56
  To release and push to rubygems.org:
57
57
 
58
58
  $ bundle exec rake release
59
+
60
+ To push a pre-built gem manually:
61
+
59
62
  $ gem push pkg/<gem>
60
63
 
61
64
  ## Manual Testing
62
65
 
63
- There is a GUI test harness written in C++ using FLTK available in the `ext/khetai/dev/fltk-ui` directory.
66
+ There is a GUI test harness written in C++ using FLTK available in the [ext/khetai/dev/fltk-ui](/ext/khetai/dev/fltk-ui) directory.
64
67
 
65
68
  ### Why does this exist?
66
69
 
@@ -1,93 +1,78 @@
1
1
  #include "ai_loader.h"
2
2
 
3
- AILoader::AILoader(const std::string &lib_path) : handle(nullptr)
4
- {
3
+ AILoader::AILoader(const std::string &lib_path) : handle(nullptr) {
5
4
  load_library(lib_path);
6
5
  }
7
6
 
8
- AILoader::~AILoader()
9
- {
10
- if (handle)
11
- {
7
+ AILoader::~AILoader() {
8
+ if (handle) {
12
9
  dlclose(handle);
13
10
  }
14
11
  }
15
12
 
16
- void AILoader::load_library(const std::string &lib_path)
17
- {
13
+ void AILoader::load_library(const std::string &lib_path) {
18
14
  handle = dlopen(lib_path.c_str(), RTLD_LAZY);
19
- if (!handle)
20
- {
15
+ if (!handle) {
21
16
  throw std::runtime_error("Failed to load KhetAI: " + std::string(dlerror()));
22
17
  }
23
18
  }
24
19
 
25
- void AILoader::reload_library(const std::string &lib_path)
26
- {
27
- if (handle)
28
- {
20
+ void AILoader::reload_library(const std::string &lib_path) {
21
+ if (handle) {
29
22
  dlclose(handle);
30
23
  }
31
24
  load_library(lib_path);
32
25
  }
33
26
 
34
- void *AILoader::get_symbol(const std::string &symbol_name)
35
- {
27
+ void *AILoader::get_symbol(const std::string &symbol_name) {
36
28
  void *symbol = dlsym(handle, symbol_name.c_str());
37
29
  check_error();
38
30
  return symbol;
39
31
  }
40
32
 
41
- void AILoader::check_error()
42
- {
33
+ void AILoader::check_error() {
43
34
  const char *error = dlerror();
44
- if (error)
45
- {
35
+ if (error) {
46
36
  throw std::runtime_error("Error in dynamic loading: " + std::string(error));
47
37
  }
48
38
  }
49
39
 
50
- void (*AILoader::get_init_zobrist())()
51
- {
40
+ void (*AILoader::get_init_zobrist())() {
52
41
  return reinterpret_cast<void (*)()>(get_symbol("init_zobrist"));
53
42
  }
54
43
 
55
- void (*AILoader::get_setup_board())(char **)
56
- {
44
+ void (*AILoader::get_reset_undo())() {
45
+ return reinterpret_cast<void (*)()>(get_symbol("reset_undo"));
46
+ }
47
+
48
+ void (*AILoader::get_setup_board())(char **) {
57
49
  return reinterpret_cast<void (*)(char **)>(get_symbol("setup_board"));
58
50
  }
59
51
 
60
- void (*AILoader::get_print_board())()
61
- {
52
+ void (*AILoader::get_print_board())() {
62
53
  return reinterpret_cast<void (*)()>(get_symbol("print_board"));
63
54
  }
64
55
 
65
- void (*AILoader::get_set_time_parameters())(int, time_t)
66
- {
56
+ void (*AILoader::get_set_time_parameters())(int, time_t) {
67
57
  return reinterpret_cast<void (*)(int, time_t)>(get_symbol("set_time_parameters"));
68
58
  }
69
59
 
70
- Move (*AILoader::get_alphabeta_root())(int, enum Player)
71
- {
60
+ Move (*AILoader::get_alphabeta_root())(int, enum Player) {
72
61
  return reinterpret_cast<Move (*)(int, enum Player)>(get_symbol("alphabeta_root"));
73
62
  }
74
63
 
75
- void (*AILoader::get_make_move())(Move)
76
- {
64
+ void (*AILoader::get_make_move())(Move) {
77
65
  return reinterpret_cast<void (*)(Move)>(get_symbol("make_move"));
78
66
  }
79
67
 
80
- int (*AILoader::get_get_start())(Move)
81
- {
68
+ int (*AILoader::get_get_start())(Move) {
82
69
  return reinterpret_cast<int (*)(Move)>(get_symbol("get_start_wrapper"));
83
70
  }
84
71
 
85
- int (*AILoader::get_get_end())(Move)
86
- {
72
+ int (*AILoader::get_get_end())(Move) {
87
73
  return reinterpret_cast<int (*)(Move)>(get_symbol("get_end_wrapper"));
88
74
  }
89
75
 
90
- int (*AILoader::get_get_rotation())(Move)
91
- {
76
+ int (*AILoader::get_get_rotation())(Move) {
92
77
  return reinterpret_cast<int (*)(Move)>(get_symbol("get_rotation_wrapper"));
93
78
  }
@@ -1,18 +1,18 @@
1
1
  #ifndef AI_LOADER_H
2
2
  #define AI_LOADER_H
3
3
 
4
+ #include "../../khetai_lib.h"
4
5
  #include <dlfcn.h>
5
6
  #include <stdexcept>
6
7
  #include <string>
7
- #include "../../khetai_lib.h"
8
8
 
9
- class AILoader
10
- {
11
- public:
9
+ class AILoader {
10
+ public:
12
11
  AILoader(const std::string &lib_path);
13
12
  ~AILoader();
14
13
 
15
14
  void (*get_init_zobrist())();
15
+ void (*get_reset_undo())();
16
16
  void (*get_setup_board())(char **);
17
17
  void (*get_print_board())();
18
18
  void (*get_set_time_parameters())(int, time_t);
@@ -23,7 +23,7 @@ public:
23
23
  int (*get_get_rotation())(Move);
24
24
  void reload_library(const std::string &lib_path);
25
25
 
26
- private:
26
+ private:
27
27
  void *handle;
28
28
  void load_library(const std::string &lib_path);
29
29
  void *get_symbol(const std::string &symbol_name);