Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Ultima{
- private static String[][] tabla = new String[ 10 ][ 10 ];
- private static int player;
- static int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
- static int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };
- public static void init(){
- player = 0;
- for( int i = 0; i <= 9; ++i )
- for( int j = 0; j <= 9; ++j )
- tabla[i][j] = "empt";
- for( int i = 1; i <= 8; ++i )
- tabla[2][i] = "wpaw";
- for( int i = 1; i <= 8; ++i )
- tabla[7][i] = "bpaw";
- tabla[1][1] = "wimm";
- tabla[1][2] = "wlon";
- tabla[1][3] = "wcha";
- tabla[1][4] = "wkin";
- tabla[1][5] = "wwit";
- tabla[1][6] = "wcha";
- tabla[1][7] = "wlon";
- tabla[1][8] = "wcoo";
- tabla[8][1] = "bcoo";
- tabla[8][2] = "blon";
- tabla[8][3] = "bcha";
- tabla[8][4] = "bwit";
- tabla[8][5] = "bkin";
- tabla[8][6] = "bcha";
- tabla[8][7] = "blon";
- tabla[8][8] = "bimm";
- }
- public static String fieldState( String field ){
- int s = (int) ( field.charAt( 0 ) - 'A' + 1 );
- int r = (int) ( field.charAt( 1 ) - '0' );
- return tabla[r][s];
- }
- public static boolean outOfBounds( int r, int s ){
- return r >= 1 && r <= 8 && s >= 1 && s <= 8;
- }
- public static String checkQueen( int r, int s ){
- String ret = "";
- for( int d = 0; d < 8; ++d ){
- int rt = r;
- int st = s;
- while( true ){
- rt += dx[d];
- st += dy[d];
- if( outOfBounds( rt, st ) || tabla[rt][st] != "empt" ) break;
- ret += Integer.toString( rt ) + Integer.toString( st );
- }
- }
- return ret;
- }
- public static void main( String[] args ){
- init();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement