{"id":17998358,"url":"https://github.com/primaryobjects/missionariescannibals","last_synced_at":"2025-10-05T05:24:24.010Z","repository":{"id":25771356,"uuid":"29209625","full_name":"primaryobjects/missionariescannibals","owner":"primaryobjects","description":"Missionaries and Cannibals AI problem in R","archived":false,"fork":false,"pushed_at":"2015-01-13T21:01:06.000Z","size":164,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-09T17:47:44.478Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/primaryobjects.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-13T20:32:02.000Z","updated_at":"2015-01-14T11:34:50.000Z","dependencies_parsed_at":"2022-08-23T12:00:17.124Z","dependency_job_id":null,"html_url":"https://github.com/primaryobjects/missionariescannibals","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primaryobjects%2Fmissionariescannibals","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primaryobjects%2Fmissionariescannibals/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primaryobjects%2Fmissionariescannibals/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primaryobjects%2Fmissionariescannibals/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/primaryobjects","download_url":"https://codeload.github.com/primaryobjects/missionariescannibals/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247135123,"owners_count":20889420,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-29T21:24:57.421Z","updated_at":"2025-10-05T05:24:18.961Z","avatar_url":"https://github.com/primaryobjects.png","language":"R","readme":"Missionaries and Cannibals in R\n=========\n\nSolves the classic Missionaries and Cannibals artificial intelligence problem using the R programming language. Why not? See http://www.aiai.ed.ac.uk/~gwickler/missionaries.html\n\nRules\n---\n\nOn the bank of a river are three missionaries and three cannibals. They're late for dinner and need to get to the other side. There is one boat available that can hold up to two people. If the cannibals ever outnumber the missionaries on either of the river’s banks, the missionaries will get eaten. How can the boat be used to safely carry all the missionaries and cannibals across the river?\n\nRunning It\n---\n\n```\nfindSolution(startState)\n```\n\nOutput\n---\n\nThe program finds all possible solutions from a starting state, within a depth of 15. It uses recursion to evaluate a depth-first search across the transition paths. Output is in the following format:\n\nm1c1\n\nWhere 'm' indicates the number of missionaries being moved and 'c' indicates the number of cannibals being moved. At each move, the boat alternates between right and left.\n\nExample output:\n\n```\n[1] \"*********************** Solution found in 11 steps!\"\n[1] \"m1c1\"\n[1] \"m1c0\"\n[1] \"m0c2\"\n[1] \"m0c1\"\n[1] \"m2c0\"\n[1] \"m1c1\"\n[1] \"m2c0\"\n[1] \"m0c1\"\n[1] \"m0c2\"\n[1] \"m0c1\"\n[1] \"m0c2\"\n```\n\nIn the above example, the first step is to move 1 mercenary and 1 cannibal to the right bank. The second step moves 1 mercenary back to the left bank. The third step moves 2 cannibals to the right bank (all 3 cannibals are now on the right bank). The fourth step moves 1 cannibal back to the left bank. The fifth step moves 2 missionaries to the right bank (there are now equal missionaries and cannibals on both banks, m1c1 and m2c2). For remaining steps, see graph at http://www.aiai.ed.ac.uk/~gwickler/missionaries.html.\n\nLicense\n----\n\nMIT\n\nAuthor\n----\nKory Becker\nhttp://www.primaryobjects.com/kory-becker\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprimaryobjects%2Fmissionariescannibals","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprimaryobjects%2Fmissionariescannibals","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprimaryobjects%2Fmissionariescannibals/lists"}