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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/qi.rb +19 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 807fc7b14621e81663ea476f2d737352d455d4d2ab1d49efbe722c3ce571ed15
|
4
|
+
data.tar.gz: 9244deacf36f2717897a23b56de132af40ce308cd5977ee92899f57c49368f0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87cedbb94ddcecb3026647893aac63ce6559c92d37dc65121850efca0eb1ddd7a1616e441a0c40463a2bbe664de59d4498bbcfcfd3aa3caae6075a65851c57c5
|
7
|
+
data.tar.gz: 62a213dcaeb4d68cc6c4bc01b4d9b4a2df33b3d8bcca09c5e494e6a5b0eb349b236907437caa12c11777c6eaac559402e927f3db972f89acb4cd07f77408c4d9
|
data/README.md
CHANGED
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
|
45
|
-
|
46
|
-
|
47
|
-
|
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 "===":
|