My professor asked me to make a board game with AI but I want the AI to be separated from the main code. What I want to do is I will just put the AI.class to the same folder where the Game.class is so that Game.class will just call the AI.class every time the AI() function from the code below is executed the AI.class will also be executed. I will also give the values of a int array to AI.class and the AI.class will return four integer. PS we are not allowed to use netbeans, we are only allowed to use notepad or textpad or the like.
@SuppressWarnings("serial")
public class Game extends JPanel {
BufferedImage board;
int[] intinfo = new int[]{486, 539, 591,643,696,749,801,853,907};
int intinfo1;
int intinfo2;
int intinfo3;
int intinfo4;
char keyPressed;
//I want this to be on different class
AI(){
int[] info=new int[10]; //the values of this will come from intinfo
info1=1; //values of these four info will be returned to the intinfo
info2=2;
info3=3;
info4=4;
}
public Game() {
KeyListener listener = new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
keyPressed= e.getKeyChar();
}
@Override
public void keyReleased(KeyEvent e) {
}
};
addKeyListener(listener);
setFocusable(true);
}
@Override
public void paint(Graphics g) {
super.paint(g);
g.drawImage(board, 0, 0,this);
}
public static void main(String[] args) throws InterruptedException {
JFrame frame = new JFrame("Games of the Generals");
Game game = new Game();
frame.add(game);
frame.setSize(1040, 680);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
game.repaint();
while(true){
game.AI();
Thread.sleep(50);
}
}
}