logicbot: if input =~ /who is (.*)'s father/i 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/i 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/i 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/i then response = self.send("what did #{$1} married") end logicbot: if input =~ /who did (.*) marry/i then grp1 = $1.to_s; if response =~ /don't know/ then response = self.send("who married #{grp1}?") end; end logicbot: if input =~ /who married (.*)/i then grp1 = $1.to_s; if response =~ /don't know/ then response = self.send("who did #{grp1} marry?") end; end #logicbot: if input =~ /who did (.* and .*) have/i then response = self.send("who did #{$1} had?") end #logicbot: if input =~ /who did (.*) and (.*) have/i then r1 = $1.to_s; r2 = $2.to_s; kids1 = self.send("who did #{r1} and #{r2} had?"); if kids1 =~ /I don't know/ then r3 = self.send("who did #{r2} and #{r1} had?"); if r3 !~ /I don.t know/i then r3 =~ /had (.*)/; response += "#{$1}"; end; end; end logicbot: if input =~ /who did (.*) and (.*) have/i 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/i 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 are (.*)'s grandfathers/i then response = self.send("who is #{$1}'s grandfather?") end logicbot: if input =~ /who is (.*)'s grandmother/i then r0 = $1.to_s; r1,s = self.send("who is #{$1}'s mother"); r2,s = self.send("who is #{r1}'s mother"); response = r2; r3,s = self.send("who is #{r0}'s father?"); r4,s = self.send("who is #{r3}'s mother"); response += " and #{r4}"; end logicbot: if input =~ /who are (.*)'s grandmothers/i then response = self.send("who is #{$1}'s grandmother?") end logicbot: if input =~ /who is (.*)'s sister/i 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 are (.*)'s sisters/i then response = self.send("who is #{$1}'s sister?") end logicbot: if input =~ /who is (.*)'s brother/i 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| 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 are (.*)'s brothers/i then response = self.send("who is #{$1}'s brother?") end logicbot: if input =~ /who is (.*)'s aunt/i 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 are (.*)'s aunts/i then response = self.send("who is #{$1}'s aunt?") end logicbot: if input =~ /who is (.*)'s uncle/i then person = $1.to_s; father,s = self.send("who is #{person}'s father"); uncle,s = self.send("who is #{father}'s brother?"); response = ''; if uncle !~ /I don.t know/i then response = uncle end; aunts,s = self.send("who is #{person}'s aunt?"); if aunt !~ /I don.t know/i then aunts.split(/(?:\.* and |, )/).each() {|aunt| uncle,s = self.send("who did #{aunt} marry?"); if uncle =~ /(.*) married (.*)\.*/ then first = $1.to_s; second = $2.to_s; if aunt =~ /#{first}/i then response += " and #{second}" end; if aunt =~ /#{second}/ then response += " and #{first}" end; end; }; end; mother,s = self.send("who is #{person}'s mother?"); aunt,s = self.send("who is #{mother}'s sister?"); if aunt !~ /I don.t know/i then uncle,s = self.send("who did #{aunt} marry?"); if uncle =~ /married (.*)\.*/ then response += " and #{$1}" end; end; end logicbot: if input =~ /who are (.*)'s uncles/i then response = self.send("who is #{$1}'s uncle?") end logicbot: if input =~ /who is (.*)/i and response =~ /I don't know what/ then response.sub!(/know what/, 'know who') end logicbot: if response =~ / and (.*)\. and (.*)/i then response = "#{$1} and #{$2}" end