in robosumo/envs/sumo.py [0:0]
def _comp_contact_reward(self, agent):
# Penalty for pain
body_ids = [
agent.body_name_idx[name]
for name in ['head', 'torso'] if name in agent.body_name_idx
]
forces = np.clip(agent.get_cfrc_ext(body_ids), -100., 100.)
pain = agent.COST_COEFS['pain'] * np.sum(np.abs(forces))
# Reward for attacking opponents
attack = 0.
for other in agent._opponents:
body_ids = [
other.body_name_idx[name]
for name in ['head', 'torso'] if name in other.body_name_idx
]
forces = np.clip(other.get_cfrc_ext(body_ids), -100., 100.)
attack += agent.COST_COEFS['attack'] * np.sum(np.abs(forces))
return attack - pain