Class MuddyChildrenProblem


  • public class MuddyChildrenProblem
    extends java.lang.Object
    Class representing the problem of muddy children. The problem is as follows:
    • the children go to play but the father has warned them not to get dirty;
    • they come back and if one of them is dirty, the father says "at least one of you is dirty".
    The goal is this: to make sure that only the children who know they are dirty have to tell on each other. To do this, the children know the condition of the other children's foreheads, but a considered child does not know his condition. Therefore, he has to reason about the actions and programs of the other children in order to know if he himself is dirty or not.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String prettyPrintKripkeStructure​(KripkeStructure structure, java.util.function.Function<java.lang.String,​java.lang.String> atomPredicateExtractor)
      Pretty prints a Kripke structure.
      static void problem​(int n, int realWorld, int maxIteration)
      Generalized problem using the multi-agent knowledge-based program (MABKP) interpreter.
      static void problemN2K1()
      Problem with two children and one child among them is dirty (without the MAKBP interpreter).
      static void problemN2K2()
      Problem with two children and both are dirty (without the MAKBP interpreter).
      static void problemN3K2()
      Problem with three children and thow child among them are dirty (without the MAKBP interpreter).
      static void problemN3K3()
      Problem with three children and are all dirty (without the MAKBP interpreter).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MuddyChildrenProblem

        public MuddyChildrenProblem()
    • Method Detail

      • prettyPrintKripkeStructure

        public static java.lang.String prettyPrintKripkeStructure​(KripkeStructure structure,
                                                                  java.util.function.Function<java.lang.String,​java.lang.String> atomPredicateExtractor)
        Pretty prints a Kripke structure.
        Parameters:
        structure - structure to pretty print
        atomPredicateExtractor - function to extract the predicate
        Returns:
        worlds of the structure in prettyfied string
      • problem

        public static void problem​(int n,
                                   int realWorld,
                                   int maxIteration)
        Generalized problem using the multi-agent knowledge-based program (MABKP) interpreter. To encode the real world, we pass a decimal number which will be then decoded in a binary number allowing to create the worlds in an automatic way. For example, if n = 4, realWorld will be between 0 and 15 included. If we choose realWorld = 13 ( = (1101)_2 ), the real world will be the world where :
        • agents 0, 2, 3 are dirty
        • agent 1 is clean
        Parameters:
        n - number of children
        realWorld - real world encoded in decimal
        maxIteration - maximum number of iteration to avoid an infinite while loop
        Throws:
        java.lang.IllegalArgumentException - thrown the real world can't exists
      • problemN2K1

        public static void problemN2K1()
        Problem with two children and one child among them is dirty (without the MAKBP interpreter).
      • problemN2K2

        public static void problemN2K2()
        Problem with two children and both are dirty (without the MAKBP interpreter).
      • problemN3K2

        public static void problemN3K2()
        Problem with three children and thow child among them are dirty (without the MAKBP interpreter).
      • problemN3K3

        public static void problemN3K3()
        Problem with three children and are all dirty (without the MAKBP interpreter).