new: added new angry state (closes #486)

This commit is contained in:
Simone Margaritelli 2019-11-01 15:53:31 +01:00
parent 2f948306eb
commit 31a89cbe4b
5 changed files with 36 additions and 5 deletions

View File

@ -75,6 +75,15 @@ class Automata(object):
logging.info("unit is grateful instead of sad")
self.set_grateful()
def set_angry(self, factor):
if not self._has_support_network_for(factor):
logging.warning("%d epochs with no activity -> angry" % self._epoch.inactive_for)
self._view.on_angry()
plugins.on('angry', self)
else:
logging.info("unit is grateful instead of angry")
self.set_grateful()
def set_excited(self):
logging.warning("%d epochs with activity -> excited" % self._epoch.active_for)
self._view.on_excited()
@ -103,12 +112,20 @@ class Automata(object):
self._epoch.next()
# after X misses during an epoch, set the status to lonely
# after X misses during an epoch, set the status to lonely or angry
if was_stale:
factor = did_miss / self._config['personality']['max_misses_for_recon']
if factor >= 2.0:
self.set_angry(factor)
else:
logging.warning("agent missed %d interactions -> lonely" % did_miss)
self.set_lonely()
# after X times being bored, the status is set to sad
# after X times being bored, the status is set to sad or angry
elif self._epoch.inactive_for >= self._config['personality']['sad_num_epochs']:
factor = self._epoch.inactive_for / self._config['personality']['sad_num_epochs']
if factor >= 2.0:
self.set_angry(factor)
else:
self.set_sad()
# after X times being inactive, the status is set to bored
elif self._epoch.inactive_for >= self._config['personality']['bored_num_epochs']:

View File

@ -199,6 +199,7 @@ ui:
smart: '(✜‿‿✜)'
lonely: '(ب__ب)'
sad: '(╥☁╥ )'
angry: "(-_-')"
friend: '(♥‿‿♥)'
broken: '(☓‿‿☓)'
debug: '(#__#)'

View File

@ -16,6 +16,7 @@ DEMOTIVATED = '(≖__≖)'
SMART = '(✜‿‿✜)'
LONELY = '(ب__ب)'
SAD = '(╥☁╥ )'
ANGRY = "(-_-')"
FRIEND = '(♥‿‿♥)'
BROKEN = '(☓‿‿☓)'
DEBUG = '(#__#)'

View File

@ -284,6 +284,11 @@ class View(object):
self.set('status', self._voice.on_sad())
self.update()
def on_angry(self):
self.set('face', faces.ANGRY)
self.set('status', self._voice.on_angry())
self.update()
def on_motivated(self, reward):
self.set('face', faces.MOTIVATED)
self.set('status', self._voice.on_motivated(reward))

View File

@ -67,6 +67,13 @@ class Voice:
self._('I\'m sad'),
'...'])
def on_angry(self):
# passive aggressive or not? :D
return random.choice([
'...',
self._('Leave me alone ...'),
self._('I\'m mad at you!')])
def on_excited(self):
return random.choice([
self._('I\'m living the life!'),