Category Archives: AI

Getting started with ResearchCyc

My main hobby currently is looking for an open-source community focused on commonsense reasoning, specifically, the encoding of commonsense used in social interactions in a form that allows for inferring explanations and predictions. If no such community exists, I’ll create one. So far, I’ve found biannual symposia and mailing lists (see CommonsenseReasoning.org) but no open-source community.

Predicate calculus is the only notation that will be expressive enough to capture the richness of the domain, I think. I’m aware of graph-based efforts like OpenMind, but they either don’t allow constraints across variables (e.g., the agent of the action must also have known he would be its primary beneficiary in order to infer that the action was self-serving) or their method of matching to support inferencing (which is likely to be some flavor of “maximal bipartite-graph matching“) will end up being functionally identical to unification for predicate calculus. So I’m placing my bet on predicate calculus-based approaches. The Stanford Encyclopedia of Philosophy (SEP) has an interesting overview.

One of the most promising of these efforts is by Andrew S. Gordon and Jerry Hobbs, which they are developing toward a book. Let’s see if we can make that part of the community once the book is published. Andrew has a video lecture about it and Jerry offers an extensive peek at the formulations.

The Cyc Project has a freely-available ontology (i.e., a high-level taxonomy plus frame-like schemas or predicate definitions), OpenCyc. It’s unclear whether they encourage or permit contributions, and anyway I’m looking for general rules and facts rather than just an ontology. That kind of knowledge base is what their ResearchCyc project is said to be. Although ResearchCyc is not open, maybe they are open to contributions. And it was conceived and is led by one of my AI heroes, Doug Lenat, and I’d like to help it if I can. Michael Witbrock has some interesting video lectures about Cyc. Here’s what I’ve done to have a look inside ResearchCyc…

Getting a copy of RCyc

  1. Write to rcyc@cyc.com with a few sentences describing your non-commercial research interest in the system, and asking for a (free) license. The response might take a few days.
  2. If your license request is approved, you’ll get an email with a download site url, a userid, and a password. Licenses seem to expire after a year. If I click the download link and enter the password, I get a page where I can click an “rcyc” folder link and then get a list of downloads; however, revisiting the same url and entering the userid as well as the password always fails for me.
  3. Download both the “o” tgz and sha1 files (the most up-to-date in early 2014). Getting the sha1 file is recommended because I encountered a corrupted download a few times, and you need a way to check for that. There is a free “MD5 & SHA Checksum” tool, and you can verify the download this way:
    1. Click ‘Browse’ and select researchcyc-4.0o.tgz
    2. Open the sha1 file using a text editor, then select and copy the SHA1 sum value (i.e., the part preceding “researchcyc-4.0o.tgz”, not including whitespace)
    3. Click ‘Paste’ in the application and then ‘Verify’. If verification fails, try downloading the large tgz file again. (I’ve had 5 downloads in a row fail.)
  4. Unpack the tgz.
  5. Avoid editing any files if you’re using Windows; otherwise, you might introduce Windows-specific line ending characters that will prevent the server from starting in Ubuntu.

Installation

I recommend installing on a publicly-accessible server, say, on an Amazon Web Services (AWS) Elastic Compute Cloud (EC2) instance. Doing so will allow you access from any browser if your local machine doesn’t accept requests on port 80. For example, this is what it looks like in Chrome on a Samsung Note 2… rcyc viewed on samsung note 2

  1. Configuring the host machine…
    • If installing on EC2…
      1. Go to https://console.aws.amazon.com/ec2/ and create an account if you don’t have one
      2. Click Launch Instance
      3. Select Ubuntu Server 13.10 64-bit
      4. In the left pane, select General Purpose, then click any row with close to 4 GiB RAM (under the “Memory” column)
      5. On the “Add Storage” page, set the persistent storage capacity (the “Size (GiB)” column) to about 25.
      6. When you get a chance to edit the Security Group, permit access from your clients…
        1. Note the security group of the instance
        2. In the left pane, click Security Groups
        3. In the right pane, select the row of the instance’s security group
        4. In the bottom pane, select the Inbound tab. To allow requests from all IP addresses, there should be a row with Port=22 and Source=0.0.0.0/0. Be sure to add Port=3602 and Source=0.0.0.0/0 because rcyc’s webserver uses this port. For more guidance, see http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/authorizing-access-to-an-instance.html
      7. If prompted, click “Yes, I want to continue with this instance type” (It won’t be free)
      8. Click Launch
      9. Choose an existing key pair, or create a new one (and be sure to download the key pair file). Then click “Launch Instances”.
      10. Make sure you’ve installed Putty
      11. To convert the pem file to Putty’s ppk format, follow http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/putty.html#putty-private-key
      12. To upload rcyc, do something like this:

        C:\Windows\system32>C:\”Program Files (x86)”\PuTTY\pscp.exe -r -i C:\[your path]\[your private key file].ppk “C:\[another local path]\researchcyc-4.0o\*.*” ubuntu@[your ec2 public dns]:

        I would have preferred WinSCP’s graphical UI, but it kept showing connection errors while transferring large files. If pscp is interrupted, you can re-run the command above. If you decided to upload the gzip instead of unpacking first, or you didn’t set the persistent storage high enough, and then find that you don’t have enough free disk space to unpack (type df -h to check), there is a way to increase disk space without having to lose your disk content

      13. Configure Putty to make it easier to login to the server for future maintenance…
        1. In Windows, go to Start | Putty
        2. Session | HostName = ubuntu@[Public DNS shown in AWS EC2 Instances page for this instance]
        3. Session | ConnectionType = SSH
        4. Connection | SSH | Auth | PrivateKeyFile = [browse to ppk file you created from the pem file]
        5. Window | Columns = 120
        6. Window | LinesOfScrollback = 2000
        7. Session | SavedSessions = “rcyc”, then click Save. When you attempt an ssh connection with this EC2 instance in the future, you can select “rcyc” in the sessions list, click Load, and then edit the host address to match what the ec2 console shows.
        8. Before clicking Open to start the ssh session, you might need to change to a network that doesn’t block port 22.
        9. When prompted “The server’s host key is not cached in the registry…”, click Yes.
        10. If all goes well, you should be prompted with
          Using username "ubuntu".
          Authenticating with public key "imported-openssh-key"
          
          The programs included with the Ubuntu system are free software;
          the exact distribution terms for each program are described in the
          individual files in /usr/share/doc/*/copyright.
          
          Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
          applicable law.
          
          ubuntu@ip-NN-NN-NN-NN:~$

    • Otherwise, if you prefer installing locally…
      1. Let’s take the hard case of using Windows. The rcyc setup instructions indicate some features aren’t supported on Windows, so I setup Ubuntu 13 64-bit in VMWare Player 6 on Windows 7 Pro 64-bit. But before creating that virtual machine, go into your BIOS and ensure that “Intel Virtualization Technology” (i.e., “Intel VT-x”) is enabled; if there is another setting limiting use of VT-x to “trusted” applications, turn that off.
      2. Before powering-on the Ubuntu VM, make sure its Memory setting is at least 7680MB.
      3. To allow fast transfer of files with the Windows host, I created a “forUbuntu” folder on my Windows desktop, moved the unpacked download contents there, installed VMWare Tools in the vm, and set the vm option for Shared Folders to the new one on my host desktop. Now access the shared folder in the vm and copy the files to a local folder in the guest Ubuntu filesystem.
        1. sudo apt-get install build-essential
        2. sudo apt-get install linux-headers-`uname -r`
        3. Select Player | Manage | Install VMWare Tools…, which will mount a folder as though it were the cdrom drive
        4. cp /media/[your userid]/*.gz /tmp/
        5. cd /tmp
        6. tar xvzf VM*.gz
        7. cd vmware-tools-distrib/
        8. sudo ./vmware-install.pl and accept all defaults
        9. Verify that the mounting tool is working: lsmod | grep vmhgfs
        10. The shared folder should be listed after doing this: ls /mnt/hgfs. If it is, do this: cd /mnt/hgfs/yourSharedFolder
        11. Whether you’ve already unpacked the rcyc gzip or not, let’s move it to a non-shared folder to avoid any accidental edits (and attendant changes to line endinges) such as your home: mv *.tgz ~ and then let’s go there: cd ~/researchcyc-*.
        12. If you haven’t already unpacked the RCyc gzipped tar file, do so now, like this: tar -xvzf *.tgz

        The remainder of the instructions will assume your terminal’s working directory is this one.

      4. ResearchCyc’s scripting language is a Lisp variant called SubL that runs on top of Java. So, to install Java in your vm, open a terminal there and sudo apt-get install openjdk-7-jre-headless
  2. Make sure you have a terminal open to the Ubuntu instance (either a Putty connection to EC2 or a terminal running in your local vm instance)
  3. Edit researchcyc-4.0o/server/cyc/run/init/jrtl-release-init.lisp so that the license value you received in email is pasted in place of the XXXX in (csetq *master-license-key* "XXXX")
  4. In the same directory, I edited parameters.lisp by adding (csetq *cb-show-cure-link* t) just before (check-system-parameters) at the end. This is supposed to make a purple “CURE” button appear in the web interface, which I’m told is a knowledge entry tool that provides some guidance.
  5. Navigate to the main scripting directory cd researchcyc-4.0o/server/cyc/run/
  6. Do a test launch to verify everything was configured correctly; try ./bin/run-cyc.sh
    • If you get error bash no such file or directory executable then one possibility is that Windows line-endings made it into some of the text files; try:
      sudo apt-get install dos2unix
      researchcyc-4.0o$ find . *.* |xargs dos2unix
      chmod a+x ./bin/*.sh
      sudo apt-get install openjdk-7-jre-headless

      (My initial research into this problem suggested that there might be 32-bit components in rcyc that wouldn’t run in Ubuntu 13.10 without ia32-libs but that turned out to be a red herring.)

    • After about five minutes of startup, you should see something like:
      Start time: Thu Nov 21 17:08:08 SGT 2013
      Lisp implementation: Cycorp Java SubL Runtime Environment
      JVM: Oracle Corporation OpenJDK 64-Bit Server VM 1.7.0_25 (23.7-b01)
      Current KB: 7163
      Patch Level: 10.145914
      Working Directory: /home/david/Desktop/researchcyc-4.0o/server/cyc/run/.
      Running on: ubuntu
      OS: Linux 3.11.0-13-generic (amd64)

      and after another five minutes, you should see:

      HTTP server listening on port 3602.  Connect via URL http://ubuntu:3602/cgi-bin/cg?cb-start
      
      SPARQL server started on port 3615.
      Jetty server started on port 3603
      Ready for services.
      Total memory allocated to VM: 5791MB.
      Memory currently used: 1651MB.
      Memory currently available: 4140MB.
      CYC(1):
    • Once a Cyc: prompt appears, the webserver is ready. (But its public DNS might not be distributed yet, so if you’re impatient you might want to use the public IP number shown in the EC2 console.)
    • Verify that it’s accessible by using a local browser to visit http://[your ec2 instance’s public dns, or localhost if using a browser in the vm]:3602/cgi-bin/cg?cb-start
  7. If you’re going to edit any rcyc content, and you probably will eventually want to, you’ll need to create an account other than the default Guest account to do so.
    1. Check researchcyc-4.0o/server/cyc/run/init/release-specific-init.lisp to make sure the following is NOT present there.
      (noting-progress "Enabling password authentication"
         (csetq *image-requires-authentication?* T))

      If it’s present, delete it and restart the RCyc server. One way to stop the server is to enter (exit) (a SubL command) at the CYC: prompt; another way is to reboot the Ubuntu server.

    2. On the start page, there’s a textbox for entering a userid to change which user is logged in. Enter “CycAdministrator” and Submit.
    3. You should be on a new page (actually just a new frame in the lower pane) that offers a button to return to the (“now stale”) login page. Click it, enter the new userid you want, and Submit.
    4. You should be in a new frame that says “Unknown Cyclist…Do you want to create a new Cyc constant with this name?”. Click “Yes, Create Cyclist”.
          Note: On at least one occasion, the RCyc server quit after this command, returning no content to my browser and showing this in the terminal:
      CYC(1): ./bin/cyc-runner.sh: line 298:  2555 Killed                  java ${BIT_FLAG} ${SERVER_FLAG} -Xms${MIN_HEAP} -Xmx${MAX_HEAP} ${OLD_SORT_FLAG} ${CODE_CACHE_FLAG} ${PERM_SIZE_FLAG} ${EA_FLAG} ${CM_FLAG} ${PGC_FLAG} ${FAST_OPTS_FLAG} ${AGENT_LIB_FLAG} ${EXTRA_OPTIONS} ${CYC_JAVA_OPTIONS} ${LOG_FLAG} ${ASSERTS_FLAG} -cp "${CLASSPATH}" ${MAIN_CLASS} -f "${INIT_FORM}" "$@"
      Shutting down Derby which provides the SCG repository ....
      ./bin/cyc-runner.sh: line 304: /db/bin/stopNetworkServer: No such file or directory
      ... see  for log output.
  8. If the test allowed you to reach RCyc’s main webpage, then the easier way to launch the rcyc server in the future is:
    • If using EC2, the following will auto-launch rcyc whenever you Start the instance after having Stopped it (because stopping an instance when you don’t need it saves on AWS usage fees). Create /etc/init/run-cyc.conf with this content,
      start on runlevel [2345]
      stop on runlevel [!2345]
      respawn
      script
           cd /home/ubuntu/researchcyc-4.0o/server/cyc/run/
           exec ./bin/run-cyc.sh -b
      end script

      and then do initctl start run-cyc

    • Otherwise, when running in the local vm… Instead of, ./bin/run-cyc.sh do this: setsid ./bin/run-cyc.sh -b “setsid” runs rcyc in a different Linux session than your terminal, so you can exit your terminal and the rcyc server will still run. The “-b” flag is Cyc’s own flag for telling it to run in the background.
  9. You might now want to configure the rcyc server to require a password.
  10. Start exploring in the web UI. For example,
    1. Type “hear” or “perceive” into the search box.
    2. Select #$hearsThat or #$perceivesThat from the autocomplete dropdown
    3. Scroll down the left pane to select Consequent or Antecedent. The right pane will show rules in which the predicate you selected is used in either an antecedent or consequent.

Many thanks to the ResearchCyc team in helping me get this far!

Cycorp offers guidance about how to explore cyc through this web interface.

Hopefully, someday they’ll offer rcyc as an Amazon Machine Instance (AMI), which would make these instructions much shorter!

Print Friendly, PDF & Email

Glossary and notes for Len Talmy’s work on cognitive semantics

I’m starting to read Talmy’s work on folk concepts of space and causality, and I find that I need to keep a glossary of his specialist terms. Maybe this will be helpful to other readers of Talmy, too.

As a quick introduction, you might want to read the Wikipedia page on Force dynamics.

[Why do we think Talmy’s work might be useful to us? We are looking for folk concepts of space, time, causality, and intention that we can formalize and use in a computer simulation of how people attribute causality and intentionality to figures in simple animations. Talmy’s work might provide articulations of the folk concepts we are after. A primary challenge for us is to identify concepts of interest to us (i.e., those that trigger expectations or that are necessary to support explanations) , because most of the concepts that Talmy identifies are powerful generalizations of distinctions made in language but which have little apparent causative power that shapes our thinking. For example, the distinction between moving-to and moving-from seems to have little effect on our expectations of what the moving object will do next, while the distinction between contact and attachment clearly affects our expectations of how two objects will move if rotated, say, around their common center of gravity.]

All page references refer to his book, Toward a cognitive semantics, volume 1.

Glossary (sorted in order of appearance, not alphabetically)

  • veridical – appearing to be true (100c)
  • factive – When two representations of the same thing are contradictory, the one that appears more true is called “factive” (100d)
  • fictive – When two representations of the same thing are contradictory, the one that appears less true is called “fictive” (100d)
  • fictivity – there exist multiple conflicting representations of the same thing, some of which seem more true than others
  • see vs sense – When two percepts of the same thing are contradictory, and one is less palpable and thus more fictive, Talmy calls the perception of the factive one “seeing” and the perception of the fictive one “sensing”. (102a). For example, a static Pac-Man quasi-circle shape is “seen” while the dynamic alternative of a circle having a wedge cut from it is “sensed”.
  • ception – A continuous conceptual space whose dimensions are all related to palpability (aka, the ability to recognize or act on something). (102b)  Intended as a replacement for arbitrary pigeon-holing of phenomena as one of sensation, perception, or conception. (139d)
  • constructional vs experienced fictive motion – “Languages systematically and extensively refer to stationary circumstances with forms and constructions whose basic reference is to motion;” however, there are “differences over the degree to which such expressions evoke an actual sense or conceptualization of motion [in their speakers].” (104c)  While some speakers would report a strong sense of movement for a construction that other speakers would report feeling no such sense, there are some constructions that evoke a sense of motion in almost all speakers.
  • active-determinative principle – For “some” [119b] emanation types of motion, the source role will usually be attributed to the more active or determinative candidate objects. For example, in a radiation path between the Sun and one’s hand, the Sun is perceived as the brighter of the two, and thus the more active, and thus given the role of source. “This principle accounts for the absence of any linguistic formulations that depict the sun as drawing energy from objects.” (117c) “One’s experience of the characteristics of agency may provide one with the model for the active-determinative principle” (119d)
  • extramission – “the notion that sight involves something emerging from the eyes” (124b) “The conceptual model in which the Agent emits a sensory Probe appears to hold sway in the cartoon imagery [of Superman’s X-ray vision].” (125b) Similarly, the expression “to look daggers at” or “the evil eye”.

Notes

  1. When fictivity is present, the representations often differ in a single dimension. (100e)
    • State of occurrence – whether something is present or absent
    • State of change – whether something changed or was in stasis
      • State of motion – whether something moved or not (“stationariness”)
  2. There is a general cognitive bias towards dynamism; i.e., things appear to move when they are in fact still, rather than things appearing to remain still when they in fact have moved. (101b)
    • For example, an utterance and a belief might be contradictory, and where greater credence is given to the belief, and the utterance indicates movement while the belief indicates stationariness: “That mountain range goes from Canada to Mexico.”
  3. “Fictive motion in language encompasses a number of relatively distinct categories” (103c), including:
    1. Emanation - “The fictive motion of something intangible emerging from a source.” (105d) “In most subtypes, the entity continues along its emanation path and terminates by impinging on some distal object.” Note the reliance on distal objects in all the examples below.
      1. Orientation paths – “A continuous linear intangible entity emerging from the front of some object and moving steadily away from it.” E.g., “She crossed in front of the TV.”
        1. Prospect paths – e.g., English verbs “face” and “look out”
        2. Alignment paths – e.g., English verb “lie” with path prepositions “toward” or “away from”
        3. Demonstrative paths – e.g., English verb “point” with path prepositions “toward” or “away from”
        4. Targeting paths – An agent aims an object that has a front so that the front follows a desired path “relative to the object’s surroundings” (109d)
        5. Line of sight – E.g., English verbs “look” and “turn” with path prepositions “toward” or “away from”
      2. Radiation paths – (skipped pp. 111-116)
      3. Shadow paths
      4. Sensory paths
    2. Pattern paths – (skipped pp. 129-138)
    3. Frame-relative motion
    4. Advent paths
      1. Site manifestation
      2. Site arrival
    5. Access paths
    6. Coextension paths (e.g., see mountain range example above) –
      1. Talmy83: Virtual motion
      2. Jackendoff83: Extension
      3. Langacker87: Abstract motion
      4. Matsumoto96: Subjective motion
  4. “Palmer (1980) and Palmer and Bucher (1981) found that in certain arrays consisting of co-oriented equilateral triangles, subjects perceive all the triangles at once pointing by turns in the direction of one or another of their common vertices. Moving the array in the direction of one of the common vertices biases the perception of the pointing to be in the direction of that vertex.” (123b)
  5. Anthropologist Pascal Boyer’s study of “ghost physics” (1994) – Belief systems characteristically permit some exceptions to normal physics, such as invisibility or passing through walls, but not other (barely!) conceivable exceptions such as “reverse causality”.
  6. The semi-abstract level of palpability (146)
    1. Sensing of object structure, e.g. envelope/interior similarity across magnitudes of volcano and thimble
    2. Sensing of path structure, e.g., similarity regardless of shape of “across” when a deer runs straight across a field or zig-zags across it
    3. Sensing of reference frames: earth-based, object-based, or viewer-based
    4. Sensing of structural history and future (object is stationary), e.g. a broken flower pot
    5. Sensing of projected paths (object is moving), e.g. a thrown ball currently arcing through the air, or a path through a crowded restaurant
    6. Sensing of force dynamics, e.g. perceived forces among objects thought to naturally be in motion or at rest. Jepson and Richards (93)  found a sideways T is thought to have its two parts “attached” while in an upside-down T, the two parts are perceived merely to be in “contact”. [See Siskind’s AI work on attributing support vs attachment.]
  7. (skipped pp. 154-172, which is the rest of the chapter on Fictive Motion in Language and “Ception”)
  8. Motion-aspect formulas – e.g., Be at, Move to, …, Move from-along (215-6, 245-52)
  9. (skipped to 409)
  10. Force dynamics (to be continued)
Print Friendly, PDF & Email

Evaluating animation toolkits for ‘perception of intentionality’ simulations

Our team needs to create 2D animations that trigger the ‘perception of causality’ or the ‘perception of intentionality’ through the movement of simple shapes. (Jointed figures with faces and props can come later.) The prototypical example of such animation is the one Heider and Simmel used in their experiments in 1944, since then transcribed into Flash.

I’ve been evaluating animation toolkits with a few objectives in mind:

  1. Creating such 2D animations must be as easy as possible
  2. It must be possible to inspect such an animation programmatically to determine where each shape is in each frame. (We are creating a simulation that will “watch” the same animation, but instead of observing pixels it will read such data.)
  3. The animations must be easily distributed, such as being able to run in most browsers on most platforms using no plugin or only a commonly installed one

Here are my evaluations.

Adobe CS4 Flash Professional

PROs

  • Flash files (SWF file format) are playable on most platforms using the Flash Player browser plugin, which most people already have installed
  • There are many online tutorials about how to create animation using this toolkit, and expertise with the tool is widespread (so it would be easy to find help or hire someone)
  • The “motion tween” feature available in the CS4 version eliminates the need to copy/paste/tweak each frame into the next frame; instead, one just drags from the starting position to the ending position, and can add arbitrary curvature at many points in between by pulling on edit points.
  • Although it’s a binary file format, the SWF format has been documented by Adobe, and there is an open-source Java library, JSwiff, that provides handy wrapper accessors. It even has a forum for questions about JSwiff, but answers seem infrequent.
    • This library is a little out of date, since it refuses to process files using SWF versions after 8, but the code seems capable of handling version 10 just fine (version 10 is what CS4 Flash Pro generates). To use the library with more recent SWF versions, it seems one has to edit the source (included in the download) by changing SWFDocument.setVersion to eliminate the max version check, and then build one’s own jar file. This method refers to private member “header”, so one can’t just subclass SWFDocument and override the method.
    • The JSwiff site also offers a separate download for its inspector.bat, which provides a GUI for inspecting all tag content of a SWF. Surprisingly, it works on SWF version 10; I’m not sure how it gets around the version check.
    • Note: There is another Java library, JavaSWF, but work on it seems to have stopped around 2005 and it doesn’t handle recent updates to the SWF file format such as the DefineShape4 tag. There is a JavaSWF Yahoo group, but it seems answers are rarely provided for any questions in recent years.

CONs

  • Adobe’s tool costs US$700.
  • There is an option to Export Motion XML, which seems like a good alternative to the Java wrapper, but despite multiple attempts I couldn’t get it to include information about each frame of my test animation.

Alternative SWF toolkits

For example,

AnimeStudio Debut6

Swish MaxMini

Synfig

Toufee

PROs

  • At US$50-150, much more affordable than Adobe’s toolkit

CONs

  • Harder to use than Adobe’s toolkit because they require copy/paste/tweak of each frame of motion, and there is  no motion guide unless one sketches a path using the drawing tool and then erases that path.
  • Toufee’s min frame rate is 1 frame/sec, which is far too slow for my needs. It also has a number of bugs such as having random transition effects on by default, and making it impossible to configure an object to disappear faster than in 5 sec in the first frame
  • Although Synfig is an open-source SWF-creating toolkit, which would otherwise make it very attractive, it has such a convoluted install process for Windows that I’m not willing to put my time into evaluating it further. It seems likely that it could just break someday, and there would be too little interest in Windows users to expect them to fix it.

Alternative web-based animation platforms

For example,

HTML5’s canvas element + Javascript

Java

Microsoft Silverlight

PROs

  • Inexpensive (free) toolkits
  • Easily distributed and demo’d

CONs

  • Would require investing significant time or hiring funds into programming animations largely from scratch
  • Would require significant effort to design a way that an outside application could inspect what objects are depicted and what is happening

K-Sketch

PROs

  • Free, open-source, and allows for easy creation of motion paths
  • Allows export to SWF

CONs

  • Motion paths aren’t editable — one needs a very steady hand
  • Current release won’t run on my XP machine, and on my Vista machine the lasso selection tool doesn’t work, which means I can’t create any motion paths. Not actively supported right now, but that might change soon.

Bottom line: Assuming one can afford Adobe’s Flash toolkit, the combination of it and the Java wrapper seem like a very workable solution.

Tip: If you need to control the playback of an SWF using Java, it seems the best option is a hack where a native SWF player like XULRunner is controlled by Java by injecting Javascript. Have a look at the DJ Native Swing project. It’s hosted on Sourceforge and has discussion forums there.

Print Friendly, PDF & Email

Making games more fun with artificial stupidity

If one buys into Daniel Dennett’s proposed use of “the intentional stance” to generate explanations and predictions of human behavior (say, in an AI program that observes a person and tries to find ways of helping), then accounting for human error is a tough problem (because the stance assumes rationality and errors aren’t rational). That’s one reason I’m interested in errors.

Game AI faces a similar problem in that some games like chess and pool/billiards allow a computer player to make very good predictions many steps ahead, often beyond the ability of human players. Such near-optimal skill makes the computer players not much fun. One has to find ways of making the computers appear to play at a similar level of skill as whatever human they play against.

I just came across a very interesting article on the topic of how to make computer players have plausibly non-optimal skills. Here’s a good summarizing quote:

In order to provide an exciting and dynamic game, the AI needs to manipulate the gameplay to create situations that the player can exploit.

In pool this could mean, instead of blindly taking a shot and not caring where the cue ball ends up, the AI should deliberately fail to pot the ball and ensure that the cue ball ends up in a place where the player can make a good shot.

An interesting anecdote from the article is that the author created a pool-playing program that understood the physics of the simulated table and balls so well that it could unfailingly knock any ball it wanted to into a pocket. The program didn’t make any attempt to have the cue ball stop at a particular position after the target ball was pocketed, however. Yet naive human players interpreted the computer’s plays as trying to optimize the final position of the cue ball, apparently because they projected human abilities onto the program, and humans cannot unfailingly pocket any ball but seemingly are pretty good at having the cue ball stop where they want.

Read more

Print Friendly, PDF & Email

Causal chain from gaze to mental attitudes in one agent

An update on my gaze project… This diagram shows pre-formalization work (in AI) on a mapping of gaze actions, mental attitudes, and causal chains among them. The set of actions, and their conditions and effects, are being fleshed out by referring to standard textbooks on nonverbal communication. The mental attitudes, and their conditions and effects, are being fleshed out by referring to BDI models in AI. Eventually, this knowledge will be formalized as rules (probably in Prolog). This effort is made somewhat harder by having to write the rules in a way that they can be used either to “run” the mind of an agent or be used by the agent to explain/predict the observed actions of other agents. This AI microtheory should be useful in a variety of domains, but I’m especially interested in the problem of detecting when an elderly person in one’s care needs help. Eventually, I’ll want to add recognition of facial expressions, gestures, etc but one can tell a lot just from gaze: level of alertness, goals, level of satisfaction with one’s work toward a goal, emotions of fear and surprise, attempts to get one’s attention, and more. causalseqofgaze To give a sense of how this theory of mind could be applied to multi-agent interactions, here is a sample analysis of an imaginary interaction between Randy, Betty, and Greta. Randy admires Betty as she passes by, but she notices and has a negative reaction. Randy realizes he’s been caught out and tries to repair the situation, but doesn’t act quickly enough before Betty looks away. Greta is looking on (without being noticed by the others) and can predict what they each think and feel by the end.One could adjust the scenario in several ways:

  • Betty is shy and avoids meeting Randy’s eyes before even realizing he’s leering.
  • Randy anticipates a bad outcome from leering before doing so and is able to suppress it.
  • Randy and Betty had been introduced a few days before, and Randy recognizes her only after starting to leer. This incident sours their cordial relationship.
  • Before this encounter, Greta had been under the impression that Betty had a romantic interest in Randy, but this encounter changes her mind.
  • At the end, Randy realizes Greta has been watching the whole time and gets mad (explain why!), or they share a laugh.

alanbettycarmen_scenarioflow1

Print Friendly, PDF & Email

Micro-theory of gaze

Gaze (aka “looking at something”) can be automatic (scanning the environment), strategic (getting a closer look at something interesting), and even communicative (indicating interest, anger, or eagerness to cooperate). I’m aiming for rules that would allow not just simulating an agent, but allow an agent to predict or explain another agent.

Following my evaluation of potential inference tools last week, I’ve tentatively settled on using either JIProlog or AmziProlog because Prolog is the only rule language that allows me to be expressive enough, and these two tools allow Java and Prolog to invoke each other (while Prolog is embedded in a Java Runtime (JVM)).

It’s important that the tool run in a JVM because I want outside users not to be restricted to using the same platform as I do, and because I want to use industry-standard libraries for graphics, etc.

The high-level architecture of my system (named ATOM = automated theory of mind) is:

  • A set of Prolog facts for each agent representing that agent’s initial mental attitudes.
  • A set of Prolog rules for each agent representing what mental attitudes cause others under what conditions.
  • A Java object that simulates a physical environment. When the Prolog module infers an “attempt” attitude, this is converted into a call into the Java module to see what follows from the attempt. When the Java module determines a causal change that should be observable to an agent, then agent-specific “percept” facts are injected into the Prolog module and may trigger new inference there.
  • A set of JUnit tests that swap out files for different initial states in Prolog (and different simulated environments in Java) to verify that the outputs match expected values. There may also be unit tests that swap out rules to test predictions about agents that veer from the “norm”.

Because a fair amount of research goes into the formulation of each rule, each rule will be in its own Prolog file accompanied by comments describing the scenarios that inspired the rule (also present as unit tests) and the particular pages in articles that inspired the rules or any changes to them. (This may seem fussy, but a career in reading related research tells me we all need to be much better at providing such “provenance”.)

As mentioned in the summary above, gaze is a good human behavior to start with. But read here for even better motivation: Vertegaal et al, 2001: “Eye Gaze Patterns in Conversations: There is More to Conversational Agents Than Meets the Eyes”.

Some initial generalizations I wanted to capture:

  • The blurriness of peripheral percepts is high.
  • Moving the eyes in the dir of a peripheral percept will change it to a focal percept, and whatever was focal will become peripheral.
  • The blurriness of a focal percept is usually less than if it were peripheral.
  • For intriguing resemblances with high blurriness, one would want less blurriness.
  • For intriguing resemblances in focus, one usually wants to ignore peripheral resemblances that are less intriguing.
  • For surprising peripheral items, one automatically looks even if intending not to.

I want to write rules for these in such a way that, not only could the rules drive the behavior of one agent, but they could also be used by that agent to explain the gaze behavior of another agent that one is focused on. That is, it’s the start of an automated “theory of mind”.

Print Friendly, PDF & Email

Comparison of tools for rule-based inference

Although I started writing pseudo-code rules a few weeks ago, I’ve suspended that while I look for a tool for writing and testing rules so I don’t assume too much about the quality of the rules so far. This post describes what I’m looking for and the tools I’ve looked at. I’m likely to go with JIProlog or Amzi Prolog (and perhaps later, ECLiPSe).

I’m looking for an expert system-type tool that offers these features:

  1. Simple, first-order-predicate-calculus (FOPC) syntax rather than C-style code
  2. Can be embedded easily in Java programs
    • Prefer Java because it’s platform-independent
    • Java has widespread use in simulation research that I might use or partner with
  3. Has a large, active community that might be interested in my work, and from whom I might get tech help
  4. Has good IDE (editor tool) support for auto-completion, syntax-highlighting, breakpointing, etc
  5. Allows for easy changing of any rules governing beliefs, desires, and intentions (aka BDI)
  6. Has a way of tracking what papers/scenarios influenced the conditions and actions of each rule (aka “provenance tracking” in my terms)

This is what I’ve found:

Jason

PROs

  • Uses a Prolog-like syntax (i.e. fairly similar to FOPC)
  • Has a jEdit-based IDE that allows inspecting the mind of each agent, and history of actions among the agents
  • There is a book with in-depth how-to info (which I’ve ordered)

CONs

  • Structured as a “BDI” system, which sounds at first like a big positive, but on deeper inspection seems to mean that it handles beliefs, desires, and intentions in a pre-defined way. I’m not sure yet how limiting this might be.
  • I asked the creators if there was a compelling reason to use it over a simple inference engine (apart from the ability of MAS frameworks to allow agents to run over a network), and they said there isn’t much advantage in that respect.
  • Might not support back-chaining or facts with universally-quantified vars (however, this might be possible in Jason and all Rete-based systems by encoding such facts as rules with “true” as their antecedent)

JADEX

PROs

  • Java based
  • Has its own BDI debugger tool

CONs

  • BDI support seems “cooked in” and likely to be hard to change
  • Rules must be expressed in an especially verbose form of xml
  • Might not support back-chaining or facts with universally-quantified vars

JAM

PROs

  • Java-based BDI
  • Distinguishes between achievement goals and maintenance goals
  • Seems more comprehensive in BDI concepts than similar systems

CONs

  • Procedural rather than FOPC-style syntax
  • Seems to have same limits on expressiveness (i.e. fairly restricted compared to FOPC or Prolog) as other forward-chaining expert system tools using the Rete clause-indexing algorithm

Discrete Event Calculus Reasoner (DECL)

PROs

  • The “event calculus” (EC) is a set of rules for dealing with the frame problem (aka “commonsense law of inertia” — things tend to stay as they are unless explicitly changed). The frame problem occurs when a rule system knows a fact was true in the past but isn’t sure whether to assume it’s still true. CCSS is likely to run into the frame problem often, since our systems are likely to be triggered by combinations of mental attitudes, but some of those attitudes may seem “stale” due to being triggered in the past. The “discrete” part in the name is due to assuming a timeline with discrete points rather than a continuous one.
  • Has a book that shows how to encode BDI and OCC in EC

CONs

  • Requires integrating Unix env, Python, “PLY”, and one of a small set of SAt logic solvers. This seems too brittle and platform-specific to me.
  • While EC has a good-sized community, this inference engine seems to have a small one
  • Seemingly no IDE support
  • Might not support  facts with universally-quantified vars

Clips

PROs

  • FOPC-like syntax

CONs

  • C-based, so integrations would have to use C, JINI, or system-level calls

Jess

[also see Jess vs Prolog]

PROs

  • Clips syntax implemented in Java
  • Has an Eclipse (IDE) plugin
  • Widely used

CONs

  • Roundabout support for facts with universally-quantified vars: One must use the special ‘nil’ slot value for such vars. Not sure if this will actually work.
  • Roundabout support for backchaining: Instead of indicating that a particular rule is backchaining, one must commit to making a particular predicate backchainable. This seems like it could have unwanted side-effects.

ACT-R

Uses special jargon — “chunk” is what most other systems call a fact; “declarative memory” (for chunks/facts) is what other systems call “working memory”; “procedural memory” is where production rules are kept (is this an oxymoron only to me?)

Structured very similarly to BDI toolkits — there is a goal buffer and a retrieval/belief buffer, but unlike BDI these buffers are allowed to hold only one fact/chunk at a time.

PROs

  • Very popular among “cognitive modeling” community

CONs

  • Limiting the size and number of buffers seems unnecessarily limiting — it limits the expressiveness of rule conditions
  • Seems to be no support for universally-quantified vars in facts, especially because vars are not allowed to bind with ‘nil’ in facts
  • Coded in Lisp, and special purpose IDE is very limited but does have a stepper (but perhaps not breakpointing)

Soar

Similar jargon as ACT-R.

PROs

  • Fair-sized community in AI and Psychology (e.g. John Laird of UMichigan)
  • Formalization of Cohen & Levesque’s teamwork theory exists, STEAM, created at USC by Milind Tambe’s group. (I strongly suspect any team- or cooperation-related work we do will have to build on C&L’s theory.)
  • Java-based
  • Has its own IDE

CONs

  • Would prefer Eclipse plugin to specialized IDE
  • Syntax allows for separate stages of “proposing” and “adopting” operators, and a lot of flexibility in conflict resolution. I don’t currently need this, though, and the syntax is somewhat different from traditional FOPC. I think I could migrate to Soar later if needed.
  • Not sure if Soar has negative connotations for roboticists and AI folk, due to its somewhat dogmatic views on cognitive architecture

LEADSTO

Prolog-based simulation tool. It’s been used by its creators for simulating many domains, including a prey animal that anticipates a predator’s actions (by simulating the predator’s mind) and counteracts.

It appears to have some sort of unit-testing support built-in. Perhaps embeddable in a Prolog/Java bridge.

JBoss Rules/Drools

[IBM tutorial]

PROs

  • Very active community (enterprise)
  • Not only an Eclipse plugin but also a browser-based “rule management system” (not sure of its features yet)
  • Java-based

CONs

  • Two primary rule languages – one in “natural” but highly constrained English, and one that mixes FOPC with procedural constructs. There is a nascent effort to provide CLIPS/Jess-style language support also.
  • Doesn’t support backchaining
  • Probably doesn’t support facts with universally-quantified vars (unless through a workaround like Jess’)

Prolog in Java [external overview]

PRO: Prolog supports backchaining and facts with universally-quantified vars

  • JIProlog
    • PRO: Java can call Prolog, and vice versa
    • PRO: Available as shareware (free)
    • PRO/CON: Special-purpose IDE
    • PRO: Actively supported
  • AmziProlog
    • PRO: Java can call Prolog, and vice versa
    • PRO: Has a plugin for Eclipse IDE
    • PRO: There is a breakpointing debugger available for the IDE plugin
    • PRO: Good support through Amzi forums
    • CON: The breakpointer is not free
    • CON: The breakpointer, and the interpreter, require some getting used to. For example, the listener must be shutdown manually (via a “quit” typed command) before one exits Eclipse. Common keyboard shortcuts cause errors when the Listener has focus.
  • ECLiPSe
    • An extension of Prolog that supports “constraint programming”. In my terms, this allows one to make temporary bindings such as “T > 2” rather than only permanent absolute bindings like “T = 3” as pure Prolog demands, thereby delaying commitment to a specific value. This is a way to be efficient by doing search in a “constrain and generate” style rather than a “generate and test” style. For example, if one wanted to know if “the book was returned before Monday”, one could constrain a time variable to be before Monday and then search for book return events using that time variable, instead of searching for all book return events using an unbound time variable and then checking each variable binding to see if it was after Monday.
    • However, one is limited to relations for which a “constraint solver” can be written; ECLiPSe comes with several solvers for different kinds of problems.
    • A plugin for the Eclipse IDE is available, Saros, but I couldn’t get version 1.0 working. It was contributed by a Cisco employee, and rumor is that he will get official support to update it. I’ll re-evaluate when that happens.
  • JPL
    • PRO: Java can call Prolog, and vice versa. Commonly used with free SWI-Prolog
    • CON: Not actively supported since 2003 (at least not the docs)
  • tuProlog
    • PRO: open source, and appears actively supported
  • JLogic
    • PRO: Free
    • PRO/CON: Special-purpose IDE
  • Jinni
    • CON: Not free
  • SICStus Jasper
    • CON: Not free
  • GNU Prolog for Java 0.1.0
    • PRO: Free
    • CON: Very early release
    • CON: Appears not to be actively supported
    • CON: No IDE

Cyc engine and tools (but not KB) – TBD

Currently can’t run on Vista; will try on XP or Linux soon

RePast – TBD

Swarm – TBD

Cogent

Targeted at situation-assessment and decision-making applications. Uses Bayesian network as part of its tech.

PROs

CONs

  • Appears to be not available, except perhaps through a belief net app from Charles River Analytics
  • “On the situation assessment side, one major problem we are confronted with is that the type of belief network currently used in COGENT does not model temporal information explicitly.”

MatLab

PROs

  • Popular in research community

CONs

  • Seems limited to numeric-oriented simulation rather than rule-based ones
Print Friendly, PDF & Email