[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Enigma-cvs] enigma/src stones_complex.cc,1.51,1.52
From: |
Ralf Westram <address@hidden> |
Subject: |
[Enigma-cvs] enigma/src stones_complex.cc,1.51,1.52 |
Date: |
Thu, 30 Oct 2003 19:12:57 +0000 |
Update of /cvsroot/enigma/enigma/src
In directory subversions:/tmp/cvs-serv18988/src
Modified Files:
stones_complex.cc
Log Message:
- Some finetuning for OxydStone color shuffling.
Now it only exchanges the colors of closed oxyds,
so oxyd_shuffle() may be called repeatedly
Index: stones_complex.cc
===================================================================
RCS file: /cvsroot/enigma/enigma/src/stones_complex.cc,v
retrieving revision 1.51
retrieving revision 1.52
diff -C2 -d -r1.51 -r1.52
*** stones_complex.cc 27 Oct 2003 11:48:30 -0000 1.51
--- stones_complex.cc 30 Oct 2003 19:12:55 -0000 1.52
***************
*** 34,37 ****
--- 34,38 ----
#include <algorithm>
#include <vector>
+ #include <iostream>
using namespace std;
***************
*** 2310,2322 ****
OxydStone::shuffle_colors()
{
! string icolor, acolor;
! for (unsigned i=0; i<instances.size(); ++i) {
! int a=IntegerRand(0, instances.size()-1);
! instances[i]->string_attrib("color", &icolor);
! instances[a]->string_attrib("color", &acolor);
! instances[i]->set_attrib("color", acolor.c_str());
! instances[a]->set_attrib("color", icolor.c_str());
}
}
--- 2311,2348 ----
OxydStone::shuffle_colors()
{
! string icolor, acolor;
! vector<int> closed_oxyds;
! unsigned isize = instances.size();
! for (unsigned i=0; i<isize; ++i) {
! if (instances[i]->state == CLOSED) {
! closed_oxyds.push_back(i);
! }
! }
! unsigned size = closed_oxyds.size();
! if (size>1) {
! for (unsigned i = 0; i<size; ++i) {
! int a = IntegerRand(0, size-2);
! if (a >= i) ++a; // make a always different from j
!
! OxydStone *o1 = instances[closed_oxyds[i]];
! OxydStone *o2 = instances[closed_oxyds[a]];
!
! assert(o1 && o2);
! assert(o1->state == CLOSED);
! assert(o2->state == CLOSED);
!
! o1->string_attrib("color", &icolor);
! o2->string_attrib("color", &acolor);
!
! if (icolor != acolor) {
! Log << "Exchanging color " << closed_oxyds[i] << " with " <<
closed_oxyds[a]
! << " ('" << icolor << "'<->'" << acolor << "')" << endl;
!
! o1->set_attrib("color", acolor.c_str());
! o2->set_attrib("color", icolor.c_str());
! }
! }
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Enigma-cvs] enigma/src stones_complex.cc,1.51,1.52,
Ralf Westram <address@hidden> <=