From e719d3579bb1539117b85eff6379eee0c7a77cd8 Mon Sep 17 00:00:00 2001 From: Andrés Ambrois Date: Fri, 26 Sep 2008 07:00:30 +0000 Subject: Add GnuGo 3.6 to the bundle. Use system's GnuGo if installed. --- (limited to 'activity.py') diff --git a/activity.py b/activity.py index ed30754..249d8cf 100644 --- a/activity.py +++ b/activity.py @@ -343,16 +343,22 @@ class PlayGo(Activity): self.ai = gnugo(boardsize=self.size) def ai_activated_cb(self, widget=None): - self.ai_activated = True - self.ai = gnugo(boardsize=self.size) - for pos, color, captures in self.game.undostack: - self.notify_ai(pos[0], pos[1], color) - self._alert(_('AI'), _('PlayGo AI Activated')) + try: + self.ai = gnugo(boardsize=self.size) + except Exception, e: + self._alert(_('AI'), _('GnuGo loading failed!: %s' % e)) + self.gameToolbar.set_ai_button_state(False) + else: + self.ai_activated = True + for pos, color, captures in self.game.undostack: + self.notify_ai(pos[0], pos[1], color) + self._alert(_('AI'), _('PlayGo AI Activated')) def ai_deactivated_cb(self, widget): - self.ai_activated = False - del self.ai - self._alert(_('AI'), _('PlayGo AI Deactivated')) + if self.ai: + self.ai_activated = False + del self.ai + self._alert(_('AI'), _('PlayGo AI Deactivated')) def notify_ai(self, x, y, color): logger.debug('Notifying AI of play by %s at %s x %s', color, x, y) -- cgit v0.9.1