Beispiel #1
0
/* int Dstar::computeShortestPath()
 * --------------------------
 * As per [S. Koenig, 2002] except for 2 main modifications:
 * 1. We stop planning after a number of steps, 'maxsteps' we do this
 *    because this algorithm can plan forever if the start is
 *    surrounded by obstacles. 
 * 2. We lazily remove states from the open list so we never have to
 *    iterate through it.
 */
int Dstar::computeShortestPath() {
  
  list<state> s;
  list<state>::iterator i;

  if (openList.empty()) return 1;

  int k=0;
  while ((!openList.empty()) && 
         (openList.top() < (calculateKey(s_start))) || 
         (!isConsistent(s_start))) {

    if (k++ > maxSteps) {
      fprintf(stderr, "At maxsteps\n");
      return -1;
    }
    
    
    state u;
    
    // check consistency (one of the loop conditions)
    bool test = isConsistent(s_start);
    //(getRHS(s_start) != getG(s_start));
    
    // lazy remove
    while(1) { 
      if (openList.empty()) return 1; // checks outer loop condition #1
      u = openList.top();
      
      if (!queuePop()) continue;
      
      if (!(u < s_start) && test) return 2; // checks outer loop conditions #2,3 still hold
    
      break;
    }
    
    state k_old = u;

    if (k_old < calculateKey(u)) { // u is out of date
      insert(u); // u has been removed already, reinsert into pq with new key
    } else if (getG(u) > getRHS(u)) { // needs update (got better)
      setG(u,getRHS(u));
      getPred(u,s);
      for (i=s.begin();i != s.end(); i++) {
        updateVertex(*i);
      }
    } else {   // g <= rhs, state has got worse
      setG(u,INFINITY);
      getPred(u,s);
      for (i=s.begin();i != s.end(); i++) {
        updateVertex(*i);
      }
      updateVertex(u);
    }
  }
  return 0;
}
Beispiel #2
0
void
SoXipPolygon::mouseDown( const SbVec3f& newPos )
{
	if( !isEditing() )
	{
		if( point.getNum() == 0 )
			point.set1Value( point.getNum(), newPos );

		// If the shape can be closed and is consitent (big enough)
		if( canClose( newPos ) && isConsistent() )
		{
			closed.setValue( TRUE );

			// Remove the last point corresponding to the moving point.
			point.setNum( point.getNum() - 1 );

			// Creation is done
			status.setValue( NONE );
		}
		else
		{
			point.set1Value( point.getNum(), newPos );
		}
	}
}
Beispiel #3
0
void
SoXipPolygon::mouseUp( const SbVec3f& newPos )
{
	if( isEditing() )
		return ;

	// If the shape can be closed and is consitent (big enough)
	if( canClose( newPos ) && isConsistent() )
	{
		closed.setValue( TRUE );

		// Remove the last point corresponding to the moving point.
		point.setNum( point.getNum() - 1 );

		// Creation is done
		status.setValue( NONE );
	}
	
	// If user keeps the mouse button pressed, then a point should
	// be added when the mouse is released.
	// But to prevent artefact points due to a fast click & move,
	// point are only added if the event is not considered as a
	// click.
	else if( (mMouseUpTime - mMouseDownTime) > mClickTime )
	{
		if (*point.getValues(point.getNum() - 1) != newPos)
			point.set1Value( point.getNum(), newPos );
	}	
}
Beispiel #4
0
SVSet& SVSet::operator=(const SVSet& rhs)
{
   if (this != &rhs)
   {
      clear();

      if (rhs.size() > 0)
      {
         DataArray < SVector::Element > ::operator=(rhs);
         set = rhs.set;

         DLPSV* ps;
         DLPSV* newps;

         void* delta0 = &(*(static_cast<SVSetBase*>(this)))[0];
         void* delta1 = &(*(static_cast<SVSetBase*>(
            const_cast<SVSet*>(&rhs))))[0];
         ptrdiff_t delta = reinterpret_cast<char*>(
            delta0) - reinterpret_cast<char*>(delta1);

         for (ps = rhs.list.first(); ps; ps = rhs.list.next(ps))
         {
            newps = & set[ rhs.number(ps) ];
            list.append(newps);
            newps->setMem(ps->max() + 1, 
               reinterpret_cast<SVector::Element*>(
                  reinterpret_cast<char*>(ps->mem()) + delta));
            newps->set_size( ps->size() );
         }
      }
   }
   assert(isConsistent());

   return *this;
}
Beispiel #5
0
	void Txtr::loadAlpha(const fschar *fileName, gl_ubyte defaultAlpha, bool initialize)
	{	
		dAssert(isConsistent());
		dAssert(!hasImage() || !initialize);
		
		gl_uint w;
		gl_uint h;	
		Pixel3 *colorPixels = loadFile(fileName, &w, &h);
		if (colorPixels)
		{
			if (initialize)
			{
				width = w;
				height = h;
				pixels = new Pixel4[w*h];
			}

			if ((w == width) && (h == height))
			{
				for(uint i=0; i<width*height; ++i)
				{
					//pixels[i].a = static_cast<GLubyte>(colorPixels[i].getBWColor() / 3);
					pixels[i].a = colorPixels[i].getBWColor();
				}
			}
			else
			{
				for(uint i=0; i<width*height; ++i)
				{
					pixels[i].a = defaultAlpha;
				}
			}
			delete[] colorPixels;
		}
	}
Beispiel #6
0
	void Txtr::loadColors(const fschar *fileName, bool initialize)
	{
		dAssert(isConsistent());
		dAssert(!hasImage() || !initialize);

		gl_uint w;
		gl_uint h;
		Pixel3 *colorPixels = loadFile(fileName, &w, &h);
		//Pixel3 *colorPixels = loadFile(fileName, &height, &width);
		if (colorPixels)
		{
			if (initialize)
			{
				width = w;
				height = h;
			}
			
			if ((w == width) && (h == height))
			{
				uint size = width*height;
				pixels = new Pixel4[size];
				for(uint i=0; i<size; ++i)
				{
					pixels[i].r = colorPixels[i].r;
					pixels[i].g = colorPixels[i].g;
					pixels[i].b = colorPixels[i].b;
				}
			}

			delete[] colorPixels;
			
		}
	}
Beispiel #7
0
Vec3f TraceBase::bsdfSample(const Primitive &light,
                            SurfaceScatterEvent &event,
                            const Medium *medium,
                            int bounce,
                            const Ray &parentRay)
{
    event.requestedLobe = BsdfLobes::AllButSpecular;
    if (!event.info->bsdf->sample(event, false))
        return Vec3f(0.0f);
    if (event.weight == 0.0f)
        return Vec3f(0.0f);

    Vec3f wo = event.frame.toGlobal(event.wo);
    if (!isConsistent(event, wo))
        return Vec3f(0.0f);

    bool geometricBackside = (wo.dot(event.info->Ng) < 0.0f);
    medium = event.info->primitive->selectMedium(medium, geometricBackside);

    Ray ray = parentRay.scatter(event.info->p, wo, event.info->epsilon);
    ray.setPrimaryRay(false);

    IntersectionTemporary data;
    IntersectionInfo info;
    Vec3f e = attenuatedEmission(*event.sampler, light, medium, -1.0f, data, info, bounce, true, ray, nullptr);

    if (e == Vec3f(0.0f))
        return Vec3f(0.0f);

    Vec3f bsdfF = e*event.weight;

    bsdfF *= SampleWarp::powerHeuristic(event.pdf, light.directPdf(_threadId, data, info, event.info->p));

    return bsdfF;
}
Beispiel #8
0
int SPxWeightPR::selectLeave()
{
   const Real* test = thesolver->fTest().get_const_ptr();
   Real type = 1 - 2 * (thesolver->rep() == SPxSolver::COLUMN ? 1 : 0);
   Real best = type * infinity;
   int lastIdx = -1;
   Real x;
   int i;

   for (i = solver()->dim() - 1; i >= 0; --i)
   {
      x = test[i];
      if (x < -theeps)
      {
         x *= leavePenalty[i];
         if (type * (x-best) < 0.0)
         {
            best = x;
            lastIdx = i;
         }
      }
   }
   assert(isConsistent());
   return lastIdx;
}
Beispiel #9
0
Vector& Vector::assign(const SVector& psv)
{
   for (int i = psv.size(); i-- > 0;)
      val[psv.index(i)] = psv.value(i);

   assert(isConsistent());
      
   return *this;
}
Beispiel #10
0
Vector& Vector::operator=(const SVector& vec)
{
   clear();
   assign(vec);

   assert(isConsistent());

   return *this;
}
Beispiel #11
0
/**@todo suspicious: Shouldn't the relation between dim, coDim, Vecs, 
 *       and CoVecs be influenced by the representation ?
 */
void SPxDevexPR::setRep(SPxSolver::Representation)
{
   if (thesolver != 0)
   {
      addedVecs(thesolver->coDim());
      addedCoVecs(thesolver->dim());
      assert(isConsistent());
   }
}
Beispiel #12
0
Vector& Vector::operator=(const Vector& vec)
{
   if (this != &vec)
   {
      assert(dim() == vec.dim());
      memcpy(val, vec.val, dimen*sizeof(Real));

      assert(isConsistent());
   }
   return *this;
}
/*
 =======================================================================================================================
    test the answer state for validity, returns string "True" or "False"
 =======================================================================================================================
 */
char *testAnswer(State *resultState, long numberCompanies, long numberBlocks)
{
    if(isConsistent(resultState, numberCompanies, numberBlocks) && testValue(resultState))
    {
        return "True";
    }
    else
    {
        return "False";
    }
}
Beispiel #14
0
bool MDSCHEMA_LEVELS::processValue(Restrictions restrictions,Properties properties){
	processProperties(properties);

	vector<MeasureList> measures;
	string catalogn="";
	string cuben="";

	//properties有指定Catalog
	if(this->Catalog!="")
		catalogn=Catalog;
	else{
		Restrictions::iterator catalognIt=restrictions.find(CATALOG_NAME);
		//有CATALOG_NAME约束
		if(catalognIt!= restrictions.end()){
			catalogn=catalognIt->second;
		}
	}
 	
	Restrictions::iterator cubenIt=restrictions.find(CUBE_NAME);
	//有CUBE_NAME约束
	if(cubenIt!=restrictions.end()){
		cuben=cubenIt->second;
	}

	
	measures=XSchemas::instance().getMeasures(catalogn,cuben);
	for(int j=0;j<measures.size();j++){
		Row measureRow=getRowM(measures[j]);
		if(isConsistent(measureRow,restrictions))
			rows.push_back(measureRow);
	}

	vector<Level*> levels=this->getRestrictLevel(restrictions);
	
	for(int i=0;i<levels.size();i++){
		Row row=getRow(levels[i]);
		if(isConsistent(row,restrictions))
			rows.push_back(row);
	}
	return true;
}
Beispiel #15
0
bool TraceBase::handleSurface(SurfaceScatterEvent &event, IntersectionTemporary &data,
                              IntersectionInfo &info, const Medium *&medium,
                              int bounce, bool adjoint, bool enableLightSampling, Ray &ray,
                              Vec3f &throughput, Vec3f &emission, bool &wasSpecular,
                              Medium::MediumState &state, Vec3f *transmittance)
{
    const Bsdf &bsdf = *info.bsdf;

    // For forward events, the transport direction does not matter (since wi = -wo)
    Vec3f transparency = bsdf.eval(event.makeForwardEvent(), false);
    float transparencyScalar = transparency.avg();

    Vec3f wo;
    if (event.sampler->nextBoolean(transparencyScalar) ){
        wo = ray.dir();
        event.pdf = transparencyScalar;
        event.weight = transparency/transparencyScalar;
        event.sampledLobe = BsdfLobes::ForwardLobe;
        throughput *= event.weight;
    } else {
        if (!adjoint) {
            if (enableLightSampling && bounce < _settings.maxBounces - 1)
                emission += estimateDirect(event, medium, bounce + 1, ray, transmittance)*throughput;

            if (info.primitive->isEmissive() && bounce >= _settings.minBounces) {
                if (!enableLightSampling || wasSpecular || !info.primitive->isSamplable())
                    emission += info.primitive->evalDirect(data, info)*throughput;
            }
        }

        event.requestedLobe = BsdfLobes::AllLobes;
        if (!bsdf.sample(event, adjoint))
            return false;

        wo = event.frame.toGlobal(event.wo);

        if (!isConsistent(event, wo))
            return false;

        throughput *= event.weight;
        wasSpecular = event.sampledLobe.hasSpecular();
        if (!wasSpecular)
            ray.setPrimaryRay(false);
    }

    bool geometricBackside = (wo.dot(info.Ng) < 0.0f);
    medium = info.primitive->selectMedium(medium, geometricBackside);
    state.reset();

    ray = ray.scatter(ray.hitpoint(), wo, info.epsilon);

    return true;
}
/*
 =======================================================================================================================
    generate a new state for starting the next instance of climbing
 =======================================================================================================================
 */
void genRandomConsistentState
(
    State	**startState,
    long	noOfBids,
    long	numberCompanies,
    long	numberBlocks,
    float	*p,
    long	timeInSeconds
)
{
    freeStateObject(startState);
    initStateObject(startState, noOfBids);

    /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    /*
     * printf("** %ld **", timeInSeconds);
     * code related to time from man pages
     */
    struct timespec startTW, currentTW;
    /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

    clock_gettime(CLOCK_MONOTONIC, &startTW);

    do
    {
        clock_gettime(CLOCK_MONOTONIC, &currentTW);
        if(currentTW.tv_sec - startTW.tv_sec >= timeInSeconds)
        {
            freeStateObject(startState);
            initStateObject(startState, noOfBids);
            (*p) /= 2;
            break;
        }

        genRandomBoolList((*startState)->allocList, noOfBids, *p);
    } while(!isConsistent((*startState), numberCompanies, numberBlocks));

    /*~~~~~~~~~~~~~~~~~~~~~~~*/
    long	i;
    Bid		*currentBid = NULL;
    /*~~~~~~~~~~~~~~~~~~~~~~~*/

    for(i = 0; i < (*startState)->lenAllocList; i++)
    {
        if((*startState)->allocList[i])
        {
            currentBid = bidList[i];
            (*startState)->value += currentBid->amount;
        }
    }

    initGlobals(*startState, numberCompanies, numberBlocks);
}
Beispiel #17
0
uint256
getBookBase (Book const& book)
{
    assert (isConsistent (book));
    // Return with quality 0.
    return getQualityIndex(sha512Half(
        std::uint16_t(spaceBookDir),
        book.in.currency,
        book.out.currency,
        book.in.account,
        book.out.account));
}
Beispiel #18
0
Vector& Vector::operator=(const Vector_exact& vec)
{
   assert(dim() == vec.dim());

   for( int i = 0; i < dim(); i++ )
   {
      val[i] = get_d(vec[i]);
   }

   assert(isConsistent());

   return *this;
}
Beispiel #19
0
Vector_exact& Vector_exact::operator=(const Vector& vec)
{
   assert(dim() == vec.dim());

   for( int i = 0; i < dimen; i++ )
   {
      val[i] = vec[i];
   }

   assert(isConsistent());

   return *this;
}
Beispiel #20
0
Vector_exact& Vector_exact::operator=(const SVector& psv)
{
   clear();

   for( int i = 0; i < psv.size(); i++ )
   {
      assert(psv.index(i) < dim());
      val[psv.index(i)] = psv.value(i);
   }

   assert(isConsistent());

   return *this;
}
Beispiel #21
0
bool 
Unifier::isConsistent(Unifier& u2) 
{ 
  MultimapStr::iterator u_pos; 
  MultimapStr u2_unifier = u2.unifier; 
  for (u_pos = u2_unifier.begin(); u_pos != u2_unifier.end(); u_pos++) 
    { 
      if ((strVar(u_pos->first) && (!strVar(u_pos->second))) && (!isConsistent(u_pos->first, u_pos->second))) 
	{ 
	  return false; 
	}					 
    } 
  return true; 
} 
Beispiel #22
0
	bool Txtr::removeImage()
	{
		dAssert(isConsistent());
		
		if (hasImage())
		{
			delete[] pixels;
			pixels = nullptr;
			width = 0;
			height = 0;
			return true;
		}
		return false;
	}
Beispiel #23
0
	std::vector<Structure*> propagate(AbstractTheory* theory, Structure* structure) {
		// TODO: doens't work with cp support (because a.o.(?) backtranslation is not implemented)

		//Set MinisatID solver options
		auto data = SolverConnection::createsolver(0);

		auto clonetheory = theory->clone();
		auto result = structure->clone();
		auto voc = new Vocabulary("intern_voc");
		voc->add(clonetheory->vocabulary());
		result->changeVocabulary(voc);
		clonetheory->vocabulary(voc);

		auto grounding = GroundingInference<PCSolver>::doGrounding(clonetheory, result, NULL, NULL, NULL, true, data);

		auto mx = SolverConnection::initpropsolution(data);
		mx->execute();

		result->changeVocabulary(structure->vocabulary());

		auto translator = grounding->translator();
		auto entailed = mx->getEntailedLiterals();
		for (auto literal = entailed.cbegin(); literal < entailed.cend(); ++literal) {
			int atomnr = var(*literal);
			if (translator->isInputAtom(atomnr)) {
				auto symbol = translator->getSymbol(atomnr);
				auto args = translator->getArgs(atomnr);
				if (sign(*literal)) {
					result->inter(symbol)->makeFalseAtLeast(args);
				} else {
					result->inter(symbol)->makeTrueAtLeast(args);
				}
			}
		}
		result->clean();
		clonetheory->recursiveDelete();
		delete (voc);
		delete (data);
		delete (mx);

		if (not result->isConsistent()) {
			return std::vector<Structure*> { };
		}
		return {result};
	}
bool CFG::isInCNF() const
{
	// do this check within isInCNF or not?
	if (!isConsistent()) return false;

	for (const auto& rule : _rules) {
		if (rule.second.size() == 2) {
			if (rule.second.at(0).isTerminal() || rule.second.at(1).isTerminal()) {
				return false;
			}
		} else if (rule.second.size() == 1) {
			if (rule.second.at(0).isVariable()) {
				return false;
			}
		} else {
			return false;
		}
	}
	return true;
}
Beispiel #25
0
Vec3f TraceBase::lightSample(const Primitive &light,
                             SurfaceScatterEvent &event,
                             const Medium *medium,
                             int bounce,
                             const Ray &parentRay,
                             Vec3f *transmittance)
{
    LightSample sample;
    if (!light.sampleDirect(_threadId, event.info->p, *event.sampler, sample))
        return Vec3f(0.0f);

    event.wo = event.frame.toLocal(sample.d);
    if (!isConsistent(event, sample.d))
        return Vec3f(0.0f);

    bool geometricBackside = (sample.d.dot(event.info->Ng) < 0.0f);
    medium = event.info->primitive->selectMedium(medium, geometricBackside);

    event.requestedLobe = BsdfLobes::AllButSpecular;

    Vec3f f = event.info->bsdf->eval(event, false);
    if (f == 0.0f)
        return Vec3f(0.0f);

    Ray ray = parentRay.scatter(event.info->p, sample.d, event.info->epsilon);
    ray.setPrimaryRay(false);

    IntersectionTemporary data;
    IntersectionInfo info;
    Vec3f e = attenuatedEmission(*event.sampler, light, medium, sample.dist, data, info, bounce, true, ray, transmittance);
    if (e == 0.0f)
        return Vec3f(0.0f);

    Vec3f lightF = f*e/sample.pdf;

    if (!light.isDirac())
        lightF *= SampleWarp::powerHeuristic(sample.pdf, event.info->bsdf->pdf(event));

    return lightF;
}
Beispiel #26
0
void SPxDevexPR::init(SPxSolver::Type tp)
{
   int i;
   if (tp == SPxSolver::ENTER)
   {
      for (i = weights.dim(); --i >= 0;)
         weights[i] = 2;
      for (i = coWeights.dim(); --i >= 0;)
         coWeights[i] = 2;
      if( thesolver->hyperPricingEnter )
      {
         if( thesolver->sparsePricingEnter )
         {
            bestPrices.clear();
            bestPrices.setMax(thesolver->dim());
            prices.reMax(thesolver->dim());
         }
         if( thesolver->sparsePricingEnterCo )
         {
            bestPricesCo.clear();
            bestPricesCo.setMax(thesolver->coDim());
            pricesCo.reMax(thesolver->coDim());
         }
      }
   }
   else
   {
      for (i = coWeights.dim(); --i >= 0;)
         coWeights[i] = 1;
      if (thesolver->sparsePricingLeave && thesolver->hyperPricingLeave)
      {
         bestPrices.clear();
         bestPrices.setMax(thesolver->dim());
         prices.reMax(thesolver->dim());
      }
   }
   weightsAreSetup = true;
   assert(isConsistent());
}
Beispiel #27
0
bool TraceBase::surfaceLensSample(const Camera &camera,
                                  SurfaceScatterEvent &event,
                                  const Medium *medium,
                                  int bounce,
                                  const Ray &parentRay,
                                  Vec3f &weight,
                                  Vec2f &pixel)
{
    LensSample sample;
    if (!camera.sampleDirect(event.info->p, *event.sampler, sample))
        return false;

    event.wo = event.frame.toLocal(sample.d);
    if (!isConsistent(event, sample.d))
        return false;

    bool geometricBackside = (sample.d.dot(event.info->Ng) < 0.0f);
    medium = event.info->primitive->selectMedium(medium, geometricBackside);

    event.requestedLobe = BsdfLobes::AllButSpecular;

    Vec3f f = event.info->bsdf->eval(event, true);
    if (f == 0.0f)
        return false;

    Ray ray = parentRay.scatter(event.info->p, sample.d, event.info->epsilon);
    ray.setPrimaryRay(false);
    ray.setFarT(sample.dist);

    Vec3f transmittance = generalizedShadowRay(*event.sampler, ray, medium, nullptr, true, true, bounce);
    if (transmittance == 0.0f)
        return false;

    weight = f*transmittance*sample.weight;
    pixel = sample.pixel;

    return true;
}
Beispiel #28
0
LPRow::LPRow(const SVector& p_rowVector, LPRow::Type p_type, Real p_value)
   : vec(p_rowVector)
{
   switch (p_type)
   {
   case LESS_EQUAL:
      left = -infinity;
      right = p_value;
      break;
   case EQUAL:
      left = p_value;
      right = p_value;
      break;
   case GREATER_EQUAL:
      left = p_value;
      right = infinity;
      break;
   default:
      throw SPxInternalCodeException("XLPROW03 This should never happen.");
   }

   assert(isConsistent());
}
Beispiel #29
0
void Board::showStart(const Move& m, int step)
{
	int f, dir;
	int colorNew;

	if (boardOk) {
	  /* board ok means: board has the normal state before move */
	  CHECK( isConsistent() );
	  if (step == 0)
	    return;      /* nothing to be done */
	}
	boardOk = (step == 0) ? true:false;

	if (color == color1)
	  colorNew = (step==0) ? color1 : color1bright;
	else 
	  colorNew = (step==0) ? color2 : color2bright;

	f = m.field;

	/* first field */
	field[f] = colorNew;

	switch(m.type) {
	case Move::left3:
	case Move::right3:
	  dir = direction[m.direction];
	  field[f + dir] = colorNew;
	  field[f + 2*dir] = colorNew;
	  break;
	case Move::left2:
	case Move::right2:
	  dir = direction[m.direction];
	  field[f + dir] = colorNew;
	}
}
Beispiel #30
0
bool Board::takeBack()
{
    int f, dir, dir2;
    int opponent = color;
    Move& m = storedMove[storedLast];

    CHECK( isConsistent() );

    if (storedFirst == storedLast) return false;

    /* change actual color */
    color = (color == color1) ? color2:color1;
    moveNo--;

    if (m.isOutMove()) {
	if (color == color1)
	    color2Count++;
	else
	    color1Count++;
    }

    f = m.field;
    CHECK( field[f] == free );
    field[f] = color;
    dir = direction[m.direction];

    switch(m.type) {
    case Move::out2:        /* (. c c c o |) => (c c c o o |) */
	CHECK( field[f + dir] == color );
	CHECK( field[f + 2*dir] == color );
	CHECK( field[f + 3*dir] == color );
	CHECK( field[f + 4*dir] == opponent );
	CHECK( field[f + 5*dir] == out );
	field[f + 3*dir] = opponent;
	break;
    case Move::out1with3:   /* (. c c c |) => (c c c o |) */
	CHECK( field[f + dir] == color );
	CHECK( field[f + 2*dir] == color );
	CHECK( field[f + 3*dir] == color );
	CHECK( field[f + 4*dir] == out );
	field[f + 3*dir] = opponent;
	break;
    case Move::move3:       /* (. c c c) => (c c c .)     */
	CHECK( field[f + dir] == color );
	CHECK( field[f + 2*dir] == color );
	CHECK( field[f + 3*dir] == color );
	field[f + 3*dir] = free;
	break;
    case Move::out1with2:   /* (. c c | ) => (c c o |)     */
	CHECK( field[f + dir] == color );
	CHECK( field[f + 2*dir] == color );
	CHECK( field[f + 3*dir] == out );
	field[f + 2*dir] = opponent;
	break;
    case Move::move2:       /* (. c c) => (c c .)       */
	CHECK( field[f + dir] == color );
	CHECK( field[f + 2*dir] == color );
	field[f + 2*dir] = free;
	break;
    case Move::push2:       /* (. c c c o o) => (c c c o o .) */
	CHECK( field[f + dir] == color );
	CHECK( field[f + 2*dir] == color );
	CHECK( field[f + 3*dir] == color );
	CHECK( field[f + 4*dir] == opponent );
	CHECK( field[f + 5*dir] == opponent );
	field[f + 3*dir] = opponent;
	field[f + 5*dir] = free;
	break;
    case Move::left3:
	dir2 = direction[m.direction-1];
	CHECK( field[f + dir] == free );
	CHECK( field[f + 2*dir] == free );
	CHECK( field[f + dir2] == color );
	CHECK( field[f + dir+dir2] == color );
	CHECK( field[f + 2*dir+dir2] == color );
	field[f+dir2] = free;
	field[f+=dir] = color;
	field[f+dir2] = free;
	field[f+=dir] = color;
	field[f+dir2] = free;
	break;
    case Move::right3:
	dir2 = direction[m.direction+1];
	CHECK( field[f + dir] == free );
	CHECK( field[f + 2*dir] == free );
	CHECK( field[f + dir2] == color );
	CHECK( field[f + dir+dir2] == color );
	CHECK( field[f + 2*dir+dir2] == color );
	field[f+dir2] = free;
	field[f+=dir] = color;
	field[f+dir2] = free;
	field[f+=dir] = color;
	field[f+dir2] = free;
	break;
    case Move::push1with3:   /* (. c c c o) => (c c c o .) */
	CHECK( field[f + dir] == color );
	CHECK( field[f + 2*dir] == color );
	CHECK( field[f + 3*dir] == color );
	CHECK( field[f + 4*dir] == opponent );
	field[f + 3*dir] = opponent;
	field[f + 4*dir] = free;
	break;
    case Move::push1with2:   /* (. c c o) => (c c o .) */
	CHECK( field[f + dir] == color );
	CHECK( field[f + 2*dir] == color );
	CHECK( field[f + 3*dir] == opponent );
	field[f + 2*dir] = opponent;
	field[f + 3*dir] = free;
	break;
    case Move::left2:
	dir2 = direction[m.direction-1];
	CHECK( field[f + dir] == free );
	CHECK( field[f + dir2] == color );
	CHECK( field[f + dir+dir2] == color );
	field[f+dir2] = free;
	field[f+=dir] = color;
	field[f+dir2] = free;
	break;
    case Move::right2:
	dir2 = direction[m.direction+1];
	CHECK( field[f + dir] == free );
	CHECK( field[f + dir2] == color );
	CHECK( field[f + dir+dir2] == color );
	field[f+dir2] = free;
	field[f+=dir] = color;
	field[f+dir2] = free;
	break;
    case Move::move1:       /* (. c) => (c .) */
	CHECK( field[f + dir] == color );
	field[f + dir] = free;
	break;
    default:
	break;
    }

    if (--storedLast < 0) storedLast = MvsStored-1;

    CHECK( isConsistent() );

    return true;
}