Commit 6a6c12b5 authored by Sergey Kireev's avatar Sergey Kireev
Browse files

bug fix in cpp

parent 43146375
......@@ -506,6 +506,56 @@ class NLE_sqr_CA : public NLE_CA_base<hood_vonNeumann,hood_type> {
}
}
virtual void do_move_group_NL(int label,int dir) {
switch(dir) {
case 0: { // up
for (int ix=0;ix<nx;ix++) {
const int first_state = ca::get(ix,0);
bool first_to_move = false;
if (ca::group[ca::xy1d(ix,0)] == label) { ca::get(ix,0) = nle::L; first_to_move = true; }
for (int iy=1;iy<ny;iy++)
if (ca::group[ca::xy1d(ix,iy)] == label) { ca::get(ix,iy-1) = ca::get(ix,iy); ca::get(ix,iy) = nle::L; }
if (first_to_move) ca::get(ix,ny-1) = first_state;
}
break;
}
case 1: { // right
for (int iy=0;iy<ny;iy++) {
const int first_state = ca::get(nx-1,iy);
bool first_to_move = false;
if (ca::group[ca::xy1d(nx-1,iy)] == label) { ca::get(nx-1,iy) = nle::L; first_to_move = true; }
for (int ix=nx-2;ix>=0;ix--)
if (ca::group[ca::xy1d(ix,iy)] == label) { ca::get(ix+1,iy) = ca::get(ix,iy); ca::get(ix,iy) = nle::L; }
if (first_to_move) ca::get(0,iy) = first_state;
}
break;
}
case 2: { // down
for (int ix=0;ix<nx;ix++) {
const int first_state = ca::get(ix,ny-1);
bool first_to_move = false;
if (ca::group[ca::xy1d(ix,ny-1)] == label) { ca::get(ix,ny-1) = nle::L; first_to_move = true; }
for (int iy=ny-2;iy>=0;iy--)
if (ca::group[ca::xy1d(ix,iy)] == label) { ca::get(ix,iy+1) = ca::get(ix,iy); ca::get(ix,iy) = nle::L; }
if (first_to_move) ca::get(ix,0) = first_state;
}
break;
}
case 3: { // left
for (int iy=0;iy<ny;iy++) {
const int first_state = ca::get(0,iy);
bool first_to_move = false;
if (ca::group[ca::xy1d(0,iy)] == label) { ca::get(0,iy) = nle::L; first_to_move = true; }
for (int ix=1;ix<nx;ix++)
if (ca::group[ca::xy1d(ix,iy)] == label) { ca::get(ix-1,iy) = ca::get(ix,iy); ca::get(ix,iy) = nle::L; }
if (first_to_move) ca::get(nx-1,iy) = first_state;
}
break;
}
}
nle::groups_found = false;
}
public:
virtual void fill_debug() {
......@@ -789,56 +839,6 @@ class NLE_sqr4_CA : public NLE_sqr_CA<hood_vonNeumann> {
return { snn, snl, sll };
}
virtual void do_move_group_NL(int label,int dir) {
switch(dir) {
case 0: { // up
for (int ix=0;ix<nx;ix++) {
int first_state = ca::get(ix,0);
bool first_to_move = false;
if (ca::group[ca::xy1d(ix,0)] == label) { ca::get(ix,0) = L; first_to_move = true; }
for (int iy=1;iy<ny;iy++)
if (ca::group[ca::xy1d(ix,iy)] == label) { ca::get(ix,iy-1) = ca::get(ix,iy); ca::get(ix,iy) = L; }
if (first_to_move) ca::get(ix,ny-1) = first_state;
}
break;
}
case 1: { // right
for (int iy=0;iy<ny;iy++) {
int first_state = ca::get(nx-1,iy);
bool first_to_move = false;
if (ca::group[ca::xy1d(nx-1,iy)] == label) { ca::get(nx-1,iy) = L; first_to_move = true; }
for (int ix=nx-2;ix>=0;ix--)
if (ca::group[ca::xy1d(ix,iy)] == label) { ca::get(ix+1,iy) = ca::get(ix,iy); ca::get(ix,iy) = L; }
if (first_to_move) ca::get(0,iy) = first_state;
}
break;
}
case 2: { // down
for (int ix=0;ix<nx;ix++) {
int first_state = ca::get(ix,ny-1);
bool first_to_move = false;
if (ca::group[ca::xy1d(ix,ny-1)] == label) { ca::get(ix,ny-1) = L; first_to_move = true; }
for (int iy=ny-2;iy>=0;iy--)
if (ca::group[ca::xy1d(ix,iy)] == label) { ca::get(ix,iy+1) = ca::get(ix,iy); ca::get(ix,iy) = L; }
if (first_to_move) ca::get(ix,0) = first_state;
}
break;
}
case 3: { // left
for (int iy=0;iy<ny;iy++) {
int first_state = ca::get(0,iy);
bool first_to_move = false;
if (ca::group[ca::xy1d(0,iy)] == label) { ca::get(0,iy) = L; first_to_move = true; }
for (int ix=1;ix<nx;ix++)
if (ca::group[ca::xy1d(ix,iy)] == label) { ca::get(ix-1,iy) = ca::get(ix,iy); ca::get(ix,iy) = L; }
if (first_to_move) ca::get(nx-1,iy) = first_state;
}
break;
}
}
groups_found = false;
}
public:
static NLE_sqr4_CA* create(int nx,int ny,int ns = 1) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment