khetai 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 57b893b2ca7a9ab8690ce116801bbd6286bc5856c7f87d01b7d51a7bbd6cc8f9
4
- data.tar.gz: 433c4c67445b585526e598f6c04c53ca9e3ce67dab012a65aafa9922d18d8a80
3
+ metadata.gz: 9a457af540807b38fdb38ab47052c7b8b7b1133d5ffe8970a6390ccf7aace592
4
+ data.tar.gz: 3cdb7b43ac5644d6e8739ff1c2f0f126b2a597a9c72602dc9e692cd3e09dae70
5
5
  SHA512:
6
- metadata.gz: 5e85bedabf5229ac1abad59889e2d2980e0fe194ad42d3acff67fb72817ed6755b59798af3a7312836cc225bb044f1bc12641edb30f4693e37e91144581ac142
7
- data.tar.gz: f7cb8d7735f580752ed50ca8f4cf084a5398bbac70d26b32da6c9a61049de9a79b68aceac685afe5a907ec8bea83ba24e72fcf3c991a88145996c5a8563b85e3
6
+ metadata.gz: 5234eec49f64360cb846b61fd5754e9faa5f2a8e343e876e9f9be86c7c04efda27e629309308c76417f1d4e6aacd4d889dc87fac9bfc5b61416895714c0024a2
7
+ data.tar.gz: e81fff6aff170e53cd62e3d8ef2e8783bf8f297faff6a6d66c5a001953f7276aa96c01919ee82ce24d51f4136e7e96d98e500ebe7d33ce5b0778be1b9b13bd9f
data/.gitignore CHANGED
@@ -7,5 +7,10 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
  /build/
10
+ CMakeFiles/
11
+ cmake_install.cmake
12
+ CMakeCache.txt
13
+ /ext/khetai/dev/khetai
14
+ /ext/khetai/dev/Makefile
10
15
  .vscode
11
16
  *.so
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- khetai (0.1.7)
4
+ khetai (0.1.8)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -19,4 +19,4 @@ DEPENDENCIES
19
19
  rake-compiler
20
20
 
21
21
  BUNDLED WITH
22
- 2.1.2
22
+ 2.4.21
data/README.md CHANGED
@@ -1,18 +1,17 @@
1
1
  # KhetAI
2
2
 
3
- ## Install
4
- ```
5
- gem install khetai
6
- ```
3
+ ## Installation
4
+
5
+ $ gem install khetai
7
6
 
8
7
  ## Usage
9
- ```
8
+ ```ruby
10
9
  require 'khetai'
11
10
  move = KhetAI.move(board, whose_turn, max_search_depth, max_search_time)
12
11
  ```
13
12
 
14
13
  ## Example
15
- ```
14
+ ```ruby
16
15
  require 'khetai'
17
16
 
18
17
  # initial board setup:
@@ -42,11 +41,18 @@ move = KhetAI.move(board, whose_turn, max_search_depth, max_search_time)
42
41
  # move[2] = rotation (1, -1, 0) (clockwise, anticlockwise, none)
43
42
  ```
44
43
 
44
+ ## Development
45
+ The internals of the gem are written in C, located in `ext/khetai`.
46
+
47
+
45
48
  ## Build and Deploy Commands
46
- ```
47
- bundle exec rake compile
48
- bundle exec rake build
49
- bundle exec rake release
50
49
 
51
- gem push pkg/<gem>
52
- ```
50
+ $ bundle exec rake compile
51
+ $ bundle exec rake build
52
+ $ gem install pkg/khetai-<version>.gem
53
+
54
+
55
+ To release and push to rubygems.org:
56
+
57
+ $ bundle exec rake release
58
+ $ gem push pkg/<gem>
@@ -167,7 +167,7 @@ int calculate_score()
167
167
  value += rand() % 20;
168
168
  break;
169
169
  case Scarab:
170
- value += 100 / (distance_from_pharaoh(i, pharaoh_loc[opposite_player(get_owner(s))])) * 10;
170
+ value += (100 / distance_from_pharaoh(i, pharaoh_loc[opposite_player(get_owner(s))])) * 10;
171
171
  value += rand() % 10;
172
172
  break;
173
173
  case Pharaoh:
@@ -225,7 +225,7 @@ void make_move(Move move)
225
225
  hash ^= keys[board[start]][start];
226
226
 
227
227
  if (get_piece(moving_piece) == Pharaoh)
228
- pharaoh_loc[whose_turn] = end;
228
+ pharaoh_loc[get_owner(moving_piece)] = end;
229
229
  }
230
230
 
231
231
  undo_moves[undo_index] = new_move(end, start, -rotation);
@@ -314,7 +314,7 @@ void undo_move()
314
314
  board[end] = moving_piece;
315
315
 
316
316
  if (get_piece(moving_piece) == Pharaoh)
317
- pharaoh_loc[get_owner(board[end])] = end;
317
+ pharaoh_loc[get_owner(moving_piece)] = end;
318
318
  }
319
319
  checkmate = false;
320
320
  }
@@ -83,27 +83,27 @@ static const int on_board[120] = {
83
83
  0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
84
84
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
85
85
 
86
- extern void setup_board(char *init_board[120]);
87
- extern Square str_to_square(char *str);
88
- extern void print_board();
89
- extern void print_piece(Square s);
90
- extern void reset_undo();
91
-
92
- extern void find_valid_moves(Move *valid_moves, int *vi);
93
- extern void find_valid_anubis_pyramid_moves(int i, Move *valid_moves, int *vi);
94
- extern void find_valid_scarab_moves(int i, Move *valid_moves, int *vi);
95
- extern void find_valid_pharaoh_moves(int i, Move *valid_moves, int *vi);
96
- extern void find_valid_sphinx_moves(int i, Move *valid_moves, int *vi);
97
-
98
- extern Move alphabeta_root(int depth, enum Player player);
99
- extern int alphabeta(int depth, enum Player player, int alpha, int beta);
100
- extern int calculate_score();
101
- extern int distance_from_pharaoh(int i, int p);
102
-
103
- extern void make_move(Move move);
104
- extern void undo_move();
105
- extern void fire_laser(uint64_t *hash);
106
- extern bool is_move_legal(Move move);
86
+ void setup_board(char *init_board[120]);
87
+ Square str_to_square(char *str);
88
+ void print_board();
89
+ void print_piece(Square s);
90
+ void reset_undo();
91
+
92
+ void find_valid_moves(Move *valid_moves, int *vi);
93
+ void find_valid_anubis_pyramid_moves(int i, Move *valid_moves, int *vi);
94
+ void find_valid_scarab_moves(int i, Move *valid_moves, int *vi);
95
+ void find_valid_pharaoh_moves(int i, Move *valid_moves, int *vi);
96
+ void find_valid_sphinx_moves(int i, Move *valid_moves, int *vi);
97
+
98
+ Move alphabeta_root(int depth, enum Player player);
99
+ int alphabeta(int depth, enum Player player, int alpha, int beta);
100
+ int calculate_score();
101
+ int distance_from_pharaoh(int i, int p);
102
+
103
+ void make_move(Move move);
104
+ void undo_move();
105
+ void fire_laser(uint64_t *hash);
106
+ bool is_move_legal(Move move);
107
107
 
108
108
  static inline bool is_piece(Square s) { return s > 0; }
109
109
 
@@ -169,8 +169,8 @@ extern uint64_t turn_key;
169
169
  extern int move_num;
170
170
  extern bool checkmate;
171
171
 
172
- extern void init_zobrist();
173
- extern uint64_t get_board_hash();
172
+ void init_zobrist();
173
+ uint64_t get_board_hash();
174
174
  static uint64_t seed = 1070372;
175
175
  static inline uint64_t random_number()
176
176
  {
@@ -196,6 +196,6 @@ typedef struct HashEntry
196
196
 
197
197
  extern HashEntry table[TABLE_SIZE];
198
198
  static inline HashEntry *search_table(uint64_t key) { return &table[key % TABLE_SIZE]; };
199
- extern void insert_table(uint64_t key, int depth, int flag, int score, Move move);
199
+ void insert_table(uint64_t key, int depth, int flag, int score, Move move);
200
200
 
201
- #endif // KHET_LIB_H_INCLUDED extern uint64_t get_board_hash();
201
+ #endif // KHET_LIB_H_INCLUDED
@@ -1,3 +1,3 @@
1
1
  module KhetAI
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: khetai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - jkugs
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-05 00:00:00.000000000 Z
11
+ date: 2024-03-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -23,7 +23,6 @@ files:
23
23
  - Gemfile.lock
24
24
  - LICENSE.txt
25
25
  - README.md
26
- - README_ORIGINAL.md
27
26
  - Rakefile
28
27
  - bin/console
29
28
  - bin/setup
@@ -58,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
57
  - !ruby/object:Gem::Version
59
58
  version: '0'
60
59
  requirements: []
61
- rubygems_version: 3.1.2
60
+ rubygems_version: 3.4.10
62
61
  signing_key:
63
62
  specification_version: 4
64
63
  summary: Khet AI
data/README_ORIGINAL.md DELETED
@@ -1,40 +0,0 @@
1
- # Khetai
2
-
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/khetai`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'khetai'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle install
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install khetai
22
-
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
-
33
- ## Contributing
34
-
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/khetai.
36
-
37
-
38
- ## License
39
-
40
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).