qi 10.0.0.beta8 → 10.0.0.beta9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/qi.rb +19 -6
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 816f97762efb0e9f7a603b93b5703b4b68c6a4629f438f39ed49d09227b9650a
4
- data.tar.gz: 1c90d60785447ff965ef92816ed58e7a0d315ffb9b104c185c76d4d1da461435
3
+ metadata.gz: 807fc7b14621e81663ea476f2d737352d455d4d2ab1d49efbe722c3ce571ed15
4
+ data.tar.gz: 9244deacf36f2717897a23b56de132af40ce308cd5977ee92899f57c49368f0e
5
5
  SHA512:
6
- metadata.gz: '0906bf4de292b88d43e88241a8690753ca6776320de3070a5f575eb44070913a68807dbf25e9836a46c0361e43fdd6cbe5f869c558695828174f7dbc548934b0'
7
- data.tar.gz: 495dd33b36e4141be5d79e989b54c735f7e86edd52b323780448f19ba16530b125564ccfb3ac9d0a668c3d841d03c889a733e5775d52f2cf210ed7d0448d719b
6
+ metadata.gz: 87cedbb94ddcecb3026647893aac63ce6559c92d37dc65121850efca0eb1ddd7a1616e441a0c40463a2bbe664de59d4498bbcfcfd3aa3caae6075a65851c57c5
7
+ data.tar.gz: 62a213dcaeb4d68cc6c4bc01b4d9b4a2df33b3d8bcca09c5e494e6a5b0eb349b236907437caa12c11777c6eaac559402e927f3db972f89acb4cd07f77408c4d9
data/README.md CHANGED
@@ -13,7 +13,7 @@
13
13
  Add this line to your application's Gemfile:
14
14
 
15
15
  ```ruby
16
- gem "qi", ">= 10.0.0.beta8"
16
+ gem "qi", ">= 10.0.0.beta9"
17
17
  ```
18
18
 
19
19
  And then execute:
data/lib/qi.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "digest"
3
4
  require_relative "qi/error/drop"
4
5
 
5
6
  # A class that represents the state of a game.
@@ -41,13 +42,12 @@ class Qi
41
42
  self.class.new(!north_turn?, *modified_captures, modified_squares)
42
43
  end
43
44
 
44
- def side_name
45
- if north_turn?
46
- "north"
47
- else
48
- "south"
49
- end
45
+ def eql?(other)
46
+ return false unless other.respond_to?(:serialize)
47
+
48
+ other.serialize == serialize
50
49
  end
50
+ alias == eql?
51
51
 
52
52
  def other_captures
53
53
  if north_turn?
@@ -65,6 +65,14 @@ class Qi
65
65
  end
66
66
  end
67
67
 
68
+ def side_name
69
+ if north_turn?
70
+ "north"
71
+ else
72
+ "south"
73
+ end
74
+ end
75
+
68
76
  # Checks if it is the north turn or not.
69
77
  #
70
78
  # @return [Boolean] true if it is the north turn and false otherwise
@@ -111,6 +119,11 @@ class Qi
111
119
  }
112
120
  end
113
121
 
122
+ # Returns the hash-code for the position.
123
+ def hash
124
+ ::Digest::SHA256.hexdigest(serialize)
125
+ end
126
+
114
127
  # Returns a string representation of the Qi object's attributes.
115
128
  #
116
129
  # @return [String] a string containing three parts separated by "===":
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qi
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.0.0.beta8
4
+ version: 10.0.0.beta9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril Kato