你的工作是征服魔戒,但是等等,有许多其他球员联合在一起,面对你的团队!你需要用你的智慧去征服魔戒。
有三支队伍:红色、蓝色和绿色。团队是随意分配的。如果球队甚至你可以加入你选择的球队,否则你必须加入最小的球队(S)。这张地图是一个长640×640的圆环。让我们看一看地图样本。
OOOOOOOOOOOOOOOOOOOOOOOOOOO
RRRRRRRRRRRRRRRRRRRRRRRRRRR
OOOOOOOOOOOOOOOOOOOOOOOOOOO
GGGGGOOOOOOOOBBBBBBBBBBBBBB
GGGGGGGGGGGGGGGGGGGGGOOOOOG
OOOOOOOOOOOOOOOOOOOOOOOOOGG
RRRRRRRRRRRRRRRRRRRRRRRRRRR
OOOOOOOOOOOOOOOOOOOOOOOOOOO正如你所看到的,红队已经建造了一堵墙来安全地征服这两堵墙之间的领土。蓝色的,绿色的就得把它拼出来。这张缩小版的地图代表了更大的地图。
红色很有可能赢得这场战斗,因为他们将完成游戏(一旦棋盘被填满或大量转弯已经通过),拥有最多的领土。
现在每个机器人都有一个位置(只有你知道)。您只能移动到相邻的广场,如果它是您的团队拥有。在游戏开始的时候,你从你的团队颜色的一个方块开始。你的目标是通过征服其他土地来扩大这片土地。在任何时候,你可以选择移动到任何相邻的颜色,你自己的领土,或者你可以选择攻击一个邻近的领土。如果被攻击的广场没有所有权,它就会被占领。
您将覆盖Bot类,返回一个试图移动的数字(0-3)和4-7的尝试攻击。您的机器人移动只需10毫秒,但除非成为问题,否则规则不会被正式强制执行。问题,恶意,或其他令人讨厌的机器人显然不符合这一竞争的精神,并将被取消立即低质量的旗帜。否则的话,机器人的行为是真诚的,但否则的话,小马车将得到必要的时间,以修复错误。方法总结
public abstract class Bot{
public final int team;// 0 = red 1 = green 2 = blue
public Bot(int inTeam){team=inTeam}//be sure to call super(inTeam);
public int move(){};//you will override this
}
Methods available
Color Bot.getColor(int x,int y){}//returns a Color object with rgb values where the r g or b value of the team owning it will be 100.
getX(); returns the X position of your bot
getY(); returns the y position of your bot
Bot.getMap();//returns the array representing the map. I.e Bot.getMap[i][j] returns a color with r g b values representing each teams stake in that spot.
//only one r g b value will be greater than 0 as only one team can hold a spot
Do not abuse the map access. Giving direct access (as opposed to a copy) is to speed up access to the map. Abusing it will result in disqualification!一个包装程序可以提供,只要它仍然允许程序顺利运行。
第一步:在这里张贴你的机器人作为一个答案,并确保它遵循规格。
第二步到这个gitHub存储库分叉它,并在'//init‘Bot.run之后添加你的机器人的文件,以及添加这两行。如果适用的话,一定要选择成员最少的团队。
bots.add(new UniqueBotNameHere(team=choiceOfTeam,x=getRandom(0,map.length),y=getRandom(0,map[0].length)));
map[x][y].colors[team]=255;第三步:提出拉请求。我将接受你的拉请求和你的机器人将自动添加到比赛。
第四步:下载源文件并将它们复制到适当的包中。运行构建,并享受观看机器人
祝你好运,不要让你的团队失望!即使是我的机器人样本也会制造团队的。我也可以在团队周围走动,以确保成员平等。
修改了半心半意的洪水填充样例机器人,给出了一个有趣的地图生成器。

发布于 2016-08-02 21:53:22
他建了一堵墙,但他不能让另一支球队为此付出代价!他制作了一个不错的低级机器人来帮助调试你的提交。
public class Trump extends Bot{
int moves;
int direction;
public Trump(int team, int inX, int inY) {
super(team, inX, inY);
direction = Bot.getRandom(0, 4);
}
@Override
public int move() {
int ret = direction;
switch(++moves%4){
case 0:
ret = direction+4;
break;
case 1:
ret = direction;
break;
case 2:
ret = direction + 1;
break;
case 3:
ret = direction +3;
}
return ret;
}
}发布于 2016-08-02 22:02:50
另一个低级机器人。他试图填满地图,但他只付出了50%的努力!我将进入另一个更有竞争力的机器人,但这家伙只是为了演示一种可能的方法。
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package toroidal.domination;
import java.awt.Color;
import java.util.Stack;
/**
*
* @author rohan
*/
public class HalfHeartedFloodFillBot extends Bot{
public static class Node{
public final int x,y;
public Node(int x, int y){
this.x=x;this.y=y;
}
}
private Stack<Integer> nodes = new Stack<>();
public HalfHeartedFloodFillBot(int team, int inX, int inY) {
super(team, inX, inY);
}
@Override
public int move() {
int x,y;
for(int i = 0;i<4;i++){
if(isEmpty(Bot.getColorAtSpot(x=getX()+(int) Math.cos(i*Math.PI/2),y= getY()+(int) Math.sin(i*Math.PI/2)))){
nodes.add((i+2)%4);
return i+4;
}
}
//no empty spots found try to backtrack or just do stuff!
return nodes.isEmpty()?Bot.getRandom(0,2)==0?Bot.getRandom(0, 2)==0?0:1:Bot.getRandom(0, 2)==0?2:3:nodes.pop();
}
boolean isEmpty(Color c){
int r = c.getRed();
int g = c.getGreen();
int b = c.getBlue();
return r == 0 && b == 0&& g == 0;
}
}发布于 2016-08-10 20:50:42
这个机器人会一直走,直到他碰到一些非中性的东西,然后向左转,在自由空间中形成一个螺旋。
public class SpiralBot extends Bot{
int d;
public SpiralBot (int team, int inX, int inY) {
super(team, inX, inY);
d = 0;
}
int dx(int move){
return (int) Math.cos(move * Math.PI / 2);
}
int dy(int move){
return (int) Math.sin(move * Math.PI / 2);
}
@Override
public int move() {
int x = getX();
int y = getY();
Color[]c = new Color[4];
for(int i = 0;i<4;i++)
c[i] = Bot.getColor(x+dx(i), y+dy(i));
if(c[d].equals(Color.black))
return d;
if(c[(d+1)%4].equals(Color.black))
return d = (d+1)%4;
if(c[(d+3)%4].equals(Color.black))
return d = (d+3)%4;
return d + 2;
}
}我对GitHub不感兴趣,所以如果有人能为我推动这件事,那就太好了。谢谢。
https://codegolf.stackexchange.com/questions/87473
复制相似问题