khetai 0.3.3 → 0.3.4

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: 947bf0b2701da92a96a4fd24d29740cbfa460614f71cfe927754ba37840aab1d
4
- data.tar.gz: 56a86968143c90e83cb1996a0aa86bf81e3e7f876aec8b077b361d35a7fab7fd
3
+ metadata.gz: b0de4779baa3060126c239bcb22e4ed4cff09168f223d282b4653ee0b48a49c0
4
+ data.tar.gz: add3d7364b84a82e2268b2ae2e17ee3169a63e1191f7bbfefe036ffb9b727a64
5
5
  SHA512:
6
- metadata.gz: c9bccf13dbbedce74f0a860a7fb0f09604caad0dc2fd395fe4fdd2484e7cd63f48c96ccaab076aeb1f0a6c75e3ca984dd85cf1973a8b348a949e8ba690c1af71
7
- data.tar.gz: 7efc3618179af126593559ea32a7086f13e02c9ed8aaa509d01b8886f8eb12661e18ff0eb235754e609eacc161fb2a462a4e5162e877ba9b52c253f82104f6fb
6
+ metadata.gz: adeeb8e3bd8605661ad1a3a7a58cdcae7728bafc6c1fb329f4ba602600e103c25adcfbfbdbfc29390a28272df04d4f15a92ea84c55034c5b1ed77e7b0d103249
7
+ data.tar.gz: 184800f1ddfc7db6d7366a29e611e8edf8149177423ce9236ee685b6ed7aa6c3b6ecb1faffd520d6da6a68041daee91c34b00d5800cefd63f1a23e50b7f9437e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- khetai (0.3.3)
4
+ khetai (0.3.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -211,31 +211,32 @@ void make_move(Move move) {
211
211
  if (is_piece(board[end]))
212
212
  hash ^= keys[board[end]][end];
213
213
 
214
- Square moving_piece = board[start];
215
- board[start] = board[end];
216
- board[end] = moving_piece;
214
+ Square starting_square = board[start];
215
+ Square ending_square = board[end];
216
+ board[start] = ending_square;
217
+ board[end] = starting_square;
218
+
217
219
  // add starting piece to end location
218
- hash ^= keys[board[end]][end];
220
+ hash ^= keys[starting_square][end];
219
221
 
220
- // add ending piece to start location if swapping
221
- if (is_piece(board[start])) {
222
- hash ^= keys[board[start]][start];
222
+ enum Player moving_player = get_owner(starting_square);
223
+ if (!is_piece(ending_square)) {
224
+ update_piece_tracker(moving_player, start, end, false);
225
+ } else {
226
+ // add ending piece to start location if swapping
227
+ hash ^= keys[ending_square][start];
223
228
 
224
- enum Player other_player = get_owner(board[start]);
225
- if (get_owner(moving_piece) == other_player)
229
+ enum Player other_player = get_owner(ending_square);
230
+ if (get_owner(starting_square) == other_player)
226
231
  update_piece_tracker(other_player, end, start, true);
227
232
  else {
228
- update_piece_tracker(moving_piece, start, end, false);
233
+ update_piece_tracker(moving_player, start, end, false);
229
234
  update_piece_tracker(other_player, end, start, false);
230
235
  }
231
-
232
- } else {
233
- enum Player moving_player = get_owner(moving_piece);
234
- update_piece_tracker(moving_player, start, end, false);
235
236
  }
236
237
 
237
- if (get_piece(moving_piece) == PHARAOH)
238
- pharaoh_loc[get_owner(moving_piece)] = end;
238
+ if (get_piece(starting_square) == PHARAOH)
239
+ pharaoh_loc[get_owner(starting_square)] = end;
239
240
  }
240
241
 
241
242
  undo_moves[undo_index] = new_move(end, start, -rotation);
@@ -311,26 +312,27 @@ void undo_move() {
311
312
  if (rotation != 0) {
312
313
  board[start] = rotate(board[start], rotation);
313
314
  } else {
314
- Square moving_piece = board[start];
315
- board[start] = board[end];
316
- board[end] = moving_piece;
315
+ Square starting_square = board[start];
316
+ Square ending_square = board[end];
317
+ board[start] = ending_square;
318
+ board[end] = starting_square;
317
319
 
318
- if (board[start] != 0) {
319
- enum Player other_player = get_owner(board[start]);
320
+ enum Player moving_player = get_owner(starting_square);
321
+ if (ending_square == 0) {
322
+ update_piece_tracker(moving_player, start, end, false);
323
+ } else {
324
+ enum Player other_player = get_owner(ending_square);
320
325
 
321
- if (get_owner(moving_piece) == other_player)
326
+ if (get_owner(starting_square) == other_player)
322
327
  update_piece_tracker(other_player, end, start, true);
323
328
  else {
324
- update_piece_tracker(moving_piece, start, end, false);
329
+ update_piece_tracker(moving_player, start, end, false);
325
330
  update_piece_tracker(other_player, end, start, false);
326
331
  }
327
- } else {
328
- enum Player moving_player = get_owner(moving_piece);
329
- update_piece_tracker(moving_player, start, end, false);
330
332
  }
331
333
 
332
- if (get_piece(moving_piece) == PHARAOH)
333
- pharaoh_loc[get_owner(moving_piece)] = end;
334
+ if (get_piece(starting_square) == PHARAOH)
335
+ pharaoh_loc[get_owner(starting_square)] = end;
334
336
  }
335
337
  checkmate = false;
336
338
  }
@@ -1,3 +1,3 @@
1
1
  module KhetAI
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: khetai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - jkugs