|
|
@ -1,40 +1,25 @@ |
|
|
|
package de.tims.viergewinnt.ai; |
|
|
|
|
|
|
|
import java.awt.Color; |
|
|
|
import java.awt.Dimension; |
|
|
|
import java.awt.GridLayout; |
|
|
|
|
|
|
|
import javax.swing.BorderFactory; |
|
|
|
import javax.swing.BoxLayout; |
|
|
|
import javax.swing.JButton; |
|
|
|
import javax.swing.JFrame; |
|
|
|
import javax.swing.JLabel; |
|
|
|
import javax.swing.JPanel; |
|
|
|
|
|
|
|
public class Logic { |
|
|
|
|
|
|
|
//"static" only for testing, remove when finished |
|
|
|
//only for testing, remove when finished |
|
|
|
static JFrame content; |
|
|
|
|
|
|
|
static JPanel contentPanel; |
|
|
|
static JPanel buttonPanel; |
|
|
|
static JPanel playfieldPanel; |
|
|
|
static JButton[] buttons = new JButton[6]; |
|
|
|
static JLabel[] gamefield = new JLabel[36]; |
|
|
|
|
|
|
|
public static JPanel create4gewinntGui() { |
|
|
|
|
|
|
|
//only for testing, remove when finished |
|
|
|
content = new JFrame(); |
|
|
|
content.setSize(500,500); |
|
|
|
JPanel contentPanel; |
|
|
|
JPanel buttonPanel; |
|
|
|
JPanel playfieldPanel; |
|
|
|
JButton[] buttons = new JButton[6]; |
|
|
|
JLabel[] gamefield = new JLabel[36]; |
|
|
|
|
|
|
|
public JPanel create4gewinntGui() { |
|
|
|
contentPanel = new JPanel(); |
|
|
|
contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.PAGE_AXIS)); |
|
|
|
|
|
|
|
//only for testing, remove when finished |
|
|
|
content.add(contentPanel); |
|
|
|
|
|
|
|
buttonPanel = new JPanel(new GridLayout(1, 6)); |
|
|
|
playfieldPanel = new JPanel(new GridLayout(6, 6)); |
|
|
|
contentPanel.add(buttonPanel); |
|
|
@ -54,12 +39,6 @@ public class Logic { |
|
|
|
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) { |
|
|
|
int chain = 0; |
|
|
|
for(int i = 0; i < playfield[0].length; i++) { |
|
|
|