summaryrefslogtreecommitdiff
path: root/i/marvin/src/ai/ai.cc
diff options
context:
space:
mode:
Diffstat (limited to 'i/marvin/src/ai/ai.cc')
-rw-r--r--i/marvin/src/ai/ai.cc34
1 files changed, 28 insertions, 6 deletions
diff --git a/i/marvin/src/ai/ai.cc b/i/marvin/src/ai/ai.cc
index d869eae..1ad1df3 100644
--- a/i/marvin/src/ai/ai.cc
+++ b/i/marvin/src/ai/ai.cc
@@ -38,13 +38,14 @@ Ai::~Ai(void)
{
// On réinitialise
// Initialise les moteurs
- motor_.init();
+ // XXX
+// motor_.init ();
// initialise la carte es
- es_.init();
+ es_.reset ();
// On sync
do
{
- scheduler_.schedule(500, true);
+ scheduler_.schedule (500, true);
}
while (!sync ());
}
@@ -53,9 +54,30 @@ void
Ai::init(void)
{
// Initialisation de motor
- motor_.init();
+ motor_.init ();
// Initialisation de la carte Es
- es_.init();
+ es_.reset ();
// Paf on sync
- while(!update());
+ while (!update ());
}
+
+/// Synchronize data of under class
+bool
+Ai::sync (void)
+{
+ return es_.sync () && motor_.sync ();
+}
+
+/// Wait for something to happened
+bool Ai::update (void)
+{
+ scheduler_.schedule (100, true);
+ bool retour = sync ();
+ // On vérifie que le match n'est pas fini
+ if (Timer::getRoundTime () > roundDuration_)
+ throw std::runtime_error ("Fin de match, merci d'avoir
+ participé !");
+ return retour;
+}
+
+