lib/combinatorial_puzzle_solver/solution_space.rb
# Resolves the given implications and the new implications they yield (including
# those resolved from constraints, if no implications are given) until no more
# identifiers can be resolved.
#
# If the solution space does not become {#resolved?} by this, it is necessary to
# {#resolve_by_trial_and_error!} to find a complete solution.
#
# If a block is given it will yield the solution space with the corresponding
# identifier and value before each time a resolution is made
# ({Possibilities#must_be!}), and it will abort unless the block returns true.
#
# @param implications [Hash<Identifier,Object>] a mapping between identifiers and
#                                               their assumed value.
# @yieldparam solution_space [SolutionSpace] the solution space in the state
#                                            right before a resolution is made.
# @yieldparam identifier [Identifier] an identifier that is resolved.
# @yieldparam value [Object] the value the identifier is resolved to.
# @yieldreturn [true,nil] the resolution will abort unless the block returns true
#                         for each identifier that is resolved.
# @return [true,false] true if the solution space became completely resolved.
# @raise [Inconsistency] if the solution space becomes inconsistent without any
#                         possible solution.
Resolves the given implications and the new implications they yield (including
those resolved from constraints, if no implications are given) until no more
identifiers can be resolved.

If the solution space does not become {#resolved?} by this, it is necessary to
{#resolve_by_trial_and_error!} to find a complete solution.

If a block is given it will yield the solution space with the corresponding
identifier and value before each time a resolution is made
({Possibilities#must_be!}), and it will abort unless the block returns true.
Resolves the given implications and the new implications they yield ( including those resolved from constraints if no implications are given ) until no more identifiers can be resolved . If the solution space does not become { #resolved? } by this it is necessary to { #resolve_by_trial_and_error! } to find a complete solution . If a block is given it will yield the solution space with the corresponding identifier and value before each time a resolution is made ( { Possibilities#must_be! } ) and it will abort unless the block returns true .
def resolve!(implications)
      loop do
        resolvable = Hash.new
        implications.each{|identifier, value|
          if block_given? then
            return false unless yield(self, identifier, value) == true
          end
          self[identifier].must_be!(value, resolvable)
        }
        if resolvable.empty? then
          implications = resolvable_from_constraints
        else
          implications = resolvable
        end
        break if implications.empty?
      end
      resolved?
    end
def resolve! ( implications ) loop do resolvable = Hash . new implications . each { | identifier , value | if block_given? then return false unless yield ( self , identifier , value ) == true end self [ identifier ] . must_be! ( value , resolvable ) } if resolvable . empty? then implications = resolvable_from_constraints else implications = resolvable end break if implications . empty? end resolved? end
Resolves the given implications and the new implications they yield (including
those resolved from constraints, if no implications are given) until no more
identifiers can be resolved.
Resolves the given implications and the new implications they yield ( including those resolved from constraints if no implications are given ) until no more identifiers can be resolved .
the resolution will abort unless the block returns true for each identifier that is resolved.
the resolution will abort unless the block returns true for each identifier that is resolved .
true,nil
true if the solution space became completely resolved.
true if the solution space became completely resolved .
true,false
[Inconsistency] if the solution space becomes inconsistent without any possible solution.
[ Inconsistency ] if the solution space becomes inconsistent without any possible solution .
implications
a mapping between identifiers and their assumed value.
a mapping between identifiers and their assumed value .
solution_space
<not_specific>
the solution space in the state right before a resolution is made.
the solution space in the state right before a resolution is made .
identifier
<not_specific>
an identifier that is resolved.
an identifier that is resolved .
value
<not_specific>
the value the identifier is resolved to.
the value the identifier is resolved to .