AS.adm.rb

Path: AS.adm.rb
Last Update: Thu Feb 24 20:54:24 W. Europe Standard Time 2005

Methods

Public Instance methods

[Source]

    # File AS.adm.rb, line 1
 1: def adm(l, m=[], n=0)
 2:    nr_attacks = 0
 3:    n.m "STS: #{l.name} / #{m.name}";
 4:    k = l.last
 5:    n.m "#{con}: starting attack against #{k.name}"
 6:    k.attackers(con, n) do |a|
 7:       catch :next_attacker do
 8:          # draw_attack_relation(a, k)
 9:          nr_attacks += 1
10:          n.m "#{con}: found #{nr_attacks.st} attacker #{a.name} against CON's #{k.name}: #{a.name}"
11:          # an attacker may not be repeated
12:          if m.include?(a) then
13:          # if m.includes_with_semantic_equality?(a) then
14:             n.m "#{con}: can't repeat attack #{a.name}"
15:             next # attacker
16:          end
17:          n.m "#{pro}: starting defense against attack #{k.name} <- #{a.name}"
18:          # a defender may be repeated (old defenders)
19:          l.each { |d|
20:             if d.attacks? a then
21:                n.m "#{pro}: defense of #{k.name} <- #{a.name} succeeds with #{d.name}"
22:                throw :next_attacker
23:             end
24:          }
25:          # generate new defenders
26:          a.attackers(pro, n) do |d|
27:             # draw_defend_relation(d, a)
28:             n.m "#{pro}: trying defense #{k.name} <- #{a.name} <- #{d.name}"
29:             if l.any? { |x| x.attacks?(d) }  then
30:                n.m "#{pro}: conflicting #{d.name}"
31:                next
32:             end
33:             if result = adm( l+[d], m+[a], n+1 ) then
34:                n.m "#{pro}: defense #{k.name} <- #{a.name} <- #{d.name} succeeds"
35:                l = result
36:                throw :next_attacker
37:             else
38:                n.m "#{pro}: defense #{k.name} <- #{a.name} <- #{d.name} fails"
39:                n.m "#{pro}: trying next defender #{k.name} <- #{a.name}"
40:             end
41:          end # each_attacker |d|
42:          n.m "#{pro}: defense #{k.name} <- #{a.name} fails, returning nil"
43:          return nil
44: 
45:       end # catch
46:       n.m "#{con}: trying next attacker of #{k.name}"
47:    end # each_attacker |a|
48:    if nr_attacks.zero? then
49:       n.m "#{con}: no attackers, hence attack on #{k.name} fails"
50:    else
51:       n.m "#{con}: no more attackers, hence attack on #{k.name} fails"
52:    end
53:    n.m "STS: #{k.name} is a member of the admissible set #{l.name}";
54:    n.m "STS: #{k.name}'s conclusion, viz. #{k.conclusion.html}, is admissible";
55:    l
56: end

[Source]

    # File AS.adm.rb, line 71
71: def con
72:    'CON'.color('con')
73: end

[Source]

    # File AS.adm.rb, line 80
80: def draw_attack_relation(a, b)
81: end

[Source]

    # File AS.adm.rb, line 77
77: def draw_defend_relation(a, b)
78: end

[Source]

    # File AS.adm.rb, line 67
67: def pro
68:    'PRO'.color('pro')
69: end

[Validate]