khetai 0.2.3 → 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: d169f4a004e24dd36c20cc0483e97089288c37d9a883102902e57ad90b9da52c
4
- data.tar.gz: 4220a784bde8231944b7cd856839f651c7b7d0491748e6597a1d6a94c58c468d
3
+ metadata.gz: c47fe1f761953801fa38ca71116b99e2a8aa96a67b0878a722674efdedbe3ca9
4
+ data.tar.gz: 9333855a0a63b63ec6a0e40dba571e2ef7423d496947c3344207468c86649135
5
5
  SHA512:
6
- metadata.gz: 74a55ef185db9d73c58e9e148a3e124f5850da6304be611d7466d8951e43b6d3165e9fbf5ae98654c12861a49e3281bf6a299f03f0b55e9d63ee51c6b76d2793
7
- data.tar.gz: 6409ac627699d0daa5a7cacb4ce1da174be6f433228466b7cd0ffd04e7c47d9830f11de41e629313b38b776dd7a41647aa82e405f49dc18d69e03f23a14a8f65
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.3)
4
+ khetai (0.3.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,98 +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_reset_undo())()
56
- {
44
+ void (*AILoader::get_reset_undo())() {
57
45
  return reinterpret_cast<void (*)()>(get_symbol("reset_undo"));
58
46
  }
59
47
 
60
- void (*AILoader::get_setup_board())(char **)
61
- {
48
+ void (*AILoader::get_setup_board())(char **) {
62
49
  return reinterpret_cast<void (*)(char **)>(get_symbol("setup_board"));
63
50
  }
64
51
 
65
- void (*AILoader::get_print_board())()
66
- {
52
+ void (*AILoader::get_print_board())() {
67
53
  return reinterpret_cast<void (*)()>(get_symbol("print_board"));
68
54
  }
69
55
 
70
- void (*AILoader::get_set_time_parameters())(int, time_t)
71
- {
56
+ void (*AILoader::get_set_time_parameters())(int, time_t) {
72
57
  return reinterpret_cast<void (*)(int, time_t)>(get_symbol("set_time_parameters"));
73
58
  }
74
59
 
75
- Move (*AILoader::get_alphabeta_root())(int, enum Player)
76
- {
60
+ Move (*AILoader::get_alphabeta_root())(int, enum Player) {
77
61
  return reinterpret_cast<Move (*)(int, enum Player)>(get_symbol("alphabeta_root"));
78
62
  }
79
63
 
80
- void (*AILoader::get_make_move())(Move)
81
- {
64
+ void (*AILoader::get_make_move())(Move) {
82
65
  return reinterpret_cast<void (*)(Move)>(get_symbol("make_move"));
83
66
  }
84
67
 
85
- int (*AILoader::get_get_start())(Move)
86
- {
68
+ int (*AILoader::get_get_start())(Move) {
87
69
  return reinterpret_cast<int (*)(Move)>(get_symbol("get_start_wrapper"));
88
70
  }
89
71
 
90
- int (*AILoader::get_get_end())(Move)
91
- {
72
+ int (*AILoader::get_get_end())(Move) {
92
73
  return reinterpret_cast<int (*)(Move)>(get_symbol("get_end_wrapper"));
93
74
  }
94
75
 
95
- int (*AILoader::get_get_rotation())(Move)
96
- {
76
+ int (*AILoader::get_get_rotation())(Move) {
97
77
  return reinterpret_cast<int (*)(Move)>(get_symbol("get_rotation_wrapper"));
98
78
  }
@@ -1,14 +1,13 @@
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
 
@@ -24,7 +23,7 @@ public:
24
23
  int (*get_get_rotation())(Move);
25
24
  void reload_library(const std::string &lib_path);
26
25
 
27
- private:
26
+ private:
28
27
  void *handle;
29
28
  void load_library(const std::string &lib_path);
30
29
  void *get_symbol(const std::string &symbol_name);