예제 #1
0
파일: hash.c 프로젝트: pmuellr/cpost
/*------------------------------------------------------------------
 *
 *------------------------------------------------------------------*/
int main(void)
   {
   Hash *iHash;
   int   i;
   int   counter;

   iHash = HashCreate(sizeof(int),3,compareFunc,hashFunc,NULL);

   for (i= 1; i<10; i++)
      HashAdd(iHash,&i);

   for (i=20; i>10; i--)
      HashAdd(iHash,&i);

   for (i=0; i<=21; i++)
      if (!HashFind(iHash,&i))
         printf("didn't find %d\n",i);

   counter = 1;
   HashIterate(iHash,iterateFunc,&counter);

   for (i=-1; i<5; i++)
      HashDelete(iHash,&i);

   for (i=21; i>15; i--)
      HashDelete(iHash,&i);

   counter = 1;
   HashIterate(iHash,iterateFunc,&counter);

   HashDestroy(iHash);

   return 0;
   }
예제 #2
0
void csmatch_reset_hash(HTablePtr T[], mobj_repeat *r) {
    int i;
    for (i = 0; i < r->num_match; i++) {
        HashDelete(csplot_hash, r->match[i].inum);
        HashInsert(csplot_hash, r->match[i].inum, &r->match[i]);
    }
}
예제 #3
0
END_TEST

START_TEST(HashTableDeleteTest) {
    struct HashTable _Table = {NULL, 0, 0};
    int _Data = 5;

    _Table.Table = calloc(sizeof(struct HashNode*), 20);
    _Table.TblSize = 20;
    _Table.Size = 0;

    ck_assert_int_eq(HashDelete(&_Table, "Foobar"), 0);
    HashInsert(&_Table, "Foobar", &_Data);
    ck_assert_int_eq(HashDelete(&_Table, "Foobar"), 1);
    ck_assert_int_eq(HashDelete(&_Table, NULL), 0);
    ck_assert_int_eq(_Table.Size, 0);
}
예제 #4
0
/*
 * ============================================================================
 * Manipulation of entire sets of results.
 * ============================================================================
 */
void DeleteRepeats(Tcl_Interp *interp, mobj_repeat *r, char *csplot_name,
                   HTablePtr T[]) {
    int i;

    /* Loop through each item removing from the hash table */
    for (i = r->num_match-1; i >= 0; i--) {
        HashDelete(T, r->match[i].inum);
    }

    /* Remove from canvas */
    Tcl_VarEval(interp, csplot_name, " delete ", r->tagname, NULL);
}
예제 #5
0
/*---------------------------------------------------------
函数名称:	HashFree
函数描述:	释放整个Hash表
输入参数:	pHashTable	Hash表叙述子
			CallBack	删除回调
输出参数:
返回值:
其他:
更新维护:	2011.4.4     最初版本
---------------------------------------------------------*/
VOID
HashFree(
    __in PHASH_TABLE_DESCRIPTOR pHashTable,
    __in_opt HASH_DELETE_CALLBACK CallBack
)
{
    ASSERT( pHashTable );

    //第一个Hash节点地址的地址
    PHASH_NOTE_DESCRIPTOR * dpCurrentFirstHashNote;

    HASH_LOCK_ON( pHashTable );

    //
    //遍历所有可能的Hash表中地址
    //
    for( ULONG ulCurrentHash = 0 ;
            ulCurrentHash < pHashTable-> ulMaximumPointNumber ;
            ulCurrentHash ++ ) {
        //
        //一直删除第一个节点,直到整个链表被清空
        //
        dpCurrentFirstHashNote =
            (PHASH_NOTE_DESCRIPTOR *)HASH_NOTE_POINT_ADDRESS( pHashTable , ulCurrentHash);

        while( * dpCurrentFirstHashNote != NULL ) {

            DebugTrace(DEBUG_TRACE_NORMAL_INFO,"HashFree",("Release table note 0x%X",*dpCurrentFirstHashNote));

            HashDelete(
                pHashTable ,
                *dpCurrentFirstHashNote ,
                CallBack,
                FALSE //由于这里已经加过锁了,Delete时不必加锁
            );
        }
    }

    HASH_LOCK_OFF( pHashTable );

    //
    //所有节点已经删除 现在释放表内存和叙述子内存
    //

    ExFreePool( (PVOID)pHashTable->ulHashTableBaseAddress );
    ExFreePool( (PVOID)pHashTable );
}
예제 #6
0
파일: cpost.c 프로젝트: pmuellr/cpost
/*------------------------------------------------------------------
 * add default key words to reserved hash
 *------------------------------------------------------------------*/
void InitializeReservedHash(
   Info *info,
   char *keyList
   )
   {
   int   i;
   char *part;

   /*---------------------------------------------------------------
    * create hash table
    *---------------------------------------------------------------*/
   info->reservedHash = HashCreate(sizeof(char *),
                                  30,
                                  (HashFunc *)IdentHash,
                                  (ListCompareFunc *)IdentCompare,
                                  cPostNoMem);

   if (!info->reservedHash)
      cPostError(1,"error creating reserved word hash table");

   for (i=0; i<sizeof(ReservedTokens)/sizeof(char *); i++)
      if (!HashAdd(info->reservedHash,&(ReservedTokens[i])))
         cPostError(1,"error adding reserved word '%s' to hash table",
                    ReservedTokens[i]);

   /*---------------------------------------------------------------
    * loop through the comma separated keys ...
    *---------------------------------------------------------------*/
   part = strtok(keyList,",");
   while (part)
      {
      /*------------------------------------------------------------
       * special c++ token
       *------------------------------------------------------------*/
      if (!Stricmp("c++",part))
         {
         for (i=0; i<sizeof(CppReservedTokens)/sizeof(char *); i++)
            if (!HashAdd(info->reservedHash,&(CppReservedTokens[i])))
               cPostError(1,"error adding reserved word '%s' to hash table",
                          CppReservedTokens[i]);

         }

      /*------------------------------------------------------------
       * use Java tokens
       *------------------------------------------------------------*/
      if (!Stricmp("java",part))
         {
         /*------------------------------------------------------------
          * remove default C tokens
          *------------------------------------------------------------*/
         for (i=0; i<sizeof(ReservedTokens)/sizeof(char *); i++)
            HashDelete(info->reservedHash,&(ReservedTokens[i]));

         /*------------------------------------------------------------
          * add Java tokens
          *------------------------------------------------------------*/
         for (i=0; i<sizeof(JavaReservedTokens)/sizeof(char *); i++)
            if (!HashAdd(info->reservedHash,&(JavaReservedTokens[i])))
               cPostError(1,"error adding reserved word '%s' to hash table",
                          JavaReservedTokens[i]);

         }

      /*------------------------------------------------------------
       * file name
       *------------------------------------------------------------*/
      else if (('@' == part[0]) && (1 != strlen(part)))
         {
         TokFileInfo  tfi;
         char        *key;

         part++;

         tfi = TokFileOpen(part);

         if (!tfi)
            cPostError(0,"error opening file '%s' for reading",part);

         else
            {
            while (NULL != (part = TokFileNext(tfi)))
               {
               key = malloc(1 + strlen(part));
               if (!key)
                  cPostError(1,"out of memory!!");

               strcpy(key,part);

               if (!HashAdd(info->reservedHash,&key))
                  cPostError(0,"error adding reserved word '%s' to hash table; word ignored",
                                key);
               }
            }
         }

      /*------------------------------------------------------------
       * plain old token
       *------------------------------------------------------------*/
      else if (!HashAdd(info->reservedHash,&part))
         {
         cPostError(0,"error adding reserved word '%s' to hash table; word ignored",part);
         }

      part = strtok(NULL,",");
      }
   }
예제 #7
0
파일: hash.c 프로젝트: HanaHosoe/c
int main(void) {
    int size = 0, h;
    char cmd, key[1024], value[1024], buf[1024];
    Hash *hash;

    // ハッシュテーブルの生成
                 
    printf("ハッシュテーブルの大きさを入力して下さい: ");
    scanf("%d", &size);
    
    if (size < 1) return -1;// 入力数エラー
    hash = HashAlloc(size);
    if (hash == NULL) return -1;    // メモリ確保失敗

    puts("* ハッシュテーブルを操作するコマンドを入力して下さい.");
    puts("* データを格納:a");
    puts("* キーを削除:x");
    puts("* キーに対応するデータの取得:g");
    puts("* ハッシュテーブルを表示:d");
    puts("* ハッシュ値の表示:h");
    puts("* ハッシュテーブルをクリア:c");
    puts("* 終了:q");
                                
    do {
        printf(": ");
        scanf("%s", buf);
        cmd = buf[0];

        switch (cmd) {
            case 'a':   /* データを格納 */
                printf("名前を入力して下さい:");
                scanf("%s", key);
                printf("血液型を入力して下さい:");
                scanf("%s", value);

                if (HashAdd(hash, key, value) == TRUE) {  // hash, name, blood-type
                    printf("%s=%sを格納しました.\n", key, value);
                } else {    /* 衝突 */
                    printf("既に同じキーを持つデータが存在します.\n");
                }
                break;
            case 'd':   /* データを表示 */
                HashDump(hash);
                break;
            case 'c':   /* ハッシュテーブルをクリア */
                HashClear(hash);
                break;
            case 'x':   /* キーを削除 */
                printf("誰を削除しますか?:");
                scanf("%s", key);
                if(HashDelete(hash, key) == TRUE) {
                    printf("%sを削除しました.\n", key);
                }
                else {
                    printf("%sは登録されていません.\n", key);
                }
                break;
            case 'g':   /* キーに対応するデータを取得 */
                printf("名前を入力して下さい:");
                scanf("%s", key);
                if (HashGet(hash, key, value) == TRUE) {
                    printf("%sの血液型は%sです.\n", key, value);
                } else {
                    printf("%sは登録されていません.\n", key);
                }
                break;
            case 'h':   /* キーに対応するデータを取得 */
                printf("名前を入力して下さい:");
                scanf("%s", key);
                h = HashCode(hash, key);
                printf("%sのハッシュ値は%dです.", key, h);
                break;
            case 'q':   /* 終了 */
                puts("プログラムを終了します.");
                break;
            case '\n':  /* 改行 */
            case '\r':  /* 復帰 */
                break;
            default:    /* 入力エラー */
                puts("コマンドが正しくありません.");
                break;
        }
    } while (cmd != 'q');

    HashDump(hash); // 解放前の出力
    HashFree(hash); // メモリ解放

    return 0;
}
예제 #8
0
/* Simple version of #define and #undef processor. */
int main() {
  char word[kMaxWord];
  char *name;
  char defn[kMaxWord];
  LinkNode *p;
  int len = 0, i = 0;
  enum ParserState state = kStart;

  HashTable hash_table[kHashSize];
  HashInit(hash_table, kHashSize);

  memset(word, 0, kMaxWord);
  memset(defn, 0, kMaxWord);

  while (GetWord(word, kMaxWord) != EOF) {
    switch (state) {
      case kStart:
        if (strcmp(word, "#define") == 0) {
          state = kDefine;
        } else if (strcmp(word, "#undef") == 0) {
          state = kUnDef;
        } else if (!isalpha(word[0])) {
          printf("%s", word);
        } else if ((p = HashSearch(hash_table, word)) == NULL) {
          printf("%s", word);
        } else {
          ungets(p->defn);
        }
        break;
      case kDefine:
        if (isalpha(word[0])) {
          name = strdup(word);
          state = kName;
        } else {
          printf("Error: non-alpha name");
          exit(1);
        }
        break;
      case kName:
        if (word[0] == '\n') {
          printf("Error: incomplate define");
          exit(1);
        } else {
          strcpy(defn, word);
          len += strlen(word);
          state = kDefn;
        }
        break;
      case kDefn:
        if (word[0] != '\n' && len < kMaxWord) {
          strcat(defn, word);
          len += strlen(word);
        } else {
          HashInsert(hash_table, name, defn);
          state = kStart;
        }
        break;
      case kUnDef:
        if (isalpha(word[0])) {
          HashDelete(hash_table, name);
          state = kStart;
        } else {
          printf("Error: non-alpha name");
          exit(1);
        }
        break;
    }
  }
  return 0;
}
예제 #9
0
//
//  関数: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  目的:  メイン ウィンドウのメッセージを処理します。
//
//  WM_COMMAND	- アプリケーション メニューの処理
//  WM_PAINT	- メイン ウィンドウの描画
//  WM_DESTROY	- 中止メッセージを表示して戻る
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;
	static HWND boardWnd, hBut[2];       // レバーコントロールのハンドル
    INITCOMMONCONTROLSEX ic;  // INITCOMMONCONTROLSEX構造体
    REBARBANDINFO rbBand;     // REBARBANDINFO構造体
	switch (message)
	{
	case WM_CREATE:
		/* ボード表示ウィンドウの作成 */
		//boardWnd = MakeBoardWindow(hWnd);
		/* レバーコントロールの作成 */
		ic.dwSize = sizeof(INITCOMMONCONTROLSEX); 
		ic.dwICC = ICC_COOL_CLASSES; 
		InitCommonControlsEx(&ic); 
		hRebar = MakeMyRebar(hWnd);
		hListBox = CreateListBox(hWnd);

		ZeroMemory(&rbBand, sizeof(REBARBANDINFO)); 
		rbBand.cbSize = sizeof(REBARBANDINFO); 
		rbBand.fMask = RBBIM_TEXT | RBBIM_STYLE | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE; 
		rbBand.fStyle = RBBS_CHILDEDGE | RBBS_NOGRIPPER; 
		rbBand.cxMinChild = 90;
		rbBand.cyMinChild = 25; 

		rbBand.hwndChild = CreateWindow("BUTTON", "新規対局", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 
										 0, 0, 0, 0, hRebar, (HMENU)NEWGAME_BT, hInst ,NULL);
		SendMessage(hRebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand);
		
		rbBand.hwndChild = CreateWindow("BUTTON", "継続対局", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 
										 0, 0, 0, 0, hRebar, (HMENU)CONTINUE_BT, hInst ,NULL);
		SendMessage(hRebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand);

		rbBand.hwndChild = CreateWindow("BUTTON", "中断", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 
										 0, 0, 0, 0, hRebar, (HMENU)INTERRUPT_BT, hInst ,NULL);
		rbBand.cxMinChild = 60;
		SendMessage(hRebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand);

		rbBand.hwndChild = CreateWindow("BUTTON", "手番変更", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 
										 0, 0, 0, 0, hRebar, (HMENU)CHANGE_BT, hInst ,NULL);
		rbBand.cxMinChild = 90; 
		SendMessage(hRebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand);

		rbBand.cxMinChild = 30;
		rbBand.hwndChild = CreateWindow("BUTTON", "<<", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 
										 0, 0, 0, 0, hRebar, (HMENU)FIRST_BT, hInst ,NULL); 
		SendMessage(hRebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand);
		rbBand.hwndChild = CreateWindow("BUTTON", "←", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 
										 0, 0, 0, 0, hRebar, (HMENU)UNDO_BT, hInst ,NULL);
		SendMessage(hRebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand); 

		rbBand.hwndChild = CreateWindow("BUTTON", "→", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 
										 0, 0, 0, 0, hRebar, (HMENU)REDO_BT, hInst ,NULL); 
		SendMessage(hRebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand);

		rbBand.hwndChild = CreateWindow("BUTTON", ">>", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 
										 0, 0, 0, 0, hRebar, (HMENU)FINAL_BT, hInst ,NULL);
		SendMessage(hRebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand);

		//hToolBar = CreateToolbarEx( 
		//	hWnd,					//親ウィンドウ
		//	WS_CHILD | WS_VISIBLE,	//ウィンドウスタイル 
		//	ID_TOOLBAR,				//コントロールID 
		//	8,						//イメージの数 
		//	hInst, 
		//	ID_MYBMP, 
		//	tbb, 
		//	8,						// ボタンの数 
		//	0,						//ボタンの幅 
		//	0,						//ボタンの高さ 
		//	18,						//イメージの幅 
		//	18,						//イメージの高さ 
		//	sizeof(TBBUTTON));
		//SendMessage(hToolBar, TB_INSERTBUTTON, 2, (LPARAM)&tb); 

		hComBox1 = CreateComBox1(hWnd, BOARD_SIZE + 10, 90, 0);
		SendMessage(hComBox1, CB_SETCURSEL, 0, 0);
		hComBox2 = CreateComBox1(hWnd, BOARD_SIZE + 10, 120, 1);
		SendMessage(hComBox2, CB_SETCURSEL, 1, 0);
		hComBox3 = CreateComBox2(hWnd, BOARD_SIZE + 100, 90, 2);
		ShowWindow(hComBox3, SW_HIDE);
		hComBox4 = CreateComBox2(hWnd, BOARD_SIZE + 100, 120, 3);
		player[0] = HUMAN;
		player[1] = CPU;
		/* 初期難易度 */
		Onnormal(hWnd, BLACK);
		Onnormal(hWnd, WHITE);

		ShowWindow(hListBox, SW_SHOW);	//リストボックスを表示
		UpdateWindow(hWnd);
		UpdateWindow(hRebar);

		//srand((unsigned int)time(NULL));
		/* ステータスバー作成 */
		hStatus = CreateStatusBar(hWnd);

		/* 定石データオープン */
		open_book_thread(hInst);

		break;
	case WM_LBUTTONDOWN:
		/* 左クリックイベント 打てるマスをクリックすればスレッドが起動 */
		if(!AI_THINKING && chk_range_board(lParam))
		{
			Flag_Abort = TRUE;
			WaitForSingleObject(SIG_HINT_FINISHED, INFINITE);
			Flag_Abort = FALSE;
			GameThread(lParam, LBUTTON);
		}
		SendMessage(hStatus, SB_SETTEXT, (WPARAM)1 | 0, (LPARAM)turn_str[NowTurn]);
		return 0;
	case WM_RBUTTONDOWN:
		RButtonClick(hWnd, hStatus, lParam);
		return 0;
	case WM_SET_TEXT_BAR:
		SendMessage(hStatus, SB_SETTEXT, (WPARAM)0 | 3, (LPARAM)lParam);
		return 0;
	case WM_COMMAND:
		wmId    = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		// 選択されたメニューの解析:
		switch (wmId)
		{
		/* コンボボックス */
		case IDC_COM1:
			/* 変更された */
			if(HIWORD(wParam) == CBN_SELCHANGE)
			{
				int index = SendMessage(hComBox1, CB_GETCURSEL, 0, 0);
				/* 人間を選択 */
				if(index == 0)
				{
					player[0] = HUMAN;
					CpuColor = WHITE;
					ShowWindow(hComBox3, SW_HIDE);
				}
				/* CPUを選択 */
				else
				{
					player[0] = CPU;
					CpuColor = BLACK;
					ShowWindow(hComBox3, SW_SHOW);
				}
			}
			break;
		case IDC_COM2:
			/* 変更された */
			if(HIWORD(wParam) == CBN_SELCHANGE)
			{
				int index = SendMessage(hComBox2, CB_GETCURSEL, 0, 0);
				/* 人間を選択 */
				if(index == 0)
				{
					player[1] = HUMAN;
					CpuColor = BLACK;
					ShowWindow(hComBox4, SW_HIDE);
				}
				/* CPUを選択 */
				else
				{
					player[1] = CPU;
					CpuColor = WHITE;
					ShowWindow(hComBox4, SW_SHOW);
				}
			}
			break;
		case IDC_COM3:
			/* 変更された */
			if(HIWORD(wParam) == CBN_SELCHANGE)
			{
				int index = SendMessage(hComBox3, CB_GETCURSEL, 0, 0);
				/* 難易度 */
				switch(index)
				{
				case 0:
					OnVeasy(hWnd, BLACK);
					break;
				case 1:
					Oneasy(hWnd, BLACK);
					break;
				case 2:
					Onnormal(hWnd, BLACK);
					break;
				case 3:
					Onhard(hWnd, BLACK);
					break;
				case 4:
					OnVhard(hWnd, BLACK);
					break;
				case 5:
					OnUhard(hWnd, BLACK);
					break;
				case 6:
					OnSUhard(hWnd, BLACK);
					break;
				case 7:
					OnSSUhard(hWnd, BLACK);
					break;
				case 8:
					OnHUhard(hWnd, BLACK);
					break;
				case 9:
					OnUltra(hWnd, BLACK);
					break;
				case 10:
					OnSUltra(hWnd, BLACK);
					break;
				case 11:
					OnSSUltra(hWnd, BLACK);
					break;
				case 12:
					OnAllSearchWin(hWnd, BLACK);
					break;
				case 13:
					OnAllSearchSD(hWnd, BLACK);
					break;
				}
			}
			break;
		case IDC_COM4:
			/* 変更された */
			if(HIWORD(wParam) == CBN_SELCHANGE)
			{
				int index = SendMessage(hComBox4, CB_GETCURSEL, 0, 0);
				/* 難易度 */
				switch(index)
				{
				case 0:
					OnVeasy(hWnd, WHITE);
					break;
				case 1:
					Oneasy(hWnd, WHITE);
					break;
				case 2:
					Onnormal(hWnd, WHITE);
					break;
				case 3:
					Onhard(hWnd, WHITE);
					break;
				case 4:
					OnVhard(hWnd, WHITE);
					break;
				case 5:
					OnUhard(hWnd, WHITE);
					break;
				case 6:
					OnSUhard(hWnd, WHITE);
					break;
				case 7:
					OnSSUhard(hWnd, WHITE);
					break;
				case 8:
					OnHUhard(hWnd, WHITE);
					break;
				case 9:
					OnUltra(hWnd, WHITE);
					break;
				case 10:
					OnSUltra(hWnd, WHITE);
					break;
				case 11:
					OnSSUltra(hWnd, WHITE);
					break;
				case 12:
					OnAllSearchWin(hWnd, WHITE);
					break;
				case 13:
					OnAllSearchSD(hWnd, WHITE);
					break;
				}
			}
			break;
		case IDM_ABOUT:
			DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
			break;
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		case NEWGAME_BT:
		case StartNew:
			InitBoard();
			/* 置換表の取得 */
			HashDelete(ghash);
			ghash = HashNew(21);
			HashClear(ghash);
			/* 再描写 */
			hdc = GetDC(hWnd);
			DrawBoard( hdc, hStatus, -1, -1);
			ReleaseDC(hWnd, hdc);
			GameThread(lParam, STARTGAME);
			return DefWindowProc(hWnd, message, wParam, lParam);
		case CONTINUE_BT:
			/* 置換表の取得 */
			if(ghash == NULL){
				HashDelete(ghash);
				ghash = HashNew(21);
				HashClear(ghash);
			}
			if(NowTurn == BLACK)
			{
				/* 再描写 */
				hdc = GetDC(hWnd);
				DrawBoard( hdc, hStatus, -1, -1);
				ReleaseDC(hWnd, hdc);
				NowTurn = BLACK;
				GameThread(lParam, STARTGAME);
				return DefWindowProc(hWnd, message, wParam, lParam);
			}
			else
			{
				hdc = GetDC(hWnd);
				DrawBoard( hdc, hStatus, -1, -1);
				ReleaseDC(hWnd, hdc);
				NowTurn = WHITE;
				GameThread(lParam, STARTGAME);
				return DefWindowProc(hWnd, message, wParam, lParam);
			}
		case StartContinue_B:
			/* 再描写 */
			hdc = GetDC(hWnd);
			DrawBoard( hdc, hStatus, -1, -1);
			ReleaseDC(hWnd, hdc);
			NowTurn = BLACK;
			GameThread(lParam, STARTGAME);
			return DefWindowProc(hWnd, message, wParam, lParam);
		case StartContinue_W:
			hdc = GetDC(hWnd);
			DrawBoard( hdc, hStatus, -1, -1);
			ReleaseDC(hWnd, hdc);
			NowTurn = WHITE;
			GameThread(lParam, STARTGAME);
			return DefWindowProc(hWnd, message, wParam, lParam);
		/*case Veasy:
			Force_SearchWin = FALSE;
			Force_SearchSD = FALSE;
			OnVeasy(hWnd);
			break;
		case easy:
			Force_SearchWin = FALSE;
			Force_SearchSD = FALSE;
			Oneasy(hWnd);
			break;
		case normal:
			Force_SearchWin = FALSE;
			Force_SearchSD = FALSE;
			Onnormal(hWnd);
			break;
		case hard:
			Force_SearchWin = FALSE;
			Force_SearchSD = FALSE;
			Onhard(hWnd);
			break;
		case Vhard:
			Force_SearchWin = FALSE;
			Force_SearchSD = FALSE;
			OnVhard(hWnd);
			break;
		case Uhard:
			Force_SearchWin = FALSE;
			Force_SearchSD = FALSE;
			OnUhard(hWnd);
			break;
		case AllWinLoss:
			Force_SearchWin = TRUE;
			OnAllSearchWin(hWnd);
			break;
		case AllStoneDiff:
			Force_SearchSD = TRUE;
			Force_SearchWin = FALSE;
			OnAllSearchSD(hWnd);
			break;*/
		case book_switch:
			if(!UseBook)
			{
				UseBook = TRUE;
				m_FlagBook = TRUE;
				HMENU hMenu = GetMenu(hWnd);
				CheckMenuItem(hMenu, book_switch, MFS_CHECKED);
			}
			else
			{
				UseBook = FALSE;
				m_FlagBook = FALSE;
				HMENU hMenu = GetMenu(hWnd);
				CheckMenuItem(hMenu, book_switch, MFS_UNCHECKED);
			}
			break;
		case book_best:
			if(!b_Flag_not_change)
			{
				HMENU hMenu = GetMenu(hWnd);
				UncheckedAll_BookMenu(hMenu);
				b_Flag_not_change = TRUE;
				CheckMenuItem(hMenu, book_best, MFS_CHECKED);
			}
			break;
		case book_little_change:
			if(!b_Flag_little_change)
			{
				HMENU hMenu = GetMenu(hWnd);
				UncheckedAll_BookMenu(hMenu);
				b_Flag_little_change = TRUE;
				CheckMenuItem(hMenu, book_little_change, MFS_CHECKED);
			}
			break;
		case book_change:
			if(!b_Flag_change)
			{
				HMENU hMenu = GetMenu(hWnd);
				UncheckedAll_BookMenu(hMenu);
				b_Flag_change = TRUE;
				CheckMenuItem(hMenu, book_change, MFS_CHECKED);
			}
			break;
		case book_random:
			{
				HMENU hMenu = GetMenu(hWnd);
				UncheckedAll_BookMenu(hMenu);
				CheckMenuItem(hMenu, book_random, MFS_CHECKED);
			}
			break;
		/*case CorrectSt:
			PrintCorrectSt(hWnd);
			return DefWindowProc(hWnd, message, wParam, lParam);*/
		case rotate90:
			m_FlagInGame = FALSE;
			black = rotate_90(black);
			white = rotate_90(white);
			{
				BitBoard move = one << (move_x * 8 + move_y);
				move = rotate_90(move);
				int pos = CountBit((move & (-(signed long long int)move)) - 1);
				move_x = pos / 8;
				move_y = pos % 8;
			}
			break;
		case rotate180:
			m_FlagInGame = FALSE;
			black = rotate_180(black);
			white = rotate_180(white);
			{
				BitBoard move = one << (move_x * 8 + move_y);
				move = rotate_180(move);
				int pos = CountBit((move & (-(signed long long int)move)) - 1);
				move_x = pos / 8;
				move_y = pos % 8;
			}
			break;
		case rotate270:
			m_FlagInGame = FALSE;
			black = rotate_270(black);
			white = rotate_270(white);
			{
				BitBoard move = one << (move_x * 8 + move_y);
				move = rotate_270(move);
				int pos = CountBit((move & (-(signed long long int)move)) - 1);
				move_x = pos / 8;
				move_y = pos % 8;
			}
			break;
		case symX:
			m_FlagInGame = FALSE;
			black = symmetry_x(black);
			white = symmetry_x(white);
			{
				BitBoard move = one << (move_x * 8 + move_y);
				move = symmetry_x(move);
				int pos = CountBit((move & (-(signed long long int)move)) - 1);
				move_x = pos / 8;
				move_y = pos % 8;
			}
			break;
		case symY:
			m_FlagInGame = FALSE;
			black = symmetry_y(black);
			white = symmetry_y(white);
			{
				BitBoard move = one << (move_x * 8 + move_y);
				move = symmetry_y(move);
				int pos = CountBit((move & (-(signed long long int)move)) - 1);
				move_x = pos / 8;
				move_y = pos % 8;
			}
			break;
		case symBL:
			m_FlagInGame = FALSE;
			black = symmetry_b(black);
			white = symmetry_b(white);
			{
				BitBoard move = one << (move_x * 8 + move_y);
				move = symmetry_b(move);
				int pos = CountBit((move & (-(signed long long int)move)) - 1);
				move_x = pos / 8;
				move_y = pos % 8;
			}
			break;
		case symWL:
			m_FlagInGame = FALSE;
			black = symmetry_w(black);
			white = symmetry_w(white);
			{
				BitBoard move = one << (move_x * 8 + move_y);
				move = symmetry_w(move);
				int pos = CountBit((move & (-(signed long long int)move)) - 1);
				move_x = pos / 8;
				move_y = pos % 8;
			}
			break;
		case BoardInit:
			InitBoard();
			{
				/* メニューバーの各項目の有効無効化 */
				HMENU hMenu = GetMenu(hWnd);
				EnableMenuItem(hMenu, interrupt, MFS_GRAYED);
				EnableMenuItem(hMenu, EditBoard, MFS_ENABLED);
				EnableMenuItem(hMenu, ChangeColor, MFS_ENABLED);
			}
			break;
		case EditBoard:
			Flag_Edit = TRUE;
			break;
		case INTERRUPT_BT:
		case interrupt:
			if(AI_THINKING /*|| m_FlagHint */)
			{
				Flag_Abort = TRUE;
			}
			else
			{
				Interrupt_flag = TRUE;
				m_FlagInterrupt = TRUE;
				m_FlagInGame = FALSE;
			}
			{
				HMENU hMenu = GetMenu(hWnd);
				EnableMenuItem(hMenu, interrupt, MFS_GRAYED);
				hMenu = GetMenu(hWnd);
				EnableMenuItem(hMenu, EditBoard, MFS_ENABLED);
				EnableMenuItem(hMenu, ChangeColor, MFS_ENABLED);
			}
			break;
		case CHANGE_BT:
		case ChangeColor:
			CpuColor ^= 1;
			break;
		case print_result:
			if(!AI_result)
			{
				AI_result = TRUE;
				HMENU hMenu = GetMenu(hWnd);
				CheckMenuItem(hMenu, print_result, MFS_CHECKED);
			}
			else
			{
				AI_result = FALSE;
				HMENU hMenu = GetMenu(hWnd);
				CheckMenuItem(hMenu, print_result, MFS_UNCHECKED);
			}
			break;
		case print_AI_moves:
			/*if(!AI_thinking)
			{
				AI_thinking = TRUE;
				HMENU hMenu = GetMenu(hWnd);
				CheckMenuItem(hMenu, print_AI_moves, MFS_CHECKED);
			}
			else
			{
				AI_thinking = FALSE;
				HMENU hMenu = GetMenu(hWnd);
				CheckMenuItem(hMenu, print_AI_moves, MFS_UNCHECKED);
			}*/
			
			break;
		case print_thinking:
		/*	if(!OnTheWay)
			{
				OnTheWay = TRUE;
				HMENU hMenu = GetMenu(hWnd);
				CheckMenuItem(hMenu, print_thinking, MFS_CHECKED);
			}
			else
			{
				OnTheWay = FALSE;
				HMENU hMenu = GetMenu(hWnd);
				CheckMenuItem(hMenu, print_thinking, MFS_UNCHECKED);
			}*/
			break;
		case Auto_Learn:
			//InitBoard();
			//{
			//	int i = 0;
			//	while(i < 1)
			//	{
			//		Learn_Thread();
			//		//Start_Auto_Learn(4, 13, 100000, -1);
			//		i++;
			//	}
			//}
			break;
		case 32849:
			/*{
				Learn_Thread();
			}*/
			break;
		case auto_g:
			m_FlagInterrupt = FALSE;
			Interrupt_flag = FALSE;
			auto_game_thread();
			break;
		case UNDO_BT:
		case Undo:
			if(turn == 0 || (UndoBoard_B[turn - 1] == 0 && UndoBoard_W[turn - 1] == 0))
			{
				break;
			}
			m_FlagInGame = FALSE;
			if(AI_THINKING /* || m_FlagHint */)
			{
				Flag_Abort = TRUE;
			}
			/* ヒント用の評価データ破棄 */
			/*{
				for(int i = 0; i < 32; i++){ EvalData[i] = NEGAMAX;}
			}*/
			black = UndoBoard_B[turn - 1];
			white = UndoBoard_W[turn - 1];
			move_x = Undo_x[turn - 1];
			move_y = Undo_y[turn - 1];
			NowTurn = Undo_color[turn - 1];

			turn--;
			SendMessage(hListBox, LB_SETCURSEL, turn - 1, 0);
			if(turn - 1 < 0 || (UndoBoard_B[turn - 1] == 0 && UndoBoard_W[turn - 1] == 0))
			{
				EnableMenuItem(GetMenu(hWnd), Undo, MFS_GRAYED);
				EnableWindow(GetDlgItem(hRebar, UNDO_BT), FALSE);
			}
			if(!(UndoBoard_B[turn + 1] == 0 && UndoBoard_W[turn + 1] == 0) || turn + 1 <= 60)
			{
				EnableMenuItem(GetMenu(hWnd), Redo, MFS_ENABLED);
				EnableWindow(GetDlgItem(hRebar, REDO_BT), TRUE);
			}
			break;
		case REDO_BT:
		case Redo:
			if(turn == 60 || UndoBoard_B[turn + 1] == 0 && UndoBoard_W[turn + 1] == 0)
			{
				break;
			}
			m_FlagInGame = FALSE;
			/* ヒント用の評価データ破棄 */
			/*{
				for(int i = 0; i < 32; i++){ EvalData[i] = NEGAMAX;}
			}*/
			SendMessage(hListBox, LB_SETCURSEL, turn, 0);
			black = UndoBoard_B[turn + 1];
			white = UndoBoard_W[turn + 1];
			move_x = Undo_x[turn + 1];
			move_y = Undo_y[turn + 1];
			NowTurn = Undo_color[turn + 1];
			turn++;
			if((UndoBoard_B[turn + 1] == 0 && UndoBoard_W[turn + 1] == 0) || turn + 1 > 60)
			{
				EnableMenuItem(GetMenu(hWnd), Redo, MFS_GRAYED);
				EnableWindow(GetDlgItem(hRebar, REDO_BT), FALSE);
			}
			if(turn - 1 >= 0 || !(UndoBoard_B[turn - 1] == 0 && UndoBoard_W[turn - 1] == 0))
			{
				EnableMenuItem(GetMenu(hWnd), Undo, MFS_ENABLED);
				EnableWindow(GetDlgItem(hRebar, UNDO_BT), TRUE);
			}
			break;
		case FIRST_BT:
			{
				int i;
				for(i = 0; i < 60; i++)
				{
					if(UndoBoard_B[i] != 0 || UndoBoard_W[i] != 0)
					{	
						black = UndoBoard_B[i];
						white = UndoBoard_W[i];
						move_x = Undo_x[i];
						move_y = Undo_y[i];
						NowTurn = Undo_color[i];
						turn = i;
						/* ヒント用の評価データ破棄 */
						//for(i = 0; i < 32; i++){ EvalData[i] = NEGAMAX;}
						m_FlagInGame = FALSE;
						break;
					}
				}
			}
			break;
		case FINAL_BT:
			{
				int i;
				for(i = 60; i >= 0; i--)
				{
					if(UndoBoard_B[i] != 0 || UndoBoard_W[i] != 0)
					{	
						black = UndoBoard_B[i];
						white = UndoBoard_W[i];
						move_x = Undo_x[i];
						move_y = Undo_y[i];
						NowTurn = Undo_color[i];
						turn = i;
						/* ヒント用の評価データ破棄 */
						//for(i = 0; i < 32; i++){ EvalData[i] = NEGAMAX;}
						m_FlagInGame = FALSE;
						break;
					}
				}
			}
			break;
		case Hint_0:
			OnHint_0(hWnd);
			HINT_DISPED = FALSE;
			GameThread(0, HINTONLY);
			break;
		case Hint_1:
			OnHint_1(hWnd);
			HINT_DISPED = FALSE;
			GameThread(0, HINTONLY);
			break;
		case Hint_2:
			OnHint_2(hWnd);
			HINT_DISPED = FALSE;
			GameThread(0, HINTONLY);
			break;
		case Hint_3:
			OnHint_3(hWnd);
			HINT_DISPED = FALSE;
			GameThread(0, HINTONLY);
			break;
		case Hint_4:
			OnHint_4(hWnd);
			HINT_DISPED = FALSE;
			GameThread(0, HINTONLY);
			break;
		case Hint_5:
			OnHint_5(hWnd);
			HINT_DISPED = FALSE;
			GameThread(0, HINTONLY);
			break;
		case Hint_6:
			OnHint_6(hWnd);
			HINT_DISPED = FALSE;
			GameThread(0, HINTONLY);
			break;
		case print_eval:
			//read_eval_table(CountBit(black | white) - 4);
			if(turn == 0){
				break;
			}
			//read_eval_table(turn - 1);
			if(NowTurn == BLACK){
				init_index_board(black, white);
				GetEvalFromPattern(black, white, NowTurn, turn - 1);
			}
			else{
				init_index_board(white, black);
				GetEvalFromPattern(white, black, NowTurn, turn - 1);
			}
			
			{
				char eval_msg[PATTERN_NUM + 1][64];
				sprintf_s(eval_msg[0], "hori_ver1_1 = %f, ", key_hori_ver1[0]);
				sprintf_s(eval_msg[1], "hori_ver1_2 = %f\n", key_hori_ver1[1]);
				sprintf_s(eval_msg[2], "hori_ver1_3 = %f,", key_hori_ver1[2]);
				sprintf_s(eval_msg[3], "hori_ver1_4 = %f\n", key_hori_ver1[3]);
				sprintf_s(eval_msg[4], "hori_ver2_1 = %f,", key_hori_ver2[0]);
				sprintf_s(eval_msg[5], "hori_ver2_2 = %f\n", key_hori_ver2[1]);
				sprintf_s(eval_msg[6], "hori_ver2_3 = %f,", key_hori_ver2[2]);
				sprintf_s(eval_msg[7], "hori_ver2_4 = %f\n", key_hori_ver2[3]);
				sprintf_s(eval_msg[8], "hori_ver3_1 = %f,", key_hori_ver3[0]);
				sprintf_s(eval_msg[9], "hori_ver3_2 = %f\n", key_hori_ver3[1]);
				sprintf_s(eval_msg[10], "hori_ver3_3 = %f,", key_hori_ver3[2]);
				sprintf_s(eval_msg[11], "hori_ver3_4 = %f\n", key_hori_ver3[3]);
				sprintf_s(eval_msg[12], "dia_ver1_1 = %f,",  key_dia_ver1[0]);
				sprintf_s(eval_msg[13], "dia_ver1_2 = %f\n",  key_dia_ver1[1]);
				sprintf_s(eval_msg[14], "dia_ver2_1 = %f,", key_dia_ver2[0]);
				sprintf_s(eval_msg[15], "dia_ver2_2 = %f\n", key_dia_ver2[1]);
				sprintf_s(eval_msg[16], "dia_ver2_3 = %f,", key_dia_ver2[2]);
				sprintf_s(eval_msg[17], "dia_ver2_4 = %f\n", key_dia_ver2[3]);
				sprintf_s(eval_msg[18], "dia_ver3_1 = %f,", key_dia_ver3[0]);
				sprintf_s(eval_msg[19], "dia_ver3_2 = %f\n", key_dia_ver3[1]);
				sprintf_s(eval_msg[20], "dia_ver3_3 = %f,", key_dia_ver3[2]);
				sprintf_s(eval_msg[21], "dia_ver3_4 = %f\n", key_dia_ver3[3]);
				sprintf_s(eval_msg[22], "dia_ver4_1 = %f,", key_dia_ver4[0]);
				sprintf_s(eval_msg[23], "dia_ver4_2 = %f\n", key_dia_ver4[1]);
				sprintf_s(eval_msg[24], "dia_ver4_3 = %f,", key_dia_ver4[2]);
				sprintf_s(eval_msg[25], "dia_ver4_4 = %f\n", key_dia_ver4[3]);
				sprintf_s(eval_msg[26], "edge_1 = %f,", key_edge[0]);
				sprintf_s(eval_msg[27], "edge_2 = %f\n", key_edge[1]);
				sprintf_s(eval_msg[28], "edge_3 = %f,", key_edge[2]);
				sprintf_s(eval_msg[29], "edge_4 = %f\n", key_edge[3]);
				sprintf_s(eval_msg[26], "edge_cor_1 = %f,", key_edge_cor[0]);
				sprintf_s(eval_msg[27], "edge_cor_2 = %f\n", key_edge_cor[1]);
				sprintf_s(eval_msg[28], "edge_cor_3 = %f,", key_edge_cor[2]);
				sprintf_s(eval_msg[29], "edge_cor_4 = %f\n", key_edge_cor[3]);
				sprintf_s(eval_msg[34], "corner4_2_1 = %f,", key_corner4_2[0]);
				sprintf_s(eval_msg[35], "corner4_2_2 = %f\n", key_corner4_2[1]);
				sprintf_s(eval_msg[36], "corner4_2_3 = %f,", key_corner4_2[2]);
				sprintf_s(eval_msg[37], "corner4_2_4 = %f\n", key_corner4_2[3]);
				sprintf_s(eval_msg[38], "corner3_3_1 = %f,", key_corner3_3[0]);
				sprintf_s(eval_msg[39], "corner3_3_2 = %f\n", key_corner3_3[1]);
				sprintf_s(eval_msg[40], "corner3_3_3 = %f,", key_corner3_3[2]);
				sprintf_s(eval_msg[41], "corner3_3_4 = %f\n", key_corner3_3[3]);
				/*sprintf_s(eval_msg[38], "triangle_1 = %f,", key_triangle[0]);
				sprintf_s(eval_msg[39], "triangle_2 = %f\n", key_triangle[1]);
				sprintf_s(eval_msg[40], "triangle_3 = %f,", key_triangle[2]);
				sprintf_s(eval_msg[41], "triangle_4 = %f\n", key_triangle[3]);
				sprintf_s(eval_msg[42], "mobility = %f\n", key_mobility);
				sprintf_s(eval_msg[43], "potential_mobility = %f\n", key_pot_mobility);
				sprintf_s(eval_msg[44], "paility = %f\n", key_pality);*/
				sprintf_s(eval_msg[42], "mobility = %f\n", key_mobility);
				sprintf_s(eval_msg[43], "constant = %f\n", key_constant);
				sprintf_s(eval_msg[44], "\n評価値 = %f,", eval_sum);
				sprintf_s(eval_msg[45], "\nblack = 0x%llx\nwhite = 0x%llx\n", black, white);
				int i;
				char print_msg[8192];
				strcpy_s(print_msg, eval_msg[0]);
				for(i = 1; i < 46; i++)
				{
					strcat_s(print_msg, eval_msg[i]);
				}
				
				MessageBox(hWnd, print_msg, "評価値詳細一覧", MB_OK);
				//memset(msg, 0, sizeof(print_msg));
			}
			break;
			/* FFOメニュ− */

		case FFO40:
			black = 9158069842325798912;
			white = 11047339776155165;
			configCPU(BLACK);
			break;

		case FFO41:
			black = 616174399789064;
			white = 39493460025648416;
			configCPU(BLACK);
			break;

		case FFO42:
			white = 9091853944868375556;
			black = 22586176447709200;
			configCPU(BLACK);
			break;

		case FFO43:
			black = 38808086923902976;
			white = 13546258740034592;
			configCPU(WHITE);
			break;

		case FFO44:
			black = 2494790880993312;
			white = 1010251075753548824;
			configCPU(WHITE);
			break;

		case FFO45:
			black = 282828816915486;
			white = 9287318235258944;
			configCPU(BLACK);
			break;

		case FFO46:
			black = 4052165999611379712;
			white = 36117299622447104;
			configCPU(BLACK);

			break;

		case FFO47:
			black = 277938752194568;
			white = 3536224466208;
			configCPU(WHITE);
			break;

		case FFO48:
			black = 38519958422848574;
			white = 4725679339520;
			configCPU(WHITE);
			break;

		case FFO49:
			black = 5765976742297600;
			white = 4253833575484;
			configCPU(BLACK);

			break;

		case FFO50:
			black = 4504145659822080;
			white = 4336117619740130304;
			configCPU(BLACK);
			break;

		case FFO51:
			black = 349834415978528;
			white = 8664011788383158280;
			configCPU(WHITE);
			break;

		case FFO52:
			black = 9096176176681728056;
			white = 35409824317440;
			configCPU(WHITE);
			break;

		case FFO53:
			black = 2515768979493888;
			white = 8949795312300457984;
			configCPU(BLACK);
			break;

		case FFO54:
			black = 277938752194568;
			white = 3536224466208;
			configCPU(BLACK);
			break;

		case FFO55:
			black = 4635799596172290;
			white = 289361502099486840;
			configCPU(BLACK);
			break;

		case FFO56:
			black = 4925086697193472;
			white = 9007372734053408;
			configCPU(WHITE);
			break;

		case FFO57:
			black = 9060166336512000;
			white = 8943248156475301888;
			configCPU(BLACK);

			break;

		case FFO58:
			black = 4636039783186432;
			white = 3383245044333600;
			configCPU(BLACK);
			break;

		case FFO59:
			black = 17320879491911778304;
			white = 295223649004691488;
			configCPU(BLACK);
			break;

		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
		InvalidateRect(hWnd, NULL, FALSE);
		/* 再描写 */
		hdc = GetDC(hWnd);
		DrawBoard( hdc, hStatus, -1, -1);
		ReleaseDC(hWnd, hdc);
		UpdateWindow(hRebar);
		SendMessage(hStatus, SB_SETTEXT, (WPARAM)1 | 0, (LPARAM)turn_str[NowTurn]);
		break;
	case WM_PAINT:
		hdc = BeginPaint(hWnd, &ps);
		// TODO: 描画コードをここに追加してください...
		hdc = GetDC(hWnd);
		DrawBoard( hdc, hStatus, move_x, move_y);
		ReleaseDC(hWnd, hdc);
		SendMessage(hStatus, SB_SETTEXT, (WPARAM)1 | 0, (LPARAM)turn_str[NowTurn]);
		//char str[64];
		//sprintf_s(str, "black = %llu", black);
		//SendMessage(hStatus, SB_SETTEXT, (WPARAM)3 | 0, (LPARAM)str);
		EndPaint(hWnd, &ps);
		break;
	case WM_DESTROY:
		
		/* 置換表の解放 */
		//HashDelete(hashTable);
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}