|
@ -1,6 +1,42 @@ |
|
|
package de.tims.viergewinnt.ai; |
|
|
package de.tims.viergewinnt.ai; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.JFrame; |
|
|
|
|
|
import javax.swing.JPanel; |
|
|
|
|
|
|
|
|
public class Logic { |
|
|
public class Logic { |
|
|
|
|
|
|
|
|
|
|
|
//only for testing, remove when finished |
|
|
|
|
|
static JFrame content; |
|
|
|
|
|
|
|
|
|
|
|
static JPanel contentPanel; |
|
|
|
|
|
static JPanel buttonPanel; |
|
|
|
|
|
static JPanel playfieldPanel; |
|
|
|
|
|
|
|
|
|
|
|
public static JPanel create4gewinntGui() { |
|
|
|
|
|
|
|
|
|
|
|
//only for testing, remove when finished |
|
|
|
|
|
content = new JFrame(); |
|
|
|
|
|
content.setSize(200,200); |
|
|
|
|
|
|
|
|
|
|
|
contentPanel = new JPanel(); |
|
|
|
|
|
|
|
|
|
|
|
//only for testing, remove when finished |
|
|
|
|
|
content.add(contentPanel); |
|
|
|
|
|
|
|
|
|
|
|
buttonPanel = new JPanel(); |
|
|
|
|
|
playfieldPanel = new JPanel(); |
|
|
|
|
|
contentPanel.add(buttonPanel); |
|
|
|
|
|
contentPanel.add(playfieldPanel); |
|
|
|
|
|
|
|
|
|
|
|
return contentPanel; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//only for testing, remove when finished |
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
|
|
create4gewinntGui(); |
|
|
|
|
|
content.setVisible(true); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public boolean testForWin(int[][] playfield, int player) { |
|
|
public boolean testForWin(int[][] playfield, int player) { |
|
|
int chain = 0; |
|
|
int chain = 0; |
|
|
for(int i = 0; i < playfield[0].length; i++) { |
|
|
for(int i = 0; i < playfield[0].length; i++) { |
|
|