<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Hazard handicap function example
This example uses a handicap function and data taken from a talk by Hazard. This example appears on Slide 36.
Hazard, C. J. 2010. What every game designer should know about game theory. Triangle Game Conference. Raleigh, North Carolina
First, we import the packages we need.
Step1:  Then we take the data as it appeared in Hazard's slides. The example given was symmetric, which means that the base matrix is log-skew-symmetric (every element is the reciprocal of its transpose). However, this payoff function can also work for non-symmetric cases.
Step2:  Hazard's talk used the convention that the elements of the matrix are how many of the row player's unit it takes to equal one of the column player's unit. We use the opposite convention, where higher is better for the row player, so we take the inverse, which for the symmetric case is the same as the transpose.
Step3:  Now we can construct our problem instance and solve it.
Step4:  Finally we print the result, normalizing the handicaps so that they sum to 1. Note that a global scale in the handicaps merely scales the global payoffs and does not change the Nash equilibrium. Since the value of the (balanced) game is 0 this does not change the value either.
<ASSISTANT_TASK:>
Python Code:
import _initpath
import numpy
import zerosum.balance
Explanation: Hazard handicap function example
This example uses a handicap function and data taken from a talk by Hazard. This example appears on Slide 36.
Hazard, C. J. 2010. What every game designer should know about game theory. Triangle Game Conference. Raleigh, North Carolina
First, we import the packages we need.
End of explanation
data = numpy.array([
    [1.0, 3.0, 0.5],
    [1.0 / 3.0, 1.0, 0.5],
    [2.0, 2.0, 1.0]])
names = ['Hammer', 'Spear', 'Curse']
Explanation: Then we take the data as it appeared in Hazard's slides. The example given was symmetric, which means that the base matrix is log-skew-symmetric (every element is the reciprocal of its transpose). However, this payoff function can also work for non-symmetric cases.
End of explanation
data = 1.0 / data
Explanation: Hazard's talk used the convention that the elements of the matrix are how many of the row player's unit it takes to equal one of the column player's unit. We use the opposite convention, where higher is better for the row player, so we take the inverse, which for the symmetric case is the same as the transpose.
End of explanation
balance = zerosum.balance.HazardSymmetricBalance(data)
result = balance.optimize()
Explanation: Now we can construct our problem instance and solve it.
End of explanation
for name, handicap in zip(names, result.handicaps / numpy.sum(result.handicaps)):
    print("%8s: %0.3f" % (name, handicap))
Explanation: Finally we print the result, normalizing the handicaps so that they sum to 1. Note that a global scale in the handicaps merely scales the global payoffs and does not change the Nash equilibrium. Since the value of the (balanced) game is 0 this does not change the value either.
End of explanation
<END_TASK>