int main()
{
	using namespace Graph_lib;
	Simple_window win {Point{100, 100}, 800, 600, "Exercise 9"};
	Checker ck {50};
	ck.set_color(Color::green);

	Circle c {Point{200, 200}, 30};
	c.set_color(Color::black);
	c.set_fill_color(Color::white);

	Rectangle r {Point{100, 50}, 30, 40};
	r.set_color(Color::red);
	r.set_fill_color(Color::yellow);

	ck.add_shape(c);
	ck.add_shape(r);
	ck.move(0, 4, 1);
	ck.move(1, 5, 3);
	win.attach(ck);
	win.attach(ck.shape(0));
	win.attach(ck.shape(1));

	win.wait_for_button();
}
Exemple #2
0
std::pair<std::shared_ptr<Node>, boost::optional<Status>>
createNode(const Status& originalStatus, Point p, Point d,
        const std::shared_ptr<Node>& base, NodeFactory& nodeFactory,
        const HeurCalculator& heurCalculator, const Checker& checker,
        Dumper* dumper)
{
    Point pd = p+d, pmd = p-d;
    if (originalStatus.value(pd) != FieldType::floor ||
            !originalStatus.reachable(pmd)) {
        return {};
    }

    Status status(originalStatus);
    status.currentPos(p);
    if (heurCalculator.calculateStone(status, pd) < 0 ||
            !status.moveStone(p, pd)) {
        return {};
    }

    auto doCreateNode =
            [&]() {
                return nodeFactory.createNode(
                        status, MoveDescriptor(p, d), base);
            };
    if (pd != status.table().destination()) {
        if (!checker.check(status, pd)) {
            if (dumper) {
                dumper->reject(doCreateNode(), checker.errorMessage());
            }
            return {};
        }
    }

    return {doCreateNode(), std::move(status)};
}
Checker* ThermalModelSimple::getChecker() const
{
  Checker *check = ThermalModel::getChecker();
  check->addBlock("updraft", new OneOrMore());
  check->addChecker("updraft", Updraft::getChecker());
  return check;
}
void QProxyCheckerLib::checkProxy(ProxyItem::ProxyType proxyType, QString hostname, int port,
                                  QString username, QString password)
{
    ProxyItem* proxyItem = new ProxyItem(proxyType, hostname, port, username, password, this);
    QObject::connect(proxyItem, SIGNAL(checkingStatusChanged(ProxyItem*, ProxyItem::CheckingStatus)),
                     this, SLOT(checkingStatusChanged(ProxyItem*, ProxyItem::CheckingStatus)));
    Checker* checker = new Checker(proxyItem, this);
    checker->start();
}
Checker *ControllerSimpleGlider::controllerFileChecker() const {
  //! \Note Dummy
  Checker *ret = new Checker();
	ret->addProperty("speed", new NTimes(1));
	ret->addProperty("min_wp_dist", new NTimes(1));
	ret->addBlock("flight_plan", new NTimes(1));
	FlightPlan fp;
	ret->addChecker("flight_plan", fp.getFlightPlanChecker());
	return ret;
}
Checker* FireworksConfig::getChecker()
{
  Checker *check = CostConfig::getConfigChecker();
  
  check->addProperty("am", new NTimes(1));
  check->addProperty("bm", new NTimes(1));
  check->addProperty("mm", new NTimes(1));
  check->addProperty("m", new NTimes(1));
  
  return check;
}
Checker* TemporalConstrain::getChecker()
{
  Checker *check = new Checker;
  
  check->addProperty("min_time", new NTimes(1));
  check->addProperty("max_time", new NTimes(1));
  check->addProperty("updraft_id", new NTimes(1));
  check->addProperty("uav_id", new NTimes(1));
  
  return check;
}
Exemple #8
0
void repair()
{
    w.loadFileStructure();
    ch.analyze();
    if(ch.getErrorCount() > 0)
    {
        if(ch.repair(true)==0)
        {
            repair();
        }
    }
}
Exemple #9
0
void graph(Checker &checker, const Params &params) {
	int ri = roundf(checker.radius);
	if (fabs(checker.radius - ri) > 1e-5) return;

	bool is_power_of_two = false;
	for(int i = 1; i <= 4096; i *= 2)
		if (ri == i) is_power_of_two = true;

	if (!is_power_of_two && ri%16 != 0)
		return;

	checker.check2(params);
	checker.graph(strprintf("iir_%04d.tga", ri));
}
Exemple #10
0
void printStatus()
{
    w.loadFileStructure();
    ch.analyze();
    int errors = ch.getErrorCount();
    cout << "Status: ";
    if (errors > 0)
    {
        cout << errors << " errors found, run flexdir -r to repair" << endl;
    }
    else
    {
        cout << "OK" << endl;
    }
}
Exemple #11
0
int main(int argc,char **argv){
  FILE *fin;
  if((fin = fopen("zenkana.sjis","r")) == NULL){
	printf("File open Error.\n");
	exit(255);
  }
  char *inputstring = new char[1024];
  fscanf(fin,"%s",inputstring);
  strcat(inputstring,"\n");
  Checker *ip = new FastChecker();
  printf("%d",ip->ChkCoding((unsigned char*)inputstring));
  delete ip;
  fclose(fin);
  return(0);
}
Exemple #12
0
  void checkAll() {

    colliding.clear();
    colliding.resize(objects.size(), false);
    reports.clear();

    Report report;

    size_t queries = 0;
    TimeStamp start = TimeStamp::now();

    for (size_t i=0; i<objects.size(); ++i) {
      Convex* c1 = objects[i];
      for (size_t j=0; j<i; ++j) {
        Convex* c2 = objects[j];
        bool collides = checker.query(qtype, &report, c1, c2, dmin);
        ++queries;
        if (collides) { 
          colliding[i] = colliding[j] = true;
        }
        if (report.flags & (HAVE_POSITION | HAVE_SEPARATION)) {
          reports.push_back(report);
        }
      }
    }

    TimeStamp end = TimeStamp::now();
    double elapsed = (end-start).toDouble();

    if (1) {
      std::cout << "did " << queries << " queries in " << elapsed << "s. "
                << "(" << (elapsed/queries) << " per query)\n";
    }

  }
Exemple #13
0
void printFileStructure()
{
    w.loadFileStructure();
    w.getPoolSizes();
    ch.analyze();
    w.printFileStructure();
}
Exemple #14
0
	double find() {
		for(int j = 0; j < 3; ++j)
			root.current.k[j] = 0.5*(root.max.k[j] - root.min.k[j]) + root.min.k[j];
		root.value = checker.check2(root.current);
		best = root.value;
		return root.find();
	}
Exemple #15
0
double find_near(Checker &checker, double step, Params &params) {
	double best_value = checker.check2(params);
	Params best_params = params;
	while(true) {
		bool found = false;
		for(int i = 0; i < 3; ++i) {
			for(int j = -1; j <= 1; j += 2) {
				Params p = params;
				p.k[i] += j*step;
				double v = checker.check2(p);
				if (v < best_value) { best_value = v; best_params = p; }
			}
		}
		if (found) params = best_params; else break;
	}
	return best_value;
}
bool Checker::hasJump(Checkers::DirectionType dir)
{
	Square* neighbor = Checkers::getNeighborSquare(m_square, dir);
	if (neighbor != nullptr)
	{
		Checker* checker = neighbor->getChecker();
		if (checker != nullptr && checker->getColor() != m_myColor)
		{
			Square* jumpSquare = Checkers::getNeighborSquare(neighbor, dir);
			if (jumpSquare != nullptr && jumpSquare->getChecker() == nullptr)
			{
				return true;
			}
		}
	}
	return false;
}
Exemple #17
0
void Point::dropEvent(QDropEvent * event) {
  if (event->mimeData()->hasFormat("application/x-backgammon-checkerdrop")) {
    int thisCheckersColor = ((Checker*) event->source())->getMyColor();
    if ((getCheckersNo() < 2) || (thisCheckersColor == checkersColor())) {
      event->acceptProposedAction();
      Checker *thisChecker = (Checker*) event->source();
      thisChecker->getMyPlace()->removeChecker();
      if ((getCheckersNo() == 1) && (thisCheckersColor != checkersColor())) { //hit
	emit killedChecker(topChecker());
	removeChecker();
      }
      addChecker(thisChecker);
    } else
      event->ignore();
  } else
    event->ignore();
}
Exemple #18
0
static PyObject*
CallChecker(PyObject *self, PyObject *args)
{
	unsigned char *str;
	int type;
	int len;
	Codes ret;
	PyObject *pret;

	Checker *op;
	if(!PyArg_ParseTuple(args, "is#", &type, &str, &len)){
		return NULL;
	}
	op = CheckerTable[type]();
	ret = op->ChkCoding(str, len);
	pret = Py_BuildValue("i", ret);
	delete op;
	return pret;
};
Exemple #19
0
void Grid::SelectCheker(Checker::CheckerColor clr)
{
	Checker* checker;
	for(int i = 0; i < _cells.size(); i++)
	{
		if(checker = GetChecker(_cells[i]))
		{
			if(checker->GetColor()==clr)
			{
				checker->GetCell()->AddComponent(new CheckerFlushCellComponent);
			}
			else if(checker->GetColor()!=clr)
			{
				checker->GetCell()->EraseComponent(new CheckerFlushCellComponent);
			}
		}
		else _cells[i]->EraseComponent(new CheckerFlushCellComponent);
	}
}
Exemple #20
0
 void
 close()
 {
     if (work_)
     {
         work_ = boost::none;
         checker_.stop();
         m_logic.stop();
     }
 }
Exemple #21
0
int main(int argc, char *argv[]) {

  //MPI_Init(&argc, &argv);
  //MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
  
  Graph *g; int *terminal_set;
  int terminal_set_size;
  if (argc != 2 || read_input(g, terminal_set, terminal_set_size,
    argv[1]) != 0) {
    if (my_rank == 0)
      std::cout << "Program error, missing name of input file." << std::endl;
    return 1;
  }
  
  if (my_rank != 0) {
    //MPI_Finalize();
    return 0;
  }

  /* Vytvoreni zadani ulohy podle vstupu */  
  Checker *checker = new Checker(g, terminal_set, terminal_set_size);
  solve(checker);
  
  // Print Result somehow
  Graph *r = g->create_induced_subgraph(checker->get_best_vertices(),
    checker->get_best_size());
  r->remove_cycles();
  print_graph(r, checker->get_best_vertices(), checker->get_best_size());
  delete(r);
  /* Vytvoreni zadani ulohy podle vstupu - konec */  
  
  delete(checker);
  if (g != NULL)
    delete(g);
  if (terminal_set != NULL)
    delete(terminal_set);  
  
  
  // MPI_Finalize();
}
Exemple #22
0
int main(int argc, char *argv[]) {
  Graph *g; int *terminal_set;
  int terminal_set_size;
  if (argc != 2 || read_input(g, terminal_set, terminal_set_size,
    argv[1]) != 0) {
    printf("Program error");
    return 1;
  }

  /* Vytvoreni zadani ulohy podle vstupu */  
  Checker *checker = new Checker(g, terminal_set, terminal_set_size);
  solve(checker);
  checker->print_parent();
  checker->remove_cycles_from_best();
  checker->print_best();
  delete(checker);
  if (g != NULL)
    delete(g);
  if (terminal_set != NULL)
    delete(terminal_set);  
  /* Vytvoreni zadani ulohy podle vstupu - konec */
}
Exemple #23
0
PyObject * kconv_mod_ChkCoding(PyObject *self,PyObject *args,PyObject *keywds){
  //デフォルト値の読み込み。一度だけ行なう
  if(_DEFAULT_INPUT_CODING == _UNKNOWN)
	_load_defaults();

  int cm = _UNDEFINED;
  unsigned char *input_string;
  unsigned int string_length;
  static char *kwlist[] = {"str",
						   "checkmode",
						   NULL};
  if(!PyArg_ParseTupleAndKeywords(args,keywds,"s#|i",kwlist,
								  &input_string,&string_length,&cm))
	return NULL;
  //デフォルトの値設定
  if(cm == _UNDEFINED)//入力コード判別ルーチン選択
	cm = _DEFAULT_CHECK_MODE;
  
  Checker *pchecker = CheckerTable[cm]();
  Codes ret = pchecker->ChkCoding(input_string,string_length);
  delete pchecker;
  return(Py_BuildValue("i",ret));
}
Exemple #24
0
int main(int argc, char **argv)
{
  char word[MAX_LENGTH + 1], matchingWords[100][MAX_LENGTH + 1];
  int numWords, count;
  DictionaryWord *words = readWordsFile();
  MatchingWords *matchingWordsKey = readTesterFile(argv[1], &numWords);
  CPUTimer ct;
  Checker *checker = new Checker((const DictionaryWord*) words, NUM_WORDS);
  delete words; 

  for(int i = 0; i < numWords; i++)
  {
    strcpy(word, matchingWordsKey[i].word);
    checker->findWord(word, matchingWords, &count);
      
    if(count != matchingWordsKey[i].count)
    {
      cout << "Incorrect count for trial# " << i << " for " 
        << matchingWordsKey[i].word << " should be " 
        << matchingWordsKey[i].count << " but received " << count << endl;
    }
    else // correct count
    {
      for(int j = 0; j < count; j++)
        if(strcmp(matchingWordsKey[i].matches[j], matchingWords[j]) != 0)
        {
          cout << "Words don't match for trial# " << i << " for "
             << matchingWordsKey[i].word << " match# " << j << " should be " 
             << matchingWordsKey[i].matches[j] << " but received " 
             << matchingWords[j] << endl;
        } // if invalid match
    } // else correct count
  }  // for each word
  
  cout << "CPU Time: " << ct.cur_CPUTime() << endl;
  return 0;
}
Exemple #25
0
int main(int argc, char * argv[])
{
    //print log entries
    w.getSettings()->verbose = true;
    //print help message when no arguments
    if (argc == 1)
    {
        printHelp();
    }
    else
    {
        for (int i = 1; i < argc; i++)
        {
            string arg = (string)argv[i];
            if (arg == "-d")
            {
                ch.debug();
            }
            else if (arg == "-t")
            {
                w.printSettings();
            }
            else if (arg == "-f")
            {
                printFileStructure();
            }
            else if (arg == "-h")
            {
                printHelp();
            }
            else if (arg == "-s")
            {
                printStatus();
            }
            else if (arg == "-r")
            {
                repair();
            }
            else if (arg == "-y")
            {
                resync();
            }
        }
    }
    return 0;
}
Exemple #26
0
Checker* CostConfig::getConfigChecker()
{
	Checker *check = new Checker;
	check->addProperty("population", new NTimes(1));
	check->addProperty("generations", new NTimes(1));
	check->addProperty("waypoint_dimension", new NTimes(1));
	check->addProperty("intermediate_waypoints", new NTimes(1));
	
	Checker *bound_checker = new Checker;
	
	bound_checker->addProperty("upper", new NTimes(1));
	bound_checker->addProperty("lower", new NTimes(1));
	
	check->addBlock("bounds", new NTimes(1));
	check->addChecker("bounds", bound_checker);
	
	Checker *cost_check = new Checker;
	cost_check->addProperty("distance", new NTimes(1));
	cost_check->addProperty("collision_penalty", new NTimes(1));
	check->addChecker("cost", cost_check);
	check->addBlock("cost", new NTimes(1));
	
	return check;
}
Exemple #27
0
int main(void)
{
    try
    {
        log_open("run.log");
        FM_LOG_DEBUG("opened");
        com.init();
        cout << "after init!!" << endl;
        com.compile();
        cout << com.getResult() << endl;
        if(string("Compile Error") == com.getResult())
        {
            return 0;
        }
        cout << "after compile" << endl;

        Exec.execute();
        cout << "after execute" << endl;

        int result = checker.checkDiff();
        if(result == 0)
        {
            cout << "AC" << endl;
        }
        else if(result == 1)
        {
            cout << "PE" << endl;
        }
        else if(result == 2)
        {
            cout << "WA" << endl;
        }
    }
    // catch(exception &ex)
    // {
    // 	cout << ex.what() << endl;
    // }
    catch(JudgeException &ex)
    {
        cout << ex.what() << endl;
    }
    return 0;
}
Exemple #28
0
int main(int argc, char* argv[])
{
  (void) argc;
  (void) argv;

  typedef lcp::BasicChecker<int, int> Checker;
//  typedef Checker::Deadlock Deadlock;

  try
  {
    int A = 1;
    int B = 2;
    int C = 3;
//    int X1 = 11;
//    int X2 = 12;
//    int X3 = 13;

    int t1 = 1;
    int t2 = 1;
    int t3 = 3;

    Checker c;

    c.OnMutexLock(A, t1);
    c.OnMutexLock(B, t1);
    c.OnMutexUnlock(B, t1);
    c.OnMutexUnlock(A, t1);

    c.OnMutexLock(B, t2);
    c.OnMutexLock(C, t2);
    c.OnMutexUnlock(C, t2);
    c.OnMutexUnlock(B, t2);

    c.OnMutexLock(C, t3);
    c.OnMutexLock(A, t3);
    c.OnMutexUnlock(A, t3);
    c.OnMutexUnlock(C, t3);
}
  catch(const std::exception& e)
  {
    printf("%s\n", e.what());
  }

  return EXIT_SUCCESS;
}
// just gets the first jump it finds for now
Checkers::Move MoveMaker::getJump()
{
	Checkers::Move move = {Checkers::SW, 22};
	vector<Checker*> myCheckers = m_board.getComputerCheckers();
	vector<Checker*>::iterator it;
	for (it = myCheckers.begin(); it != myCheckers.end(); ++it)
	{
		Checker* checker = *it;
		Square* sq = (*it)->getSquare();

		Square* neighbor = sq->getSW();
		if (neighbor != nullptr && neighbor->getChecker() != nullptr)
		{
			Checker* neighborChecker = neighbor->getChecker();
			if (neighborChecker->getColor() == Checkers::RED)
			{
				Square* jumpSquare = neighbor->getSW();
				if (jumpSquare != nullptr && jumpSquare->getChecker() == nullptr)
				{
					move.index = checker->getIndex();
					move.dir = Checkers::SW;
					break;
				}
			}
		}
		neighbor =sq->getSE();
		if (neighbor != nullptr && neighbor->getChecker() != nullptr)
		{
			Checker* neighborChecker = neighbor->getChecker();
			if (neighborChecker->getColor() == Checkers::RED)
			{
				Square* jumpSquare = neighbor->getSE();
				if (jumpSquare != nullptr && jumpSquare->getChecker() == nullptr)
				{
					move.index = checker->getIndex();
					move.dir = Checkers::SE;
					break;
				}
			}
		}
	}
	return move;
}
void BeCheckersWindow::SaveGame(const char *file) {
	ofstream outGame(file, ios::out);
	if(!outGame)
		(new BAlert("SaveError",
					"Error while saving BeCheckers game.",
					"Okay", NULL, NULL,
					B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
	else {
		Checker *c = (Checker *)cb->ChildAt(0);
		outGame << Checker::Turn()			<< ' '
				<< Checker::PrevDist()		<< ' '
				<< Checker::JumpAvailable() << ' '
				<< Checker::CheckerJumping().x << ' '
				<< Checker::CheckerJumping().y << endl;
		while(c) {
			outGame << c->Square().x << ' ' << c->Square().y << ' '
					<< c->Color()	 << ' ' << c->Rank()	 << endl;
			c = (Checker *)c->NextSibling();
		}
	}
}