Browse Source

Add values and colors to board-String

AIPlayer
FelixKrull 3 years ago
parent
commit
e9dcf4a162
  1. 62
      src/main/java/Gameboard.java

62
src/main/java/Gameboard.java

@ -2,13 +2,18 @@ import java.util.Arrays;
public class Gameboard {
int[] board;
static String RED = "\u001b[31;1m";
static String BLUE = "\u001b[34;1m";
static String YELLOW = "\u001b[33;1m";
static String GREEN = "\u001b[32;1m";
static String RESET = "\u001b[0m";
public Gameboard() {
board = new int[56];
}
public void initGameboard (){
for(int i = 0; i < 40; i++) {
for(int i = 0; i < 56; i++) {
if ( i % 10 == 0) {
board[i] = 1;
}
@ -21,9 +26,60 @@ public class Gameboard {
}
}
@Override
public String toString() {
return Arrays.toString(board);
String[] f = new String[72];
Arrays.fill(f, " ");
return "" +
BLUE +"+---+ +---+"+ RESET +" +---+ +---+ +---+ "+ YELLOW +"+---+ +---+\n" +
BLUE +"| "+ f[60] +" | | "+ f[61] +" |"+ RESET +" | "+ f[18] +" | | "+ f[19] +" | | "+ f[20] +" | "+ YELLOW +"| "+ f[64] +" | | "+ f[65] +" |\n" +
BLUE +"+---+ +---+"+ RESET +" +---+ +---+ +---+ "+ YELLOW +"+---+ +---+\n" +
BLUE +"+---+ +---+"+ RESET +" +---+ "+ YELLOW +"+---+"+ RESET +" +---+ "+ YELLOW +"+---+ +---+\n" +
BLUE +"| "+ f[62] +" | | "+ f[63] +" |"+ RESET +" | "+ f[17] +" | "+ YELLOW +" | "+ f[48] +" | "+ RESET +" | "+ f[21] +" | "+ YELLOW +"| "+ f[66] +" | | "+ f[67] +" |\n" +
BLUE +"+---+ +---+"+ RESET +" +---+ "+ YELLOW +"+---+"+ RESET +" +---+ "+ YELLOW +"+---+ +---+\n" + RESET +
" +---+ "+ YELLOW +" +---+ "+ RESET +" +---+\n" +
" | "+ f[16] +" | "+ YELLOW +" | "+ f[49] +" | "+ RESET +" | "+ f[22] +" |\n" +
" +---+ "+ YELLOW +" +---+ "+ RESET +" +---+\n" +
" +---+ "+ YELLOW +" +---+ "+ RESET +" +---+\n" +
" | "+ f[15] +" | "+ YELLOW +" | "+ f[50] +" | "+ RESET +" | "+ f[23] +" |\n" +
"+---+ +---+ +---+ +---+ +---+ "+ YELLOW +" +---+ "+ RESET +" +---+ +---+ +---+ +---+ +---+ \n" +
"| "+ f[10] +" | | "+ f[11] +" | | "+ f[12] +" | | "+ f[13] +" | | "+ f[14] +" | "+ YELLOW +" | "+ f[51] +" | "+ RESET +" | "+ f[24] +" | | "+ f[25] +" | | "+ f[26] +" | | "+ f[27] +" | | "+ f[28] +" | \n" +
"+---+ +---+ +---+ +---+ +---+ "+ YELLOW +" +---+ "+ RESET +" +---+ +---+ +---+ +---+ +---+ \n" +
"+---+ "+ BLUE +" +---+ +---+ +---+ +---+ "+ GREEN +"+---+ +---+ +---+ +---+ "+ RESET +" +---+ \n" +
"| "+ f[9] +" | "+ BLUE +" | "+ f[44] +" | | "+ f[45] +" | | "+ f[46] +" | | "+ f[47] +" | "+ GREEN +" | "+ f[55] +" | | "+ f[54] +" | | "+ f[53] +" | | "+ f[52] +" | "+ RESET +" | "+ f[29] +" | \n" +
"+---+ "+ BLUE +" +---+ +---+ +---+ +---+ "+ GREEN +"+---+ +---+ +---+ +---+ "+ RESET +" +---+ \n" +
"+---+ +---+ +---+ +---+ +---+ "+ RED +" +---+ "+ RESET +" +---+ +---+ +---+ +---+ +---+ \n" +
"| "+ f[8] +" | | "+ f[7] +" | | "+ f[6] +" | | "+ f[5] +" | | "+ f[4] +" | "+ RED +" | "+ f[43] +" | "+ RESET +" | "+ f[34] +" | | "+ f[33] +" | | "+ f[32] +" | | "+ f[31] +" | | "+ f[30] +" | \n" +
"+---+ +---+ +---+ +---+ +---+ "+ RED +" +---+ "+ RESET +" +---+ +---+ +---+ +---+ +---+ \n" +
" | "+ f[3] +" | "+ RED +" | "+ f[42] +" | "+ RESET +" | "+ f[35] +" |\n" +
" +---+ "+ RED +" +---+ "+ RESET +" +---+\n" +
" +---+ "+ RED +" +---+ "+ RESET +" +---+\n" +
" | "+ f[2] +" | "+ RED +" | "+ f[41] +" | "+ RESET +" | "+ f[36] +" |\n" +
" +---+ "+ RED +" +---+ "+ RESET +" +---+\n" +
RED +"+---+ +---+"+ RESET +" +---+ "+ RED +" +---+ "+ RESET +" +---+ "+ GREEN +"+---+ +---+\n" +
RED +"| "+ f[56] +" | | "+ f[57] +" |"+ RESET +" | "+ f[1] +" | "+ RED +" | "+ f[40] +" | "+ RESET +" | "+ f[37] +" | "+ GREEN +"| "+ f[68] +" | | "+ f[69] +" |\n" +
RED +"+---+ +---+"+ RESET +" +---+ "+ RED +" +---+ "+ RESET +" +---+ "+ GREEN +"+---+ +---+\n" +
RED +"+---+ +---+"+ RESET +" +---+ +---+ +---+ "+ GREEN +"+---+ +---+\n" +
RED +"| "+ f[58] +" | | "+ f[59] +" |"+ RESET +" | "+ f[0] +" | | "+ f[39] +" | | "+ f[38] +" | "+ GREEN +"| "+ f[70] +" | | "+ f[71] +" |\n" +
RED +"+---+ +---+"+ RESET +" +---+ +---+ +---+ "+ GREEN +"+---+ +---+\n" + RESET +
"Color Test\n" +
"" + RED + " RED " + BLUE + " BLUE " + GREEN + " GREEN " + YELLOW + " YELLOW " + RESET + " WHITE";
}
public static void main(String[] args) {
Game g = new Game();
System.out.println(g.gb.toString());
}
}
/*
0-39 Spielfelder
Rot Ziel: 40,41,42,43
Blau Ziel: 44,45,46,47
Gelb Ziel: 48,49,50,51
Grün Ziel: 52.53.54.55
Rot Daneben: 56,57,58,59
Blau Daneben: 60,61,62,63
Gelb Daneben: 64.65.66.67
Grün Daneben: 68.69,70,71
*/
Loading…
Cancel
Save