From dfc5a1e3cce2c0fc7fc9069e3536d5ae17e03055 Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 14 Apr 2011 20:47:34 +0200 Subject: fix algo --- pacman-c++/util.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'pacman-c++') diff --git a/pacman-c++/util.cpp b/pacman-c++/util.cpp index 31d2e79..b1848e1 100644 --- a/pacman-c++/util.cpp +++ b/pacman-c++/util.cpp @@ -81,8 +81,14 @@ namespace Util /* this outer loop is used if there are no more valid places left * so we can change mindistance */ + QList actors; for(unsigned int i = 0; i < players; ++i) { + /* first remove formally placed actors from map */ + foreach(QPoint pos, actors) + map[pos.x()][pos.y()] = Transmission::none; + actors.clear(); + /* get list of valid positions */ QList validpos; for (unsigned int x = 0; x < Constants::map_size.width; ++x) @@ -101,7 +107,9 @@ namespace Util int rand = (int) (validpos.size() * (qrand() / (RAND_MAX + 1.0))); QPoint newpos = validpos.at(rand); map[newpos.x()][newpos.y()] = colors[i] | Transmission::pacman | Transmission::direction_none; + actors.append(newpos); validpos.removeAt(rand); + qDebug() << "actor" << colors[i] << "at" << newpos; QMutableListIterator j(validpos); while(j.hasNext()) -- cgit v1.2.3