logicbot: if input =~ /who is (.*)'s father/ then r1,s = self.send("who had #{$1}"); if /(.*) and (.*) had/ =~ r1 then f1 = $1.to_s; f2 = $2.to_s; rf1,s = self.send("is #{f1} male?"); if rf1 =~ /Yes/ then response = "#{f1}" end; rf2,s = self.send("is #{f2} male?"); if rf2 =~ /Yes/ then response = "#{f2}" end; end; end logicbot: if input =~ /who is (.*)'s mother/ then r1,s = self.send("who had #{$1}"); if /(.*) and (.*) had/ =~ r1 then f1 = $1.to_s; f2 = $2.to_s; rf1,s = self.send("is #{f1} female?"); if rf1 =~ /Yes/ then response = "#{f1}" end; rf2,s = self.send("is #{f2} female?"); if rf2 =~ /Yes/ then response = "#{f2}" end; end; end #logicbot: if input =~ /who is (.*)'s grandfather/ then r1,s = self.send("who is #{$1}'s father"); r2,s = self.send("who is #{r1}'s father"); response = r2; end logicbot: if input =~ /who did (.*) marry/ then response = self.send("what did #{$1} married") end logicbot: if input =~ /who did (.*) marry/ then grp1 = $1.to_s; if response =~ /don't know/ then response = self.send("who married #{grp1}?") end; end #logicbot: if input =~ /who did (.* and .*) have/ then response = self.send("who did #{$1} had?") end logicbot: if input =~ /who did (.*) and (.*) have/ then r1 = $1.to_s; r2 = $2.to_s; response = self.send("who did #{r1} and #{r2} had?"); r3 = self.send("who did #{r2} and #{r1} had?"); if r3 !~ /I don.t know/i then r3 =~ /had (.*)/; response += " and #{$1}"; end; end logicbot: if input =~ /who is (.*)'s grandfather/ then r0 = $1.to_s; r1,s = self.send("who is #{$1}'s father"); r2,s = self.send("who is #{r1}'s father"); response = r2; r3,s = self.send("who is #{r0}'s mother?"); r4,s = self.send("who is #{r3}'s father"); response += " and #{r4}"; end logicbot: if input =~ /who is (.*)'s sister/ then r0 = $1.to_s; r1,s = self.send("who is #{r0}'s father"); r2,s = self.send("who did #{r1} marry?"); if r2 =~ /(.*) married (.*)\./ then r2b = $1.to_s + " and " + $2.to_s; r3,s = self.send("who did #{r2b} have?"); if r3 =~ /had (.*)(?:,|. and)+ (.*)\./ then k1 = $1.to_s; k2 = $2.to_s; end; if r0 =~ /#{k1}/i and /Yes/i =~ self.send("is #{k2} female?") then response = k2; end; if r0 =~ /#{k2}/i and /Yes/i =~ self.send("is #{k1} female?") then response = k1 end; end; end logicbot: if input =~ /who is (.*)'s brother/ then r0 = $1.to_s; r1,s = self.send("who is #{r0}'s father"); r2,s = self.send("who did #{r1} marry?"); if r2 =~ /(.*) married (.*)\./ then r2b = $1.to_s + " and " + $2.to_s; r3,s = self.send("who did #{r2b} have?"); if r3 =~ /had (.*)(?:,|. and)+ (.*)\./ then k1 = $1.to_s; k2 = $2.to_s; end; if r0 =~ /#{k1}/i and /Yes/i =~ self.send("is #{k2} male?") then response = k2; end; if r0 =~ /#{k2}/i and /Yes/i =~ self.send("is #{k1} male?") then response = k1 end; end; end logicbot: if input =~ /who is (.*)'s aunt/ then r0 = $1.to_s; r1,s = self.send("who is #{r0}'s father"); r2,s = self.send("who is #{r1}'s sister?"); if r2 !~ /I don.t know/i then response = r2 end; r3,s = self.send("who is #{r0}'s mother?"); r4,s = self.send("who is #{r3}'s brother?"); if r4 !~ /I don.t know/i then r5,s = self.send("who did #{r4} marry?"); if r5 =~ /married (.*)\.*/ then response += " and #{$1}" end; end; end logicbot: if input =~ /who is (.*)/ and response =~ /I don't know what/ then response.sub!(/know what/, 'know who') end