Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
20d45ce4ca | ||
![]() |
d0ae96def8 |
8
.idea/.gitignore
generated
vendored
8
.idea/.gitignore
generated
vendored
@ -1,8 +0,0 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
6
.idea/misc.xml
generated
6
.idea/misc.xml
generated
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
8
.idea/modules.xml
generated
8
.idea/modules.xml
generated
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/ProgA-Bot.iml" filepath="$PROJECT_DIR$/ProgA-Bot.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
generated
6
.idea/vcs.xml
generated
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -1,11 +0,0 @@
|
||||
<?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$" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
8
out/production/ProgA-Bot/.idea/.gitignore
generated
vendored
8
out/production/ProgA-Bot/.idea/.gitignore
generated
vendored
@ -1,8 +0,0 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
6
out/production/ProgA-Bot/.idea/misc.xml
generated
6
out/production/ProgA-Bot/.idea/misc.xml
generated
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
8
out/production/ProgA-Bot/.idea/modules.xml
generated
8
out/production/ProgA-Bot/.idea/modules.xml
generated
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/ProgA-Bot.iml" filepath="$PROJECT_DIR$/ProgA-Bot.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
6
out/production/ProgA-Bot/.idea/vcs.xml
generated
6
out/production/ProgA-Bot/.idea/vcs.xml
generated
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -1,11 +0,0 @@
|
||||
<?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$" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
@ -1,3 +0,0 @@
|
||||
# ProgA-Bot
|
||||
|
||||
Jeder erstellt seinen eigenen Branch und wir mergen am ende das was am besten funktioniert
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,49 +0,0 @@
|
||||
package src;
|
||||
|
||||
public class EscapeBot extends Bot {
|
||||
int stepCounter = 0;
|
||||
int turnCount = 0;
|
||||
int viewRange = 5;
|
||||
int straightLength = 1;
|
||||
|
||||
protected EscapeBot(String[] args) {
|
||||
super(args);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
EscapeBot bot = new EscapeBot(args);
|
||||
bot.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected char nextMove(View view) throws Exception {
|
||||
|
||||
if (!view.data.contains("o")) {
|
||||
|
||||
if (turnCount == 2) {
|
||||
turnCount = 0;
|
||||
straightLength++;
|
||||
}
|
||||
if (stepCounter < straightLength * viewRange) {
|
||||
stepCounter++;
|
||||
return '^';
|
||||
} else {
|
||||
stepCounter = 0;
|
||||
turnCount++;
|
||||
return '>';
|
||||
}
|
||||
} else {
|
||||
if (view.data.substring(0, 10).contains("o")) {
|
||||
return '^';
|
||||
} else if (view.data.substring(10, 12).contains("o")) {
|
||||
return '<';
|
||||
} else if (view.data.substring(13, 15).contains("o")) {
|
||||
return '>';
|
||||
} else if (view.data.substring(15, 25).contains("o")) {
|
||||
return 'v';
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
package src;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
public class ManualBot extends Bot {
|
||||
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
|
||||
protected ManualBot(String[] args) {
|
||||
super(args);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
ManualBot bot = new ManualBot(args);
|
||||
bot.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected char nextMove(View view) throws Exception {
|
||||
char ch = 0;
|
||||
if (scanner.hasNextLine()) {
|
||||
ch = scanner.nextLine().toCharArray()[0];
|
||||
}
|
||||
|
||||
return switch (ch) {
|
||||
case 'w' -> '^';
|
||||
case 's' -> 'v';
|
||||
case 'a' -> '<';
|
||||
case 'd' -> '>';
|
||||
case 'q' -> throw new Exception();
|
||||
default -> 'l';
|
||||
};
|
||||
}
|
||||
}
|
@ -1,18 +1,10 @@
|
||||
package src;
|
||||
|
||||
public class RumbleBot extends Bot{
|
||||
|
||||
|
||||
String[] playerChars = {"<",">","^","v"};
|
||||
int angle = 0;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
boolean left = false;
|
||||
boolean right = false;
|
||||
boolean up = false;
|
||||
boolean down = false;
|
||||
int turnCounter = 0;
|
||||
int waitTimer = 80;
|
||||
public class RumbleBot extends Bot {
|
||||
int stepCounter = 0;
|
||||
int turnCount = 0;
|
||||
int viewRange = 30;
|
||||
int straightLength = 1;
|
||||
|
||||
protected RumbleBot(String[] args) {
|
||||
super(args);
|
||||
@ -23,70 +15,79 @@ public class RumbleBot extends Bot{
|
||||
bot.run();
|
||||
}
|
||||
|
||||
protected char nextMove(View view){
|
||||
@Override
|
||||
protected char nextMove(View view) throws Exception {
|
||||
// Definition der gegnerischen Symbole
|
||||
String enemySymbols = "<>v^";
|
||||
|
||||
if(waitTimer > 0){
|
||||
waitTimer--;
|
||||
return 0;
|
||||
}
|
||||
//back away if possible
|
||||
if(playerAhead(view) && !view.data.substring(49,50).contains("X")){
|
||||
return 'v';
|
||||
}
|
||||
//shoot target
|
||||
if(playerAhead(view)){
|
||||
return 'f';
|
||||
}
|
||||
// Annahme: Sichtfeld ist 9x9, der Bot steht immer in der Mitte (Zeile 4, Spalte 4)
|
||||
final int gridSize = 9;
|
||||
final int centerRow = gridSize / 2; // 4
|
||||
final int centerCol = gridSize / 2; // 4
|
||||
|
||||
if(view.data.substring(39,40).contains("X") && view.data.substring(49,50).contains("X")){
|
||||
return '^';
|
||||
}else turnRight();
|
||||
// if (x <= 15 && !up){
|
||||
// x++;
|
||||
// return '^';
|
||||
// }else if(angle != 180){
|
||||
// up = true;
|
||||
// return turnRight();
|
||||
// }else if (x >= -15 && !down){
|
||||
// x--;
|
||||
// return '^';
|
||||
// } else if (angle != 0) {
|
||||
// down = true;
|
||||
// return turnRight();
|
||||
// }else if (x < 0){
|
||||
// x++;
|
||||
// return '^';
|
||||
// } else if (angle != 90 && x == 0) {
|
||||
// return turnRight();
|
||||
// } else if (y <= 15 && !right) {
|
||||
// y++;
|
||||
// return '^';
|
||||
// } else if (angle != 270) {
|
||||
// right = true;
|
||||
// return turnRight();
|
||||
// } else if(y >= -15 && !left){
|
||||
// y--;
|
||||
// return '^';
|
||||
// }else if(angle != 90){
|
||||
// turnRight();
|
||||
// }else if (y > 0){
|
||||
// y++;
|
||||
// return '^';
|
||||
// }
|
||||
return 0;
|
||||
}
|
||||
|
||||
private boolean playerAhead(View view){
|
||||
for (String s : playerChars){
|
||||
if(view.data.substring(4,5).contains(s) || view.data.substring(43,45).contains(s)){
|
||||
return true;
|
||||
// 1. Prüfe, ob sich ein Gegner in der direkten Schusslinie befindet.
|
||||
// Dabei werden die Zellen in der zentralen Spalte oberhalb des Bots untersucht (Reihen 0 bis 3).
|
||||
for (int row = 0; row < centerRow; row++) {
|
||||
int index = row * gridSize + centerCol;
|
||||
char cell = view.data.charAt(index);
|
||||
if (enemySymbols.indexOf(cell) != -1) {
|
||||
// Ein Gegner befindet sich direkt vor dem Bot – feuere!
|
||||
return 'f';
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
// 2. Falls kein Gegner in der Schusslinie ist, prüfe, ob überhaupt ein Gegner sichtbar ist.
|
||||
// Wenn keiner der gegnerischen Symbole im Sichtfeld vorkommt, folgt das Standard-Bewegungsmuster.
|
||||
if (view.data.indexOf('<') == -1 &&
|
||||
view.data.indexOf('>') == -1 &&
|
||||
view.data.indexOf('^') == -1 &&
|
||||
view.data.indexOf('v') == -1) {
|
||||
// Kein Gegner im Sichtfeld – bewege dich gemäß dem Bewegungsmuster:
|
||||
if (turnCount == 2) {
|
||||
turnCount = 0;
|
||||
straightLength++;
|
||||
}
|
||||
if (stepCounter < straightLength * viewRange) {
|
||||
stepCounter++;
|
||||
return '^';
|
||||
} else {
|
||||
stepCounter = 0;
|
||||
turnCount++;
|
||||
return '>';
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Es ist ein Gegner sichtbar, allerdings nicht direkt in der Schusslinie.
|
||||
// Bestimme, ob der Gegner eher links oder rechts liegt, und drehe in die entsprechende Richtung,
|
||||
// um den Gegner in Zukunft in die Schusslinie zu bekommen.
|
||||
boolean enemyOnLeft = false;
|
||||
boolean enemyOnRight = false;
|
||||
|
||||
// Untersuche dazu alle Zellen des Sichtfelds:
|
||||
for (int row = 0; row < gridSize; row++) {
|
||||
for (int col = 0; col < gridSize; col++) {
|
||||
int index = row * gridSize + col;
|
||||
char cell = view.data.charAt(index);
|
||||
if (enemySymbols.indexOf(cell) != -1) {
|
||||
// Vergleiche die Spalte der Zelle mit der Mitte (centerCol)
|
||||
if (col < centerCol) {
|
||||
enemyOnLeft = true;
|
||||
} else if (col > centerCol) {
|
||||
enemyOnRight = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (enemyOnLeft) {
|
||||
return '<';
|
||||
} else if (enemyOnRight) {
|
||||
return '>';
|
||||
}
|
||||
|
||||
// Sollte zwar ein Gegner sichtbar sein, aber weder links noch rechts – als Fallback fahre vorwärts.
|
||||
return '^';
|
||||
}
|
||||
|
||||
private char turnRight(){
|
||||
angle = (angle + 90) % 360;
|
||||
return '>';
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,31 +0,0 @@
|
||||
package src;
|
||||
|
||||
public class test extends Bot{
|
||||
|
||||
String[] playerChars = {"<",">","^","v"};
|
||||
|
||||
protected test(String[] args) {
|
||||
super(args);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
test bot = new test(args);
|
||||
bot.run();
|
||||
}
|
||||
|
||||
protected char nextMove(View view){
|
||||
if(playerAhead(view)){
|
||||
return 'f';
|
||||
}
|
||||
return '>';
|
||||
}
|
||||
|
||||
private boolean playerAhead(View view){
|
||||
for (String s : playerChars){
|
||||
if(view.data.substring(4,5).contains(s) || view.data.substring(13,14).contains(s)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user