twisty_puzzles 0.0.23 → 0.0.27

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: 38464f2fe484f8bf9336b02fd487750afd507060ad308f43fc7f6f77d4fdd009
4
- data.tar.gz: 7934ea73bdbc8aa54bbc342693ab2118ca927f5ac5f4e4af2e63d0f1669c7eda
3
+ metadata.gz: 50d977c5e137d9396e79e1cf39f6143e99b457549c0cd518ada8b2c4a35c428c
4
+ data.tar.gz: f092b98630606b231ecb60c6020cd6528225d9e5771229147973afe4b3312b43
5
5
  SHA512:
6
- metadata.gz: 84c639c1b0d861543494f12256212a17d758e37fc2ef4099dd894a50d545c566d5c172ee839bcbb25ad1d5a76911003e93c4aaf7f1180ca4d61497ecd546c46e
7
- data.tar.gz: 21eccbfb1040243dddaf036fa43d2b8ef54a020a23df3470dc7c18bc7ee44f404fe8df633293c80445d377db13e62d12b60305184a5b985b0e691b17d0f6da05
6
+ metadata.gz: 210297dea0bf79343a405e3d3a0f8a7c7f7bc0c680302ad25535aaefcbea3fd7e4c84e0ea6a9bc05c76e45e897d9f1a69c1199d2b4aae0e5e291c2d000e80fa2
7
+ data.tar.gz: 104110df13cf554e59e9c32cad74452869a0aa628565898df000e416eaf4ebf38b02d2df39f58dc2a508148d1f42fdbd59e08d9ff37859bce7a589efd3389fb5
@@ -4,7 +4,7 @@ module TwistyPuzzles
4
4
  # Base class for directions.
5
5
  class AbstractDirection
6
6
  include Comparable
7
- POSSIBLE_DIRECTION_NAMES = [[''], ['2', '2\''], ['\'', '3', '’']].freeze
7
+ POSSIBLE_DIRECTION_NAMES = [[''], ['2', '2\''], ['\'', '3', '’', '‘', '´', '`']].freeze
8
8
  SIMPLE_DIRECTION_NAMES = (['0'] + POSSIBLE_DIRECTION_NAMES.map(&:first)).freeze
9
9
  POSSIBLE_SKEWB_DIRECTION_NAMES = [['', '2\''], ['\'', '2']].freeze
10
10
  SIMPLE_SKEWB_DIRECTION_NAMES = (['0'] + POSSIBLE_SKEWB_DIRECTION_NAMES.map(&:first)).freeze
@@ -20,7 +20,9 @@ module TwistyPuzzles
20
20
  @moves = moves
21
21
  end
22
22
 
23
- EMPTY = Algorithm.new([])
23
+ def self.empty
24
+ Algorithm.new([])
25
+ end
24
26
 
25
27
  # Creates a one move algorithm.
26
28
  def self.move(move)
@@ -43,7 +43,7 @@ module TwistyPuzzles
43
43
  raise TypeError unless algorithm.is_a?(Algorithm)
44
44
 
45
45
  CubeState.check_cube_size(cube_size)
46
- alg = Algorithm::EMPTY
46
+ alg = Algorithm.empty
47
47
  algorithm.moves.each do |m|
48
48
  alg = push_with_cancellation(alg, m, cube_size)
49
49
  end
@@ -107,7 +107,7 @@ module TwistyPuzzles
107
107
  def self.rotation_sequences
108
108
  @rotation_sequences ||=
109
109
  begin
110
- trivial_rotation_algs = [Algorithm::EMPTY]
110
+ trivial_rotation_algs = [Algorithm.empty]
111
111
  single_rotation_algs = Rotation::NON_ZERO_ROTATIONS.map { |e| Algorithm.move(e) }
112
112
  combined_rotation_algs = self.combined_rotation_algs
113
113
  rotation_algs = trivial_rotation_algs + single_rotation_algs + combined_rotation_algs
@@ -57,7 +57,7 @@ module TwistyPuzzles
57
57
  end
58
58
 
59
59
  def colors
60
- @face_symbols_to_colors.values
60
+ @face_symbols_to_colors.to_a.sort_by(&:first).map(&:last)
61
61
  end
62
62
 
63
63
  def turned(top_color, front_color)
@@ -173,6 +173,10 @@ module TwistyPuzzles
173
173
  @native = native
174
174
  end
175
175
 
176
+ def to_s
177
+ "#{self.class}(#{face}, #{cube_size}, #{x}, #{y})"
178
+ end
179
+
176
180
  attr_reader :native
177
181
 
178
182
  def face
@@ -72,6 +72,11 @@ module TwistyPuzzles
72
72
  true
73
73
  end
74
74
 
75
+ def self.exists_on_cube_size?(cube_size)
76
+ cube_size >= min_cube_size && cube_size <= max_cube_size &&
77
+ (cube_size % 2 == 0 ? self.exists_on_even_cube_sizes? : self.exists_on_odd_cube_sizes?)
78
+ end
79
+
75
80
  def num_incarnations(_cube_size)
76
81
  1
77
82
  end
@@ -286,7 +291,7 @@ module TwistyPuzzles
286
291
  # lie where the given other face currently is.
287
292
  def rotation_to(other)
288
293
  if other == self
289
- Algorithm::EMPTY
294
+ Algorithm.empty
290
295
  else
291
296
  # There can be multiple solutions.
292
297
  axis_face =
@@ -470,7 +475,6 @@ module TwistyPuzzles
470
475
  # Represents one wing or the position of one wing on the cube.
471
476
  class Wing < Part
472
477
  extend EdgeLike
473
- WING_BASE_INDEX_INVERTED_FACE_SYMBOLS = %i[U R B].freeze
474
478
  FACES = 2
475
479
 
476
480
  ELEMENTS = generate_parts
@@ -479,10 +483,6 @@ module TwistyPuzzles
479
483
  4
480
484
  end
481
485
 
482
- def self.exists_on_odd_cube_sizes?
483
- false
484
- end
485
-
486
486
  def self.max_parseable_face_symbols
487
487
  FACES + 1
488
488
  end
@@ -543,8 +543,7 @@ module TwistyPuzzles
543
543
 
544
544
  # One index of such a piece on a on a NxN face.
545
545
  def base_index_on_other_face(face, _cube_size, incarnation_index)
546
- # TODO: Make this more elegant than hardcoding
547
- inverse = WING_BASE_INDEX_INVERTED_FACE_SYMBOLS.include?(face.face_symbol)
546
+ inverse = face.piece_index.even?
548
547
  coordinates = [0, 1 + incarnation_index]
549
548
  inverse ? coordinates.reverse : coordinates
550
549
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'twisty_puzzles/utils/array_helper'
4
+ require 'twisty_puzzles/utils/string_helper'
4
5
  require 'twisty_puzzles/sticker_cycle_factory'
5
6
  require 'twisty_puzzles/cube'
6
7
 
@@ -11,6 +12,8 @@ module TwistyPuzzles
11
12
  # Check StickerCycleFactory for making it concrete and applyable.
12
13
  class PartCycle
13
14
  include Utils::ArrayHelper
15
+ include Utils::StringHelper
16
+ extend Utils::StringHelper
14
17
 
15
18
  RAW_DATA_RESERVED = [' ', '(', ')'].freeze
16
19
 
@@ -48,7 +51,7 @@ module TwistyPuzzles
48
51
  end
49
52
 
50
53
  def to_raw_data
51
- "#{part_type}(#{self})"
54
+ "#{simple_class_name(part_type)}(#{self})"
52
55
  end
53
56
 
54
57
  def length
@@ -86,7 +89,7 @@ module TwistyPuzzles
86
89
 
87
90
  def self.from_raw_data(data)
88
91
  raw_part_type, raw_parts = data.match(/(.*)\((.*)\)/).captures
89
- part_type = PART_TYPES.find { |p| p.name == raw_part_type }
92
+ part_type = PART_TYPES.find { |p| simple_class_name(p) == raw_part_type }
90
93
  parts = raw_parts.split.map { |r| part_type.parse(r) }
91
94
  new(parts)
92
95
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TwistyPuzzles
4
- VERSION = '0.0.23'
4
+ VERSION = '0.0.27'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twisty_puzzles
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.23
4
+ version: 0.0.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernhard F. Brodowsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-09 00:00:00.000000000 Z
11
+ date: 2021-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize