📄 minimaxgame.java
字号:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
/**
* This program is the main executable file of MiniMaxGame
* Input format MiniMaxGame [input filename] [output file name] [depth]
* It also supports empty number of arguments as it is facilitated to be entered later in the program.
* @author sanshack
*
*/
public class MiniMaxGame {
/**
* args[0] input filename //Not mandatory
* args[1] output filename //Not mandatory
* args[2] depth //Not mandatory
* Also supports empty number of arguments as it is facilitated to be entered later in the program.
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
int mode=1;//mode for mid and end game
int estimatorIndex=0;
long startTime = System.currentTimeMillis();
String inputTextFileName,outputTextFileName;
int treeDepth=0;
BufferedReader buff = new BufferedReader(new InputStreamReader( System.in ));
if(args.length==3) {
inputTextFileName = args[0];
outputTextFileName = args[1];
treeDepth = Integer.parseInt(args[2]);
}else {
System.out.println("Enter your input:([input filename] [output file name] [depth])");
String temp= buff.readLine();
StringTokenizer st = new StringTokenizer(temp);
inputTextFileName = st.nextToken();
outputTextFileName = st.nextToken();
treeDepth = Integer.parseInt(st.nextToken());
}
String initialPosition = new FileReader().getPosition(inputTextFileName);
if(initialPosition==null) {
System.out.println("invalid initialPosition given in file "+inputTextFileName);
}
//System.out.println("Max Depth="+treeDepth);
System.out.println("Input Position :"+initialPosition);
String finalPosition = new MM().getMaxMove(initialPosition,treeDepth,mode);
new FileWriter().writePosition(outputTextFileName,finalPosition);
long endTime = System.currentTimeMillis();
//System.out.print("Time taken="+(endTime-startTime)+" milli secs");
}catch (Exception e) {
System.out.println("The input format is not correct or board position is not valid:");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -