Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8707931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:59:15+00:00 2026-06-13T03:59:15+00:00

I’m doing an exercise and where I need to create a simple dating agency

  • 0

I’m doing an exercise and where I need to create a simple dating agency matching system. Currently each person have one hobby, hobbies are categories by active and inactive and if the two hobbies match and the two persons have opposite sex, the dating agency thinks these to persons are a match.

So now I need the system to be able to allow for multiple hobbies but I cant seem to get my head around this.

Here’s what I have:

(deftemplate MAIN::person
    (slot name)
    (slot age)
    (multislot hobby)
    (slot town)
    (slot sex))

(person (name "Jane")
        (age 25)
        (hobby fashion gardening)
        (town montrose)
        (sex female))

(deffacts hobby_types "Hobby categories"
    (hobby_type gardening active)
    (hobby_type swinging active)
    (hobby_type reading inactive)
    (hobby_type fashion inactive)
)

(defrule compatible_hobbies
    (opposite_sex ?name1 ?name2)
    (person (name ?name1) (hobby ?hobby1))
    (person (name ?name2) (hobby ?hobby2))
    (hobby_type ?hobby1 ?type)
    (hobby_type ?hobby2 ?type)
    =>
    (assert (hobbies_match ?name1 ?name2))
)

So first up, do I declare the multislot field correctly? And how do I adjust my compatible_hobbies rule to match against either of the hobbies that a person might have?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:59:17+00:00Added an answer on June 13, 2026 at 3:59 am

    The multislot hobby in person is declared correctly. But your rule won’t match the hobbies correctly and would match the same fact to the same fact showing that Jane is compatible with Jane. Actually if the rule matched facts it would generate the Cartesian product of the person facts (or a large number of non-desired matches).

    I modified the rule to:


    (defrule compatible_hobbies
    (person (name ?n1) (hobby $? ?h1 $?))
    (person (name ?n2) (hobby $? ?h1 $?))
    (hobby_type ?h1 ?x)
    (test (neq ?n1 ?n2))
    =>
    (assert (hobbies_compatible ?n1 ?n2))
    )

    So if you assert two person facts like

    (person (name "Jane") (hobby blah1 gardening blah2)) and (person (name "Jim") (hobby blah3 gardening blah4)) then the rule will fire and the fact (hobbies_compatible Jim Jane) will be asserted (as well as the fact (hobbies_compatible “Jim” “Jane”)).

    The wildcard $? variable matches a set of symbols preceding and following the desired matching hobby. Your opposite sex fact should probably also be a test instead of a fact.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
I am doing a simple coin flipping experiment for class that involves flipping a
I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.