started with the TicTacToe_MinMax Project. Finished the rendering of the game.
TODO: Make a playable version and add MinMax
This commit is contained in:
9
TOOLS/.classpath
Normal file
9
TOOLS/.classpath
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="src" path="createBackground"/>
|
||||
<classpathentry kind="src" path="fileReader"/>
|
||||
<classpathentry kind="src" path="fileWriter"/>
|
||||
<classpathentry kind="lib" path="C:/Program Files/Java/jdk1.8.0_65/jre/lib/ext/basisSwing130203UTF8.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
1
TOOLS/.gitignore
vendored
Normal file
1
TOOLS/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/bin/
|
||||
17
TOOLS/.project
Normal file
17
TOOLS/.project
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>TOOLS</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
14
TOOLS/TOOLS.iml
Normal file
14
TOOLS/TOOLS.iml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/createBackground" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/fileReader" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/fileWriter" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/time" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
42
TOOLS/fileReader/reader/NumberReader.java
Normal file
42
TOOLS/fileReader/reader/NumberReader.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package reader;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class NumberReader {
|
||||
|
||||
private String path;
|
||||
int i;
|
||||
|
||||
public NumberReader(String PATH) {
|
||||
this.path = PATH;
|
||||
}
|
||||
|
||||
public int read() {
|
||||
File file = new File(path);
|
||||
|
||||
BufferedReader br;
|
||||
try {
|
||||
br = new BufferedReader(new FileReader(file));
|
||||
String st;
|
||||
while ((st = br.readLine()) != null) {
|
||||
char[] chars = st.toCharArray();
|
||||
st = "";
|
||||
for (int i = 0; i < chars.length; i++) {
|
||||
String j = "" + chars[i];
|
||||
try {
|
||||
st += Integer.parseInt(j);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
i = Integer.parseInt(st);
|
||||
}
|
||||
} catch (FileNotFoundException ex) {
|
||||
ex.printStackTrace();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
}
|
||||
47
TOOLS/fileReader/reader/ReaderRakete.java
Normal file
47
TOOLS/fileReader/reader/ReaderRakete.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package reader;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
public class ReaderRakete {
|
||||
|
||||
private String path;
|
||||
private int[] fluege;
|
||||
private int entrys;
|
||||
|
||||
public ReaderRakete(String PATH) {
|
||||
this.path = PATH;
|
||||
fluege = new int [3];
|
||||
}
|
||||
|
||||
public int read() {
|
||||
File file = new File(path);
|
||||
|
||||
BufferedReader br;
|
||||
try {
|
||||
br = new BufferedReader(new FileReader(file));
|
||||
String st;
|
||||
while ((st = br.readLine()) != null) {
|
||||
if(st != "") {
|
||||
fluege[entrys] = Integer.parseInt(st);
|
||||
System.out.println(fluege[entrys]);
|
||||
entrys++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return entrys;
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
ReaderRakete r = new ReaderRakete("F:/JavaCode/RaketeGame/src/RaketeGame/res/highscores.txt");
|
||||
r.read();
|
||||
}
|
||||
}
|
||||
170
TOOLS/fileReader/reader/ReaderRotkaeppchen.java
Normal file
170
TOOLS/fileReader/reader/ReaderRotkaeppchen.java
Normal file
@@ -0,0 +1,170 @@
|
||||
package reader;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
public class ReaderRotkaeppchen {
|
||||
|
||||
// OPTIONAL
|
||||
private double wolfRot, wolfOma, jaegerWolf, rotOma;
|
||||
private double gesamt, fehler, runden, male;
|
||||
private String path;
|
||||
private String[] strings;
|
||||
|
||||
public ReaderRotkaeppchen(String PATH) {
|
||||
// OPTIONAL
|
||||
wolfRot = 0;
|
||||
wolfOma = 0;
|
||||
jaegerWolf = 0;
|
||||
rotOma = 0;
|
||||
gesamt = 0;
|
||||
runden = 0;
|
||||
male = 0;
|
||||
strings = new String[13];
|
||||
this.path = PATH;
|
||||
|
||||
}
|
||||
|
||||
public void read() {
|
||||
File file = new File(path);
|
||||
|
||||
BufferedReader br;
|
||||
try {
|
||||
br = new BufferedReader(new FileReader(file));
|
||||
String st;
|
||||
male++;
|
||||
while ((st = br.readLine()) != null) {
|
||||
// OPTIONAL
|
||||
switch (st) {
|
||||
case "Der Wolf hat das Rotkaeppchen gefressen!":
|
||||
this.setWolfRot(this.getWolfRot()+1);
|
||||
break;
|
||||
|
||||
case "Der Wolf hat die Oma gefressen!":
|
||||
this.setWolfOma(this.getWolfOma()+1);
|
||||
break;
|
||||
|
||||
case "Der Jaeger hat den Wolf erschossen!":
|
||||
this.setJaegerWolf(this.getJaegerWolf()+1);
|
||||
break;
|
||||
|
||||
case "Das Rotkaeppchen hat das Haus erreicht!":
|
||||
this.setRotOma(this.getRotOma()+1);
|
||||
break;
|
||||
|
||||
case " Runde beendet":
|
||||
this.setRunden(this.getRunden()+1);
|
||||
|
||||
default:
|
||||
this.setFehler(this.getFehler()+1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// OPTIONAL
|
||||
this.setGesamt( this.getWolfOma() + this.getWolfRot() + this.getJaegerWolf() + this.getRotOma());
|
||||
|
||||
}
|
||||
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int stringsLength() {
|
||||
return strings.length;
|
||||
}
|
||||
|
||||
public String[] results() {
|
||||
|
||||
strings[0] = "Gesamte Aktionen: " + Math.round(gesamt) + "\n";
|
||||
|
||||
strings[1] = "Der Wolf hat das Rotk<74>ppchen " + Math.round(wolfRot) + "-mal gefressen. ";
|
||||
strings[2] = "(" + (Math.round((wolfRot / gesamt)*100)) + "%)\n";
|
||||
|
||||
strings[3] = "Der Wolf hat die Oma " + Math.round(wolfOma) + "-mal gefressen. ";
|
||||
strings[4] = "(" + (Math.round((wolfOma / gesamt) * 100)) + "%)\n";
|
||||
|
||||
strings[5] = "Der J<>ger hat den Wolf " + Math.round(jaegerWolf) + "-mal erschossen. ";
|
||||
strings[6] = "(" + Math.round((jaegerWolf / gesamt) * 100) + "%)\n";
|
||||
|
||||
strings[7] = "Das Rotk<74>ppchen hat das Haus der Oma " + Math.round(rotOma) + "-mal erreicht. ";
|
||||
strings[8] = "(" + (Math.round((rotOma / gesamt) * 100)) + "%)\n";
|
||||
|
||||
strings[9] = "Not matched: " + Math.round(fehler) + " / Gesamt: " + Math.round(gesamt + fehler);
|
||||
strings[10] = " (" + Math.round(fehler / (gesamt + fehler) * 100) + "%)\n";
|
||||
|
||||
strings[11] = "Runden: " + (Math.round(this.getRunden()) + "\n");
|
||||
|
||||
strings[12] = "Male durchgelaufen: " + male + "\n";
|
||||
|
||||
return strings;
|
||||
}
|
||||
|
||||
public double getWolfRot() {
|
||||
return wolfRot;
|
||||
}
|
||||
|
||||
public void setWolfRot(double wolfRot) {
|
||||
this.wolfRot = wolfRot;
|
||||
}
|
||||
|
||||
public double getWolfOma() {
|
||||
return wolfOma;
|
||||
}
|
||||
|
||||
public void setWolfOma(double wolfOma) {
|
||||
this.wolfOma = wolfOma;
|
||||
}
|
||||
|
||||
public double getJaegerWolf() {
|
||||
return jaegerWolf;
|
||||
}
|
||||
|
||||
public void setJaegerWolf(double jaegerWolf) {
|
||||
this.jaegerWolf = jaegerWolf;
|
||||
}
|
||||
|
||||
public double getRotOma() {
|
||||
return rotOma;
|
||||
}
|
||||
|
||||
public void setRotOma(double rotOma) {
|
||||
this.rotOma = rotOma;
|
||||
}
|
||||
|
||||
public double getGesamt() {
|
||||
return gesamt;
|
||||
}
|
||||
|
||||
public void setGesamt(double gesamt) {
|
||||
this.gesamt = gesamt;
|
||||
}
|
||||
|
||||
public double getFehler() {
|
||||
return fehler;
|
||||
}
|
||||
|
||||
public void setFehler(double fehler) {
|
||||
this.fehler = fehler;
|
||||
}
|
||||
|
||||
public double getRunden() {
|
||||
return runden;
|
||||
}
|
||||
|
||||
public void setRunden(double runden) {
|
||||
this.runden = runden;
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
ReaderRotkaeppchen r = new ReaderRotkaeppchen("E:\\JavaCode\\Rotkeappchengame\\Rotkeappchengame\\statistics\\Run.txt");
|
||||
r.read();
|
||||
for(int i = 0; i < r.stringsLength(); i++)
|
||||
System.out.print(r.results()[i]);
|
||||
}
|
||||
}
|
||||
3070
TOOLS/fileReader/reader/res/RED_Analyse_File.txt
Normal file
3070
TOOLS/fileReader/reader/res/RED_Analyse_File.txt
Normal file
File diff suppressed because it is too large
Load Diff
58
TOOLS/fileWriter/writer/Writer.java
Normal file
58
TOOLS/fileWriter/writer/Writer.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package writer;
|
||||
|
||||
import reader.ReaderRakete;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Writer {
|
||||
|
||||
private String filePath;
|
||||
|
||||
public Writer(String PATH) {
|
||||
this.filePath = PATH;
|
||||
}
|
||||
|
||||
public void write(String newText, boolean append) {
|
||||
File file = new File(filePath);
|
||||
FileWriter fr = null;
|
||||
try {
|
||||
fr = new FileWriter(file, append);
|
||||
fr.write(newText);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
fr.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
File file = new File(filePath);
|
||||
|
||||
FileWriter fr = null;
|
||||
try {
|
||||
// Below constructor argument decides whether to append or override
|
||||
fr = new FileWriter(filePath, false);
|
||||
fr.write("");
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
fr.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
File file = new File(filePath);
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
41
TOOLS/time/util/Timer.java
Normal file
41
TOOLS/time/util/Timer.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package util;
|
||||
|
||||
/**
|
||||
* This is a tool to time
|
||||
*
|
||||
* @param starttime This Parameter captures the time at the beginning of a program
|
||||
* @param endtime This Parameter captures the time at the end of a program
|
||||
* @Author BiteCoding --> https://github.com/BiteCoding
|
||||
*/
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class Timer {
|
||||
private long starttime;
|
||||
private long endtime;
|
||||
|
||||
public Timer() {
|
||||
starttime = 0;
|
||||
endtime = 0;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
starttime = new Date().getTime();
|
||||
}
|
||||
|
||||
public void end() {
|
||||
endtime = new Date().getTime();
|
||||
}
|
||||
|
||||
private long deltaTime() {
|
||||
if (starttime == 0 || endtime == 0) {
|
||||
return -1;
|
||||
} else {
|
||||
return endtime-starttime;
|
||||
}
|
||||
}
|
||||
|
||||
public String timeNeeded(){
|
||||
return "Time needed " + deltaTime() + " ms";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user