Kuro5hin.org: technology and culture, from the trenches
create account | help/FAQ | contact | links | search | IRC | site news
[ Everything | Diaries | Technology | Science | Culture | Politics | Media | News | Internet | Op-Ed | Fiction | Meta | MLP ]
We need your support: buy an ad | premium membership

[P]
Missionaries and Cannibals

By Edmund Blackadder in Edmund Blackadder's Diary
Tue Feb 19, 2013 at 02:20:15 AM EST
Tags: octave, missionaries, cannibals, mcp, planning, ai planning, coursera, hack, ugly code, cut and paste (all tags)

Coursera's AI Planning class presents the Missionaries and Cannibals problem in an early lecture, as an example of a planning exercise.

McCarthy says:


It is an elementary student exercise to write a program to search the space and get the above sequence of states

I tried it in Octave. The results are not pretty: http://subbot.org/coursera/aiplan/mcp/


I can get it to find one solution: http://subbot.org/coursera/aiplan/mcp/output.txt (The steps are similar to McCarthy's solution except for the second step, which is one alternate path pictured in http://subbot.org/coursera/aiplan/mcp/mcp.png .)

The Octave code is not general and involves cut-and-pasted sections, because I don't know how to iterate over a group of different-sized matrices in Octave.

JordiGH noted in #octave that this is not the sort of problem Octave is suited for. What I would like to do is wrap Octave with http://subbot.org/myagent so that I could take advantage of the matrix operations from another language (such as Ruby).

For the present, I just tried to get Octave to do the problem. I cheated by looking at the solutions beforehand, so I knew that the 11th step should contain the solution. What I really want to do is have a loop that keeps creating new matrices for each step and testing them to see if they've reached the goal, but as I said I don't know how to do that in Octave (yet).

The whole procedural, repetitive mess is in http://subbot.org/coursera/aiplan/mcp/mcp.m.txt .

After finding the solution, I have to backtrack to find the particular steps that led to that solution. When there are two possible steps, I just take the last one.

The solution is heavily customized to the problem and not easily generalizable. Isn't this the case with most AI programs? The key, I think, lies in the natural language processing. McCarthy says:


We skip the part about going from an English statement of the problem to a logical statement for two reasons. First, we don't have anything new to say about parsing English or about the semantics of English. Second, we don't yet have the logical target language that the parsing program should aim at. Progress toward establishing this language is the goal of the paper.

In other words, it's really hard. But if we can figure out the NLP part, the rest will follow, I think.

From http://www.cs.cornell.edu/home/llee/papers/cstb/index.html :


Indeed, it is often said that NLP is "AI-complete" (a pun on NP-completeness; see [other chapter][sic]), meaning that the most difficult problems in artificial intelligence manifest themselves in human language phenomena. This belief in language use as the touchstone of intelligent behavior dates back at least to the 1950 proposal of the Turing Test as a way to gauge whether machine intelligence has been achieved; as Turing wrote, "The question and answer method seems to be suitable for introducing almost any one of the fields of human endeavour that we wish to include".

Sponsors

Voxel dot net
o Managed Hosting
o VoxCAST Content Delivery
o Raw Infrastructure

Login

Related Links
o AI Planning
o Missionari es and Cannibals
o says
o http://sub bot.org/coursera/aiplan/mcp/
o http://sub bot.org/coursera/aiplan/mcp/output.txt
o http://sub bot.org/coursera/aiplan/mcp/mcp.png
o http://sub bot.org/myagent
o http://sub bot.org/coursera/aiplan/mcp/mcp.m.txt
o http://www .cs.cornell.edu/home/llee/papers/cstb/index.html
o Edmund Blackadder's Diary


Display: Sort:
Missionaries and Cannibals | 24 comments (24 topical, editorial, 0 hidden)
can we skip to the part where you (3.00 / 3) (#1)
by LilDebbie on Tue Feb 19, 2013 at 07:32:51 AM EST

stick your head in a gas oven and kill yourself?

My name is LilDebbie and I have a garden.
- hugin -

boring, OO crap just makes more verbose as usual (none / 1) (#2)
by sholden on Tue Feb 19, 2013 at 11:21:31 AM EST

from collections import deque

class State:
    def __init__(self, data=(3,3,1)):
        assert self._valid(data)
        self.data = data

    def __hash__(self):
        return hash(self.data)

    def __eq__(self, other):
        return self.data == other.data

    def _valid(self, data):
        if data[0] < 0 or data[0] > 3 or data[1] < 0 or data[1] > 3 or data[2] < 0 or data[2] > 1:
            return False
        if (data[0] > 0 and data[1] > data[0]) or (data[0] < 3 and data[0] > data[1]):
            return False
        return True

    def goal(self):
        return self.data[0] == 0 and self.data[1] == 0

    def transitions(self):
        for boat in (-1, 1):
            for m, c in ((2,0), (1,0), (1,1), (0,1), (0,2)):
                newdata = (self.data[0] + boat*m, self.data[1] + boat*c, self.data[2]+boat)
                if self._valid(newdata):
                    yield State(newdata), "%d%d%s" % (m, c, "> <"[boat+1])

seen = {}
queue = deque()
initial = State()
queue.append((initial,[]))
seen[initial] = -1
while(len(queue)):
    state, history = queue.popleft()
    for newstate, transition in state.transitions():
        if newstate.goal():
            print ', '.join(history+[transition])
        else:
            if newstate not in seen or seen[newstate] >= len(history):
                seen[newstate] = len(history)
                queue.append((newstate,history+[transition]))

--
The world's dullest web page


You might have heard of an amazing algorithm (none / 0) (#4)
by procrasti on Wed Feb 20, 2013 at 03:55:21 AM EST

called Astar?

Personally, I'd send two missionaries across the river in the boat, then bring the two of them back... problem solved.

<-- kr5ddit
-------
if i ever see the nickname procrasti again on this site or anywhere in my life, i want it to be in an OBITUARY -- CTS
doing my best at licking arseholes - may 2015 -- mirko
-------
Winner of Kuro5hin: April 2015
-------
kr5ddit.com - You're front page to the internettm.

Now that you're a proven failure at AI too (none / 0) (#5)
by procrasti on Wed Feb 20, 2013 at 02:42:23 PM EST

get on with the econ sim...

Cause maximising value IS THE PSYCH RULE

You stupid filthy moronic retarded crackhead failure.

God how I hope you die soon.

<-- kr5ddit
-------
if i ever see the nickname procrasti again on this site or anywhere in my life, i want it to be in an OBITUARY -- CTS
doing my best at licking arseholes - may 2015 -- mirko
-------
Winner of Kuro5hin: April 2015
-------
kr5ddit.com - You're front page to the internettm.

Missionaries and Cannibals | 24 comments (24 topical, 0 editorial, 0 hidden)
Display: Sort:

kuro5hin.org

[XML]
All trademarks and copyrights on this page are owned by their respective companies. The Rest © 2000 - Present Kuro5hin.org Inc.
See our legalese page for copyright policies. Please also read our Privacy Policy.
Kuro5hin.org is powered by Free Software, including Apache, Perl, and Linux, The Scoop Engine that runs this site is freely available, under the terms of the GPL.
Need some help? Email help@kuro5hin.org.
My heart's the long stairs.

Powered by Scoop create account | help/FAQ | mission | links | search | IRC | YOU choose the stories!