Example #1
0
int main(int argc, char *argv[])
{
	vector<string>ground;
	getInput(ground);
	detectDeadSquare(ground);
	//showGround(ground);
	/*
	puts("1) Breadth first search");
	puts("2) Depth first search");
	puts("3) Uniform cost search");
	puts("4) Greedy best first search");
	puts("5) A* search");
	*/
	freopen("output.txt", "w", stdout);
	int choice;
	sscanf(argv[argc - 1], "%d", &choice);
	switch(choice) {
		case 1: BFS(ground); break;
		case 2: DFS(ground); break;
		case 3: UCS(ground); break;
		case 4: GFS(ground); break;
		case 5: AStar(ground); break;
	}
	return 0;
}
Example #2
0
void Dumper::printUnwindInfo(const Context &Ctx, const coff_section *Section,
                             off_t Offset, const UnwindInfo &UI) {
  DictScope UIS(SW, "UnwindInfo");
  SW.printNumber("Version", UI.getVersion());
  SW.printFlags("Flags", UI.getFlags(), makeArrayRef(UnwindFlags));
  SW.printNumber("PrologSize", UI.PrologSize);
  if (UI.getFrameRegister()) {
    SW.printEnum("FrameRegister", UI.getFrameRegister(),
                 makeArrayRef(UnwindOpInfo));
    SW.printHex("FrameOffset", UI.getFrameOffset());
  } else {
    SW.printString("FrameRegister", StringRef("-"));
    SW.printString("FrameOffset", StringRef("-"));
  }

  SW.printNumber("UnwindCodeCount", UI.NumCodes);
  {
    ListScope UCS(SW, "UnwindCodes");
    ArrayRef<UnwindCode> UC(&UI.UnwindCodes[0], UI.NumCodes);
    for (const UnwindCode *UCI = UC.begin(), *UCE = UC.end(); UCI < UCE; ++UCI) {
      unsigned UsedSlots = getNumUsedSlots(*UCI);
      if (UsedSlots > UC.size()) {
        errs() << "corrupt unwind data";
        return;
      }

      printUnwindCode(UI, ArrayRef<UnwindCode>(UCI, UCE));
      UCI = UCI + UsedSlots - 1;
    }
  }

  uint64_t LSDAOffset = Offset + getOffsetOfLSDA(UI);
  if (UI.getFlags() & (UNW_ExceptionHandler | UNW_TerminateHandler)) {
    SW.printString("Handler",
                   formatSymbol(Ctx, Section, LSDAOffset,
                                UI.getLanguageSpecificHandlerOffset()));
  } else if (UI.getFlags() & UNW_ChainInfo) {
    if (const RuntimeFunction *Chained = UI.getChainedFunctionEntry()) {
      DictScope CS(SW, "Chained");
      printRuntimeFunctionEntry(Ctx, Section, LSDAOffset, *Chained);
    }
  }
}
Example #3
0
void all_start(){
	Result res;
	int showFlag;
	char snumOpen[4],snumClose[4],sfindFlag[4];
  	const	char *start,*end;
	const 	char *file;
	start = gtk_entry_get_text(GTK_ENTRY(TallStart));
	end = gtk_entry_get_text(GTK_ENTRY(TallEnd));
	file= gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(FallFile));

	showFlag = 0;
	CreatALGraph(file);

	//广度优先搜索算法
	res = BFS(*start,*end,showFlag);
	sprintf(snumOpen,"%d",res.numOpen);
	sprintf(snumClose,"%d",res.numClose);
	if(res.findFlag == 1){
		strcpy(sfindFlag,"是");
	}else{
		strcpy(sfindFlag,"否");
	}
	gtk_entry_set_text(GTK_ENTRY(TallOpen[0]),snumOpen);
	gtk_entry_set_text(GTK_ENTRY(TallClose[0]),snumClose);
	gtk_entry_set_text(GTK_ENTRY(TallFind[0]),sfindFlag);

	//深度优先搜索算法	
	res = DFS(*start,*end,showFlag);
	sprintf(snumOpen,"%d",res.numOpen);
	sprintf(snumClose,"%d",res.numClose);
	if(res.findFlag == 1){
		strcpy(sfindFlag,"是");
	}else{
		strcpy(sfindFlag,"否");
	}
	gtk_entry_set_text(GTK_ENTRY(TallOpen[1]),snumOpen);
	gtk_entry_set_text(GTK_ENTRY(TallClose[1]),snumClose);
	gtk_entry_set_text(GTK_ENTRY(TallFind[1]),sfindFlag);

	//深度受限搜索算法
	res = DLS(*start,*end,showFlag);
	sprintf(snumOpen,"%d",res.numOpen);
	sprintf(snumClose,"%d",res.numClose);
	if(res.findFlag == 1){
		strcpy(sfindFlag,"是");
	}else{
		strcpy(sfindFlag,"否");
	}
	gtk_entry_set_text(GTK_ENTRY(TallOpen[2]),snumOpen);
	gtk_entry_set_text(GTK_ENTRY(TallClose[2]),snumClose);
	gtk_entry_set_text(GTK_ENTRY(TallFind[2]),sfindFlag);

	//迭代搜索算法
	res = IDS(*start,*end,showFlag);
	sprintf(snumOpen,"%d",res.numOpen);
	sprintf(snumClose,"%d",res.numClose);
	if(res.findFlag == 1){
		strcpy(sfindFlag,"是");
	}else{
		strcpy(sfindFlag,"否");
	}
	gtk_entry_set_text(GTK_ENTRY(TallOpen[3]),snumOpen);
	gtk_entry_set_text(GTK_ENTRY(TallClose[3]),snumClose);
	gtk_entry_set_text(GTK_ENTRY(TallFind[3]),sfindFlag);

	//等代价搜索算法
	res = UCS(*start,*end,showFlag);
	sprintf(snumOpen,"%d",res.numOpen);
	sprintf(snumClose,"%d",res.numClose);
	if(res.findFlag == 1){
		strcpy(sfindFlag,"是");
	}else{
		strcpy(sfindFlag,"否");
	}
	gtk_entry_set_text(GTK_ENTRY(TallOpen[4]),snumOpen);
	gtk_entry_set_text(GTK_ENTRY(TallClose[4]),snumClose);
	gtk_entry_set_text(GTK_ENTRY(TallFind[4]),sfindFlag);

	//最佳优先搜索算法
	res = BestFS(*start,*end,showFlag);
	sprintf(snumOpen,"%d",res.numOpen);
	sprintf(snumClose,"%d",res.numClose);
	if(res.findFlag == 1){
		strcpy(sfindFlag,"是");
	}else{
		strcpy(sfindFlag,"否");
	}
	gtk_entry_set_text(GTK_ENTRY(TallOpen[5]),snumOpen);
	gtk_entry_set_text(GTK_ENTRY(TallClose[5]),snumClose);
	gtk_entry_set_text(GTK_ENTRY(TallFind[5]),sfindFlag);
}
Example #4
0
/* Return a string describing a given key. This (sometimes) uses a
    static buffer, which is overwritten with each call. */
static wchar_t *key_to_name(glui32 key)
{
    static wchar_t kbuf[32];

    if (key >= 32 && key < 256) {
        if (key == 127) {
            return L"delete";
        }
        kbuf[0] = key;
        kbuf[1] = L'\0';
        return kbuf;
    }

    switch (key) {
    case L'\t':
        return L"tab";
    case L'\033':
        return L"escape";
    case keycode_Down:
        return L"down-arrow";
    case keycode_Up:
        return L"up-arrow";
    case keycode_Left:
        return L"left-arrow";
    case keycode_Right:
        return L"right-arrow";
    case keycode_Home:
        return L"home";
    /* Now that we don't have access to the raw code, glk can't
       distinguish between Backspace and Delete.
    case KEY_BACKSPACE:
        return L"backspace";
    */
    case keycode_Delete:
        return L"delete-char";
    /* Now that we don't have access to the raw code, glk can't
       detect IC
    case KEY_IC:
        return L"insert-char";
    */
    case keycode_PageDown:
        return L"page-down";
    case keycode_PageUp:
        return L"page-up";
    case keycode_Return:
        return L"enter";
    case keycode_End:
        return L"end";
    /* Now that we don't have access to the raw code, glk can't
       detect HELP
    case KEY_HELP:
        return L"help";
    */
    case keycode_Func1:
        return L"Function-1";
    case keycode_Func2:
        return L"Function-2";
    case keycode_Func3:
        return L"Function-3";
    case keycode_Func4:
        return L"Function-4";
    case keycode_Func5:
        return L"Function-5";
    case keycode_Func6:
        return L"Function-6";
    case keycode_Func7:
        return L"Function-7";
    case keycode_Func8:
        return L"Function-8";
    case keycode_Func9:
        return L"Function-9";
    case keycode_Func10:
        return L"Function-10";
    case keycode_Func11:
        return L"Function-11";
    case keycode_Func12:
        return L"Function-12";
    }

    if (key < 32) {
        /* swprintf(kbuf, 32, L"ctrl-%c", '@'+key); */
        kbuf[0] = L'\0';
        wcsncat(kbuf, L"ctrl-", 32);
        int l = wcslen(kbuf);
        kbuf[l] = UCS('@'+key);
        kbuf[l + 1] = L'\0';
        return kbuf;
    }

    return L"unknown-key";
}