old_contents: import unittest
  
  import acpc_python_client as acpc
  
  from evaluation.exploitability import ExploitabilityCalculator
  from tools.game_tree.builder import GameTreeBuilder
  from tools.game_tree.node_provider import StrategyTreeNodeProvider
  from tools.game_tree.nodes import ActionNode
  from tools.walk_tree import walk_tree
  
  KUHN_POKER_GAME_FILE_PATH = 'games/kuhn.limit.2p.game'
  
  
  class ExploitabilityTests(unittest.TestCase):
      def setUp(self):
          self.game = acpc.read_game_file(KUHN_POKER_GAME_FILE_PATH)
          self.game_tree = GameTreeBuilder(
              self.game, StrategyTreeNodeProvider()).build_tree()
  
      def test_always_call_kuhn_value(self):
          # Create strategy such that it will always check or call
          def on_node(node):
              if isinstance(node, ActionNode):
                  node.strategy[1] = 1
          walk_tree(self.game_tree, on_node)
  
          exploitability = ExploitabilityCalculator(self.game).get_exploitability(self.game_tree)
          self.assertEqual(exploitability, -1 / 3)
  
      def test_always_fold_kuhn_value(self):
          # Create strategy such that it will always check or fold
          def on_node(node):
              if isinstance(node, ActionNode):
                  if 0 in node.children:
                      node.strategy[0] = 1
                  else:
                      node.strategy[1] = 1
          walk_tree(self.game_tree, on_node)
  
          exploitability = ExploitabilityCalculator(self.game).get_exploitability(self.game_tree)
          self.assertEqual(exploitability, -1)
  
new_contents: import unittest
  
  import acpc_python_client as acpc
  
  from evaluation.exploitability import ExploitabilityCalculator
  from tools.game_tree.builder import GameTreeBuilder
  from tools.game_tree.node_provider import StrategyTreeNodeProvider
  from tools.game_tree.nodes import ActionNode
  from tools.walk_tree import walk_tree
  
  KUHN_POKER_GAME_FILE_PATH = 'games/kuhn.limit.2p.game'
  LEDUC_POKER_GAME_FILE_PATH = 'games/leduc.limit.2p.game'
  
  
  class ExploitabilityTests(unittest.TestCase):
      def setUp(self):
          self.game = acpc.read_game_file(KUHN_POKER_GAME_FILE_PATH)
          self.game_tree = GameTreeBuilder(
              self.game, StrategyTreeNodeProvider()).build_tree()
  
      def test_kuhn_always_call_value(self):
          # Create strategy such that it will always check or call
          def on_node(node):
              if isinstance(node, ActionNode):
                  node.strategy[1] = 1
          walk_tree(self.game_tree, on_node)
  
          exploitability = ExploitabilityCalculator(self.game).get_exploitability(self.game_tree)
          self.assertEqual(exploitability, -1 / 3)
  
      def test_kuhn_always_fold_value(self):
          # Create strategy such that it will always check or fold
          def on_node(node):
              if isinstance(node, ActionNode):
                  if 0 in node.children:
                      node.strategy[0] = 1
                  else:
                      node.strategy[1] = 1
          walk_tree(self.game_tree, on_node)
  
          exploitability = ExploitabilityCalculator(self.game).get_exploitability(self.game_tree)
          self.assertEqual(exploitability, -1)
  
      def test_leduc_always_fold_value(self):
          # Create strategy such that it will always check or fold
          def on_node(node):
              if isinstance(node, ActionNode):
                  if 0 in node.children:
                      node.strategy[0] = 1
                  else:
                      node.strategy[1] = 1
          walk_tree(self.game_tree, on_node)
  
          exploitability = ExploitabilityCalculator(self.game).get_exploitability(self.game_tree)
          self.assertEqual(exploitability, -1)
subject: Add exploitability test for leduc always-fold