Skip to content

Commit

Permalink
Fix meta-cfr example (add missing headers, use absltest)
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 486629244
Change-Id: I3ca67b6cf7e32344e8707bc36d59f482e5024bda
  • Loading branch information
lanctot committed Nov 7, 2022
1 parent 762d48a commit 0f1c1ad
Show file tree
Hide file tree
Showing 9 changed files with 137 additions and 3 deletions.
14 changes: 14 additions & 0 deletions open_spiel/python/examples/meta_cfr/sequential_games/cfr.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2022 DeepMind Technologies Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Counterfactual Regret Minimization."""

import copy
Expand Down
22 changes: 19 additions & 3 deletions open_spiel/python/examples/meta_cfr/sequential_games/cfr_test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
# Copyright 2022 DeepMind Technologies Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Tests counterfactual regret minimization."""

from absl.testing import absltest
from absl.testing import parameterized

from open_spiel.python.examples.meta_cfr.sequential_games import cfr
from open_spiel.python.examples.meta_cfr.sequential_games import game_tree_utils as trees
from open_spiel.python.examples.meta_cfr.sequential_games import openspiel_api
from google3.testing.pybase import googletest
from google3.testing.pybase import parameterized


def _uniform_policy(size):
Expand Down Expand Up @@ -67,4 +83,4 @@ def test_cfr_kuhn_poker(self):


if __name__ == '__main__':
googletest.main()
absltest.main()
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2022 DeepMind Technologies Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Dataset generation for meta-CFR algorithm."""

from typing import List, Tuple
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
# Copyright 2022 DeepMind Technologies Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Game tree structure for imperfect information games."""

import copy
from typing import Any, Dict, List, Text, Tuple

Expand Down
15 changes: 15 additions & 0 deletions open_spiel/python/examples/meta_cfr/sequential_games/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
# Copyright 2022 DeepMind Technologies Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Model definitions for optimizer network."""

import enum
from typing import Any, Callable, List, Optional, Union

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
# Copyright 2022 DeepMind Technologies Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""OpenSpiel API."""

import random
from typing import Any, List, Text, Tuple, Dict

Expand Down
15 changes: 15 additions & 0 deletions open_spiel/python/examples/meta_cfr/sequential_games/typing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
# Copyright 2022 DeepMind Technologies Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Typing definitions."""

from typing import Any, Dict, Callable
import jax.numpy as jnp
import optax
Expand Down
15 changes: 15 additions & 0 deletions open_spiel/python/examples/meta_cfr/sequential_games/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
# Copyright 2022 DeepMind Technologies Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Utility functions for meta-cfr algorithm."""

import functools
from typing import List
import haiku as hk
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
# Copyright 2022 DeepMind Technologies Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""API for world state representation."""

import abc
from typing import Any, List, Text, Tuple

Expand Down

0 comments on commit 0f1c1ad

Please sign in to comment.