// toril_chacker.cpp : コンソール アプリケーションのエントリ ポイントを定義します。 // #include "stdafx.h" const int BLOCK_MAX = 10; const int STAGE_SIZE_X = 3; const int STAGE_SIZE_Y = 3; const int STAGE_SIZE_H = 3; const int FIGURE_SIZE_X = 16; const int FIGURE_SIZE_Y = 13; const int FIG_BASE_X = 4; const int FIG_BASE_Y = 4; const int FIG_BLOCK_SIZE_X = 6; const int FIG_BLOCK_SIZE_Y = 5; void CopyString( char* dst, const WCHAR* src,const int len ) { if( len == 0 ) return; WideCharToMultiByte(CP_ACP, // コードページ 0, // 処理速度とマッピング方法を決定するフラグ src, // ワイド文字列のアドレス -1, // ワイド文字列の文字数 dst, // 新しい文字列を受け取るバッファのアドレス len, // 新しい文字列を受け取るバッファのサイズ NULL, // マップできない文字の既定値のアドレス NULL // 既定の文字を使ったときにセットするフラグのアドレス ); dst[len-1] = 0; for( int q=0; dst[q] ; q++ ){ if( ( dst[q+0] == "@"[0] )&& ( dst[q+1] == "@"[1] ) ){ dst[q+0] = '.'; dst[q+1] = '-'; } if( ( dst[q+0] == "C"[0] )&& ( dst[q+1] == "C"[1] ) ){ dst[q+0] = '.'; dst[q+1] = '-'; } if( ( dst[q+0] == "D"[0] )&& ( dst[q+1] == "D"[1] ) ){ dst[q+0] = '/'; dst[q+1] = ' '; } if( ( dst[q+0] == "E"[0] )&& ( dst[q+1] == "E"[1] ) ){ dst[q+0] = '-'; dst[q+1] = ' '; } } } struct LOC { BYTE x,y,h,c; LOC() { x=y=h=c=0; } bool IsEqual( const LOC& s ) const { return (x==s.x)&&(y==s.y)&&(h==s.h); } bool IsContinue() const { return h< STAGE_SIZE_H; } bool Next() { c++; x++; if( x>=STAGE_SIZE_X ){ x=0; y++; if( y>=STAGE_SIZE_Y ){ y=0; h++; if( h>=STAGE_SIZE_H ){ return true; } } } return false; } }; const WCHAR* figBlock0 = //0 1 1 //0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 L"                " L"                " L"                " L"                " L"      @────────┐" L"     /########/│" L"    ┌──E##C──┐#D" L"    │#/##/│##│/ " L"    └┌──┐#@──┘  " L"     │##│/      " L"     └──┘       " L"                " L"                "; const WCHAR* figBlock1 = //0 1 1 //0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 L"                " L"                " L"                " L"                " L"      @────────┐" L"     /########/│" L"    ┌────────┐#D" L"    │########│/ " L"    └────────┘  " L"                " L"                " L"                " L"                "; const WCHAR* figBlock2 = //0 1 1 //0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 L"                " L"                " L"                " L"                " L"      @─────┐   " L"     /#####/│   " L"    /##C──┐#D   " L"   /##/│##│/    " L"  ┌──┐#└──┘     " L"  │##│/         " L"  └──┘          " L"                " L"                "; const WCHAR* figBlock3 = //0 1 1 //0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 L"                " L"                " L"                " L"                " L"      @──┐      " L"     /##/│      " L"    /##/#D      " L"   /##/#/       " L"  ┌──┐#/        " L"  │##│/         " L"  └──┘          " L"                " L"                "; const WCHAR* figBlock4 = //0 1 1 //0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 L"                " L"                " L"      @──┐      " L"     /##/│      " L"    ┌──┐#+      " L"    │##│$│      " L"    +#@+#D      " L"    │##│/       " L"    └──┘        " L"                " L"                " L"                " L"                "; const WCHAR* figBlock5 = //0 1 1 //0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 L"                " L"                " L"      @──┐      " L"     /##/│      " L"    ┌──┐#└──┐   " L"    │##│/##/│   " L"    +#@└──┐#D   " L"    │#####│/    " L"    └─────┘     " L"                " L"                " L"                " L"                "; const WCHAR* figBlock6 = //0 1 1 //0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 L"                " L"                " L"      @─────┐   " L"     /#####/│   " L"    ┌─────┐#+   " L"    │#####│$│   " L"    └──┐#@+#D   " L"       │##│/    " L"       └──┘     " L"                " L"                " L"                " L"                "; const WCHAR* figBlock7 = //0 1 1 //0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 L"      @──┐      " L"     /##/│      " L"    ┌──┐#+      " L"    │##│$│      " L"    +#@+#+      " L"    │##│$│      " L"    +#@+#D      " L"    │##│/       " L"    └──┘        " L"                " L"                " L"                " L"                "; const WCHAR* figBlock8_9 = //0 1 1 //0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 L"                " L"                " L"                " L"                " L"      @─────┐   " L"     /#####/│   " L"    ┌─────┐#D   " L"    │#####│/    " L"    └─────┘     " L"                " L"                " L"                " L"                "; #define NN {{ 0,0,0 },{ 0,0,0 },{ 0,0,0 }} struct BLOCK { const WCHAR* figure; BYTE t[STAGE_SIZE_H][STAGE_SIZE_Y][STAGE_SIZE_H]; int sx,sy,sh; int fx,fy,fx2,fy2; void Initialize() { sx = -1; sy = -1; sh = -1; for( int x=0; x tx ) fx = tx; if( fy > ty ) fy = ty; if( fx2 < tx ) fx2 = tx; if( fy2 < ty ) fy2 = ty; } } } fx2++; fy2++; } } block[BLOCK_MAX] = { // ------------------------------------------------------------------ // 0 { figBlock0,{ { { 1,1,1 }, { 0,1,0 }, { 0,0,0 }, }, NN, NN, } }, // ------------------------------------------------------------------ // 1 { figBlock1,{ { { 1,1,1 }, { 0,0,0 }, { 0,0,0 }, }, NN, NN, } }, // ------------------------------------------------------------------ // 2 { figBlock2,{ { { 1,1,0 }, { 1,0,0 }, { 0,0,0 }, }, NN, NN, } }, // ------------------------------------------------------------------ // 3 { figBlock3,{ { { 1,0,0 }, { 1,0,0 }, { 0,0,0 }, }, NN, NN, } }, // ------------------------------------------------------------------ // 4 { figBlock4,{ { { 1,0,0 }, { 0,0,0 }, { 0,0,0 }, }, { { 1,0,0 }, { 0,0,0 }, { 0,0,0 }, }, NN, } }, // ------------------------------------------------------------------ // 5 { figBlock5,{ { { 1,1,0 }, { 0,0,0 }, { 0,0,0 }, }, { { 1,0,0 }, { 0,0,0 }, { 0,0,0 }, }, NN, } }, // ------------------------------------------------------------------ // 6 { figBlock6,{ { { 0,1,0 }, { 0,0,0 }, { 0,0,0 }, }, { { 1,1,0 }, { 0,0,0 }, { 0,0,0 }, }, NN, } }, // ------------------------------------------------------------------ // 7 { figBlock7,{ { { 1,0,0 }, { 0,0,0 }, { 0,0,0 }, }, { { 1,0,0 }, { 0,0,0 }, { 0,0,0 }, }, { { 1,0,0 }, { 0,0,0 }, { 0,0,0 }, }, } }, // ------------------------------------------------------------------ // 8 { figBlock8_9,{ { { 1,1,0 }, { 0,0,0 }, { 0,0,0 }, }, NN, NN, } }, // ------------------------------------------------------------------ // 9 { figBlock8_9,{ { { 1,1,0 }, { 0,0,0 }, { 0,0,0 }, }, NN, NN, } }, }; // ------------------------------------------------------------------ struct STAGE { BYTE w[STAGE_SIZE_H][STAGE_SIZE_Y][STAGE_SIZE_X]; bool Set( const int bi,const LOC* loc ){ // そもそも入らないサイズ? if( STAGE_SIZE_X < ( block[bi].sx + loc->x ) ) return true; if( STAGE_SIZE_Y < ( block[bi].sy + loc->y ) ) return true; if( STAGE_SIZE_H < ( block[bi].sh + loc->h ) ) return true; for( int xp=0; xpx+xp; for( int yp=0; ypy+yp; for( int hp=0; hph+hp; if( block[bi].t[hp][yp][xp] == 1 ){ if( w[h][y][x] != 99 ) return true; } } } } for( int xp=0; xpx+xp; for( int yp=0; ypy+yp; for( int hp=0; hph+hp; if( block[bi].t[hp][yp][xp] == 1 ){ w[h][y][x] = bi; } } } } return false; } bool Check( const LOC* loc0, const LOC* loc1, const LOC* loc2, const LOC* loc3, const LOC* loc4, const LOC* loc5, const LOC* loc6, const LOC* loc7, const LOC* loc8, const LOC* loc9 ) { memset( w,99,STAGE_SIZE_H*STAGE_SIZE_Y*STAGE_SIZE_X ); if( loc0 == NULL ) return true; if( Set( 0,loc0 ) ) return false; if( loc1 == NULL ) return true; if( Set( 1,loc1 ) ) return false; if( loc2 == NULL ) return true; if( Set( 2,loc2 ) ) return false; if( loc3 == NULL ) return true; if( Set( 3,loc3 ) ) return false; if( loc4 == NULL ) return true; if( Set( 4,loc4 ) ) return false; if( loc5 == NULL ) return true; if( Set( 5,loc5 ) ) return false; if( loc6 == NULL ) return true; if( Set( 6,loc6 ) ) return false; if( loc7 == NULL ) return true; if( Set( 7,loc7 ) ) return false; if( loc8 == NULL ) return true; if( Set( 8,loc8 ) ) return false; if( loc9 == NULL ) return true; if( Set( 9,loc9 ) ) return false; return true; } }; // ------------------------------------------------------------------ //0 1 1 //0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 const WCHAR* figStageInit = L"                " L"                " L"                " L"                " L"                " L"                " L"      ・−−−−−−−−・" L"     /        / " L"    /        /  " L"   /        /   " L"  /        /    " L" /        /     " L"・−−−−−−−−・      "; void figDraw( FILE* fp,const STAGE& stage,const LOC** ploc,const int vi ) { WCHAR wstr[FIGURE_SIZE_X*FIGURE_SIZE_Y] ; BYTE flag[FIGURE_SIZE_X*FIGURE_SIZE_Y] ; for( int q=0; q a2 ){ // TLB t = tlb[ww]; // tlb[ww ] = tlb[ww2]; // tlb[ww2] = t; // } // } // } for( int ii=0; ii<9999; ii++ ){ if( tlb[ii].h >= STAGE_SIZE_H ) break; int lx = tlb[ii].x; int ly = tlb[ii].y; int lh = tlb[ii].h; int bi = stage.w[lh][ly][lx]; if( bi == 99 ) continue; const WCHAR* pfig = block[bi].figure; const char* pbct = " *--*" " /##/|" "*--*#*" "|##|/ " "*--* "; int bl_x = lx - ploc[bi]->x; int bl_y = ly - ploc[bi]->y; int bl_h = lh - ploc[bi]->h; int bl_dx = bl_x*3 - bl_y*2 + FIG_BASE_X; int bl_dy = bl_y*2 - bl_h*2 + FIG_BASE_Y; int dw_dx = lx*3 - ly*2 + FIG_BASE_X; int dw_dy = ly*2 - lh*2 + FIG_BASE_Y; for( int qy=0; qyx*10 + ploc[q]->y*100 + ploc[q]->h * 1000; if( vp > a ){ vp = a; vi = q; } } if( vi < 0 ) break; //fprintf( fp," --------------------\n" ); fprintf( fp," %d:\n",hand++ ); fprintf( fp," \n" ); // 手牌を書く int bl_x = ploc[vi]->x; int bl_y = ploc[vi]->y; int bl_dx = bl_x*3 - bl_y*2 + FIG_BASE_X; for( int qy=block[vi].fy; qy= ITEM_MAX ) return false; Item[Count].s = s; Item[Count].loc0 = *loc0; Item[Count].loc1 = *loc1; Item[Count].loc2 = *loc2; Item[Count].loc3 = *loc3; Item[Count].loc4 = *loc4; Item[Count].loc5 = *loc5; Item[Count].loc6 = *loc6; Item[Count].loc7 = *loc7; Item[Count].loc8 = *loc8; Item[Count].loc9 = *loc9; Count++; return true; } }; // ------------------------------------------------------------------ int _tmain(int argc, _TCHAR* argv[]) { STAGE stage; ANSWER answer; int hitcount = 0; for( int q=0; qh == hq ){ // printf( ps[q],ploc[q]->h ,ploc[q]->x,ploc[q]->y ); // } // } // } // } // printf( "\n" ); // } FILE* fp = fopen( "q.txt","w" ); for( int iq=0; iq