def test_add_knowledge(self):

        # No neighbor mines
        msAi = ms.MinesweeperAI()
        msAi.add_knowledge((7, 0), 0)
        self.assertEqual(msAi.knowledge, [])

        # All neighbor mines
        msAi = ms.MinesweeperAI()
        msAi.add_knowledge((7, 7), 3)
        self.assertEqual(msAi.knowledge, [])

        # Unknown
        msAi = ms.MinesweeperAI()
        msAi.add_knowledge((0, 0), 1)
        sentence = ms.Sentence([(0, 1), (1, 0), (1, 1)], 1)
        self.assertEqual(msAi.knowledge, [sentence])

        # Example case
        msAi = ms.MinesweeperAI(3, 3)
        msAi.add_knowledge((0, 0), 1)
        msAi.add_knowledge((0, 1), 1)
        msAi.add_knowledge((0, 2), 1)
        msAi.add_knowledge((2, 1), 2)
        sentence = ms.Sentence({(2, 0), (2, 2)}, 1)
        self.assertEqual(msAi.knowledge, [sentence])
    def test_known_safes(self):

        # All are safe
        sentence = ms.Sentence([(0, 1), (0, 2), (0, 3)], 0)
        self.assertEqual({(0, 1), (0, 2), (0, 3)}, sentence.known_safes())

        # Not known
        sentence = ms.Sentence([(0, 1), (0, 2), (0, 3)], 2)
        self.assertIsNone(sentence.known_safes())
    def test_mark_mine(self):
        sentence = ms.Sentence([(0, 1), (0, 2), (0, 3)], 2)

        # First Cell
        sentence.mark_mine((0, 1))
        self.assertEqual({(0, 2), (0, 3)}, sentence.cells)

        # Second Cell
        sentence.mark_mine((0, 2))
        self.assertEqual({(0, 3)}, sentence.cells)

        # Cell NOT in sentence
        sentence.mark_mine((2, 1))
        self.assertEqual({(0, 3)}, sentence.cells)

        # Check mine count
        self.assertEqual(0, sentence.count)