|
|
вернуться в форумHint Послано ASK 2 мар 2010 15:39 Do not use the fact that there are only 3 moves left. The traditional minimax is fast and simpler to write. Re: Hint Послано Anton 20 дек 2011 10:24 Finally I decided to use your way and I got AC. First of all, I cost tree leafs and then run minimax on the tree. You did in the same way ? On the leaf-costing I don't like how I find index for the child nodes. Is there a more beautiful way then in function below: void costIt( char val=1, char pos = 2 ){ char res = 0; for( char i = 0; i < 3; i++ ){ if ( !arr[ f_x[ i ] ][ f_y[ i ] ] ){ arr[ f_x[ i ] ][ f_y[ i ] ] = val; res = check(); if ( res == 0 ) costIt( val == 1 ? -1 : 1, pos*2+1 ); else if ( !set[ pos > 10 ? (pos-1)/2 : pos ] ){ cost[ pos > 10 ? (pos-1)/2 : pos ] = res; set[ pos > 10 ? (pos-1)/2 : pos ] = true; } arr[ f_x[ i ] ][ f_y[ i ] ] = 0; pos++; } } } Edited by author 20.12.2011 10:24 |
|
|