nash.learning package

Submodules

nashpy.learning.fictitious_play module

Code to carry out fictitious learning

nashpy.learning.fictitious_play.fictitious_play(A: numpy.ndarray[Any, numpy.dtype[numpy.typing._generic_alias.ScalarType]], B: numpy.ndarray[Any, numpy.dtype[numpy.typing._generic_alias.ScalarType]], iterations: int, play_counts: Optional[Any] = None) Generator[source]

Implement fictitious play

Parameters
  • A (array) – The row player payoff matrix.

  • B (array) – The column player payoff matrix.

  • iterations (int) – The number of iterations of the algorithm.

  • play_counts (Optional) – The play counts.

Yields

Generator – The play counts.

nashpy.learning.fictitious_play.get_best_response_to_play_count(A: numpy.ndarray[Any, numpy.dtype[numpy.typing._generic_alias.ScalarType]], play_count: numpy.ndarray[Any, numpy.dtype[numpy.typing._generic_alias.ScalarType]]) int[source]

Returns the best response to a belief based on the playing distribution of the opponent

Parameters
  • A (array) – The utility matrix.

  • play_count (array) – The play counts.

Returns

The action that corresponds to the best response.

Return type

int

nashpy.learning.fictitious_play.update_play_count(play_count: numpy.ndarray[Any, numpy.dtype[numpy.typing._generic_alias.ScalarType]], play: int) numpy.ndarray[Any, numpy.dtype[numpy.typing._generic_alias.ScalarType]][source]

Update a belief vector with a given play

Parameters
  • play_count (array) – The play counts.

  • play (int) – The given play.

Returns

The updated play counts.

Return type

array