KOTH:全球大流行


82

最终结果在这里!

介绍

在2042年,世界变得人口过多。全球化,人满为患,新的生活方式以及全球缺乏卫生条件导致了新的流行病蔓延。在那些困难时期,国家领导人必须管理局势。您不能让人口大量减少,但也许可以让邻居死掉而受益……

词汇表

健康:人们没有感染
感染:谁可以从大流行死亡人
死亡:尸体数量,没有特别的影响(只计分)
感染率:数健康谁就会成为感染每回合
传染率:百分比感染,将转换健康被感染每回合
死亡率:每回合将死亡的感染百分率
迁移率:每回合将迁移/迁徙的健康感染百分率
当地:仅影响您的州
全局:影响每个州

原理

每个参与者将从100个人开始管理一个城镇。不幸的是,其中有一个被感染

该游戏是回合制的。转弯由七个阶段组成,最后一个阶段是交互式的(向机器人询问命令)。玩家的顺序在每个回合中都是随机的。下一个阶段在每个城镇都执行了上一个阶段时开始(第1轮:玩家1,第2玩家,...;第2轮:第3玩家,第2玩家,第1玩家...):

1. Mutation                                 - AUTOMATED
2. Reproduction                             - AUTOMATED
3. Migration                                - AUTOMATED
4. Infection                                - AUTOMATED
5. Contagion                                - AUTOMATED
6. Extinction                               - AUTOMATED
7. Players Turn                             - INTERACTIVE

控制器通过命令参数为您提供输入,而程序必须通过stdout输出。

句法

输入值

每次调用程序时,它将收到以下格式的参数:

Round;YourPlayerId;PlayerId_Healthy_Infected_Dead_InfectionRate_ContagionRate_LethalityRate_MigrationRate;PlayerId_Healthy_Infected_Dead_InfectionRate_ContagionRate_LethalityRate_MigrationRate;...

回合均为1索引。

输入示例

6;2;1_106_23_9_2_4_13_5;0_20_53_62_16_20_35_5;2_20_53_62_16_20_35_5

在这里,您看到它是第六轮,您是玩家2。您有20位健康,53位感染,62位死亡,16%的感染率,20%的传染率,35%的致死率和5%的迁移率。

输出量

您必须输出三个字符(无空格,无分隔符),每个字符对应于本轮将要执行的一个动作。字符的顺序决定了动作的顺序。您可以多次输出相同的动作。

N:执行Ñ othing
M:研究中号 icrobiology [效果:减少本地传染率 4%]
E:研究È pidemiology [效果:减少本地传染率 8%]
I:研究 mmunology [效果:减少本地致死率 4%]
V:研究V预防接种的[效果:减少本地传染率被一个,减少局部传染率 4%,减少局部致死率 2%]
C:给ç URE [效果:转换10局部感染健康 ]
QQ uarantine [效果:移除30个本地感染者 ]
OO边界[效果:将本地迁移率提高10%]
B:关闭B订单[效果:将本地迁移率降低10%]
T:Bio T错误[效果:转换4全球健康感染 ]
Ww ^ eaponization [效果:增加全球传染率通过1,增加全球致死率 2%]
Dd issemination [效果:增加全球感染率通过如图1所示,增加全球传染率 2%]
PP acification [效果:减少全球传染率通过1,减少全球传染率 1%,减少全球致死率 1%]

游戏玩法

所有阶段

无效的命令 =没有
百分比像整数一样累加,即10%-4%= 6%。在公式中应用百分比时,结果将被下限。

阶段1:变异

大流行变得越来越有力。每回合,它随机获得以下属性之一(此突变会同时影响所有玩家):

  • 全球感染率提高2
  • 全球传染率提高5%
  • 全球致死率提高5%

阶段2:复制

每五轮比赛(第5、10、15轮...)将诞生新的公民。每对健康者将使一个健康者(23个健康者产生11个新的健康者)。每对感染都会造成一个感染

阶段3:迁移

每回合,根据迁移率的不同,一部分健康受感染的人将离开州(10个健康人将离开一个州,其健康状况为100 ,迁移率为 10%)。然后,将再次根据移民率在各个州之间分配移民。(对每个州的比率进行加权,然后对移民进行相应分配)。

阶段4:感染

健康每个状态被转换为感染,根据感染率

阶段5:传染

根据传染率,将每个状态的健康状态都转换为感染状态。数乘以计算出的感染传染率

阶段6:灭绝

根据死亡率感染者会转化为死亡。数乘以计算出的感染致死率

阶段7:玩家回合

每个玩家都收到输入,并且必须输出三个动作,这些动作按照输出的顺序执行。

规则

  • 不得将Bot写为击败或支持其他特定的Bot。
  • 允许写入文件。请写入“ yoursubmissionname.txt”,游戏开始前该文件夹将被清空。禁止使用其他外部资源。
  • 您的提交有1秒钟的响应时间(每个镇)。
  • 提供命令以编译和运行提交。

获奖

获胜者是50轮后最健康的赢家。如果玩家是最后一位在世(超过0个“ 健康”或“ 感染”),游戏将停止并获胜。如果多个玩家有相同数量的健康,在一个大多数感染会获胜,那么一个用更少的秒。

控制者

您可以在GitHub上找到控制器。它还包含三个用Java编写的samplebot。
要使其运行,请签出项目并在Java IDE中将其打开。main类方法中的入口点Game。需要Java 8。

要添加机器人,首先需要Java的编译版本(.class文件)或解释语言的源代码。将它们放置在项目的根文件夹中。然后,在players包中创建一个新的Java类(您可以在已经存在的机器人上举个例子)。此类必须实现Player以重写方法String getCmd()。返回的字符串是运行您的机器人的shell命令。例如,你可以让使用此命令红宝石机器人的工作:return "C:\Ruby\bin\ruby.exe MyBot.rb";。最后,将Bot添加playersGame类顶部的数组中。

最终结果(2016-03-04 08:22 GMT)

全球(100声望):

100场比赛结果:http : //pasted.co/942200ff

1. EvilBot (24, 249, 436)
2. Triage (23, 538, 486)
3. WICKED (23, 537, 489)
4. Israel (23, 40, 240)
5. InfectedTown (22, 736, 482)
6. ZombieState (22, 229, 369)
7. Mooch (22, 87, 206)
8. InfectedHaven (21, 723, 483)
9. Crossroads (16, 9, 136)
10. TheKeeper (3, 4, 138)
11. Terrorist (0, 595, 496)
12. InfectionBot (0, 511, 430)
13. FamilyValues (0, 6, 291)
14. UndecidedBot (0, 0, 20)
15. XenoBot (0, 0, 26)
16. Researcher (0, 0, 33)
17. Strategist (0, 0, 42)
18. TheCure (0, 0, 55)
19. Socialist (0, 0, 67)
20. TrumpBot (0, 0, 77)
21. CullBot (0, 0, 81)
22. BackStabber (0, 0, 87)
23. BlunderBot (0, 0, 104)
24. RemoveInfected (0, 0, 111)
25. PFC (0, 0, 117)
26. BioterroristBot (0, 0, 118)
27. PassiveBot (0, 0, 118)
28. Smaug (0, 0, 118)
29. WeaponOfMassDissemination (0, 0, 119)
30. AllOrNothing (0, 0, 121)
31. Obamacare (0, 0, 122)
32. DisseminationBot (0, 0, 123)
33. CureThenQuarantine (0, 0, 125)
34. Madagascar (0, 0, 129)
35. OpenAndClose (0, 0, 129)
36. ThePacifist (0, 0, 130)
37. MedicBot (0, 0, 131)
38. Medic (0, 0, 133)
39. Salt (0, 0, 134)
40. Piecemeal (0, 0, 136)
41. Graymalkin (0, 0, 137)
42. PureBot (0, 0, 140)
43. MadScienceBot (0, 0, 144)
44. BipolarBot (0, 0, 149)
45. RedCross (0, 0, 151)

世界末日少(200点声望):

100个游戏结果:http : //pasted.co/220b575b

1. FamilyValues (5708, 14, 2)
2. BlunderBot (5614, 12, 3)
3. Graymalkin (5597, 17, 4)
4. PureBot (5550, 12, 5)
5. Crossroads (5543, 11, 4)
6. Salt (5488, 24, 7)
7. CureThenQuarantine (5453, 13, 7)
8. Piecemeal (5358, 121, 23)
9. TrumpBot (5355, 12, 5)
10. CullBot (5288, 12, 9)
11. AllOrNothing (5284, 13, 10)
12. Madagascar (5060, 180, 35)
13. TheKeeper (4934, 165, 44)
14. WICKED (4714, 25, 5)
15. Strategist (2266, 25, 5)
16. BackStabber (2180, 1327, 596)
17. RemoveInfected (2021, 33, 27)
18. OpenAndClose (1945, 667, 394)
19. Triage (1773, 401, 80)
20. TheCure (1465, 46, 26)
21. Obamacare (1263, 525, 247)
22. Mooch (1103, 546, 269)
23. Israel (1102, 580, 292)
24. RedCross (1086, 1700, 727)
25. ThePacifist (1069, 636, 580)
26. Researcher (1035, 113, 37)
27. UndecidedBot (825, 219, 93)
28. PassiveBot (510, 990, 567)
29. MedicBot (411, 1474, 667)
30. Medic (392, 1690, 619)
31. Socialist (139, 63, 90)
32. XenoBot (0, 82, 170)

谢谢大家的参与。我希望您能像我运行游戏一样花很多时间来设计和编码您的机器人。


9
我们可以得到一个è xecute吩咐谋杀X的量感染(他们转向直接到死)?可能不是一种可行的取胜方法,但似乎是合法的举动。除非那是隔离所所做的(尚不清楚)。
Draco18s

3
快速的语法注释:“理智”是指“心理稳定”;您正在(可能)在此处查找的字词是“健康”。(我猜您的母语是西班牙语,“ s​​ano”是“健康”还是紧密相关的东西,我会猜对吗?)
Mason Wheeler

5
@MasonWheeler Nitpicking术语注释:您的注释是术语或词汇注释,因为不涉及语法;)
1

3
@Thrax当前处理转弯的方式(在开始时是随机的,从此以后是相同的顺序),这给在转弯顺序中排在后面的玩家带来了巨大的优势,这使得最终结果大为不同。也许,如果您要么1)在每个回合中随机分配回合顺序,要么2)让每个人在回合中查看相同的状态,并在回合结束时将更改同时应用于每个人,那么结果可能会更加平衡,并基于有关提交质量的更多信息。我测试了第一个选项,结果更加一致。
Mwr247 '16

7
@Thrax当前有大量的机器人可以简单地“摧毁世界”。尽管这可能是一个有趣的挑战,但在这一点上,实际上试图进行竞争的机器人无法再有效地应对它,而最终剩下的任何被编程为“治愈X 3”的机器人都将成为赢家。我想建议一个规则更改,为了让KOTH能够被考虑,机器人至少需要能够在与PassiveBot的1对1比赛中以正“ sanes”结束?当策略真正发挥作用时,挑战会更加有趣。
Mwr247 '16

Answers:


12

家庭价值观,节点(ES6)

// Process input
var data = process.argv[2].split(';');
var round = data.shift()*1;
var id = data.shift()*1;
var playerCount = data.length;
var local = data.find(function(v) {
  return !v.indexOf(id+'_')}
).split('_');
local = {
  sane: local[1]*1,
  infected: local[2]*1,
  dead: local[3]*1,
  infectionRate: local[4]*1,
  contagionRate: local[5]*1,
  lethalityRate: local[6]*1,
  migrationRate: local[7]*1
};

// Determine response
var response = [];
for(var i=0;i<3;i++) {
  var model = {
    M: local.infectionRate,
    E: local.contagionRate * (local.sane > 0 ? 1 : 0.5),
    I: local.lethalityRate * (round > 45 ? 0 : local.sane > 0 ? 1 : 2),
    V: (local.infectionRate/4 + local.contagionRate/2 + local.lethalityRate/2) * (round > 45 ? 0 : 1),
    C: local.infected / Math.max(local.infectionRate, 1) * (round > 48 ? round : local.infectionRate + local.contagionRate/100 * local.infected < (3 - i) * 10 ? 1 : 0),
    B: local.migrationRate * 10
  };
  var max = 'M';
  for(k in model) {
    if (model[k] > model[max] ) {
      max = k;
    } else if(model[k] == model[max]) {
      max = [max, k][Math.random()*2|0];
    }
  }
  response.push(max);

  // Refactor priorities
  if(max == 'M') {
    local.infectionRate -= 4;
  } else if(max == 'E') {
    local.contagionRate -= 8;
  } else if(max == 'I') {
    local.lethalityRate -= 4;
  } else if(max == 'V') {
    local.infectionRate -= 1;
    local.contagionRate -= 4;
    local.lethalityRate -= 2;
  } else if(max == 'C') {
    local.infected -= 10;
  } else if(max == 'B') {
    local.migrationRate -= 10;
  }
}

// Respond with actions
process.stdout.write(response.join(''));

家庭价值观注重自我保护和防御,并且仅为此目的而采取行动。它使用点值系统来确定最佳操作方案,然后调整其自身的状态值以更好地确定其下一个优先级。如果出现平局,它将从最佳选项中随机选择。

编辑:到目前为止似乎做的还不错:

    ********** FINISH **********
    1. FamilyValues (1143, 0, 188)
    2. Triage (582, 0, 158)
    3. Researcher (281, 0, 142)
    4. Madagascar (149, 0, 162)
    5. Mooch (148, 0, 331)
    6. MedicBot (142, 0, 161)
    7. Medic (66, 65, 211)
    8. XenoBot (0, 0, 22)
    9. WMDbot (0, 0, 218)
    10. PassiveBot (0, 0, 221)
    11. BioterroristBot (0, 0, 221)
    12. MadScienceBot (0, 0, 221)
    13. DisseminationBot (0, 0, 221)
    14. TheCure (0, 0, 222)

和平主义者,节点

// Process input
var data = process.argv[2].split(';');
var round = data.shift()*1;

// Respond with actions
process.stdout.write(round == 1 ? 'OOO' : 'PPP');

和平主义者非常关注杀戮和死亡,因此认为强大的全球健康意味着强大的本地健康。因此,他们几乎只专注于减少全球疾病,同时保留部分边界以允许善良四处传播。


哇,我没想到TheCure会是最后一

@justhalf有了这么多的玩家,他们最终都在棋盘上四处走动:现在只跑一个,TheCure排名第三。不过,FamilyValues和Triage几乎始终排在前两位,而FV大部分时间都排名第一。
Mwr247 '16

嗯,任务本身就是确定性的,对吧?那是由于某些玩家将随机性纳入他们的算法中吗?
Justhalf '16

@justhalf到目前为止,最大的因素似乎是回合顺序,该顺序是随机的(但游戏中每回合都一样)。先走意味着您在当前回合中没有机会对每个人的动作做出反应,而走到最后则使您能够最佳地适应其他玩家对您所做的事情。
Mwr247 '16

1
@justhalf我刚刚测试了一个改进的控制器,该控制器随机化每一轮的回合顺序,现在的结果更加一致。
Mwr247 '16

27

特朗普

private void sleep(String[] args) {

    round = Integer.parseInt(args[0]);
    thisTownID = Integer.parseInt(args[1]);

    states = new ArrayList<>();
    //states.add(new State(args[thisTownID+2]));

    otherStates = new ArrayList<>();


    for (int i = 2; i < args.length; i++){
        states.add(new State(args[i]));
    }

    for (State state : states){
        if (state.ownerId == thisTownID) {
            thisState = state;
        } else {
            otherStates.add(state);
        }
    }

    StringBuilder cmd = new StringBuilder();

    for (int j =0;j<3;j++){
        if (thisState.infected > 7) {
          if (thisState.infected > 25){
            cmd.append("Q");
            thisState.infected -= 30;
          }
          else {
            cmd.append("C");
            thisState.infected -= 10;
          }
        }
        else if (thisState.migrationRate > 2) {
          cmd.append("B");
          thisState.migrationRate -= 10;
        }
        else if (thisState.infectionRate > 4) {
          cmd.append("M");
          thisState.infectionRate  -= 4;
        }
        else if (thisState.contagionRate > 10 || thisState.lethalityRate > 6 || thisState.infectionRate > 0) {
          cmd.append("V");
          thisState.contagionRate  -= 4;
          thisState.lethalityRate  -= 2;
          thisState.infectionRate  -= 1;
        }

        else if (thisState.infected % 10 <= 6){
          cmd.append("T");
          thisState.infected +=4;
        }
        else cmd.append("V");
    }
    System.out.print(cmd.reverse());
}

治愈所有被感染的人,除非只有2个或更少的人,否则它会使美国变得更好。少数群体将被忽略。

更少的感染使这种药物更便宜。

不需要移民-他们只带来感染。

如果什么也没做,那就炸其他玩家。

以美式方式颠倒命令顺序,炸弹先治愈人们。

编辑:修复了垃圾邮件可以治愈的错误,因为治愈后感染人数并未降低。

喇叭

感谢J Atkin提供:

Make turn 4000000
As long as, turn larger than 1000000;:
If, refugee count > 2000000;: say "C"!
Else if, infectionRate > 200000;: say "M"!
Else if, immigration rate > 9000000;: say "B"!
Else: say "T"!
Make turn old turn - 1000000!
America is Great. 

14

全部或全部,R

args <- strsplit(commandArgs(TRUE),";")[[1]]
round <- as.integer(args[1])
me <- as.integer(args[2])
stats <- do.call(rbind,strsplit(args[-(1:2)],"_"))
stats <- as.data.frame(apply(stats,2,as.integer))
colnames(stats) <- c("id","Sane","Infected","Dead","InfRate","ContRate","LethRate","MigRate")
out <- ""
statme <- stats[stats$id==me,]
while(nchar(out)<3){
    if(round==1 & !nchar(out)){
        out <- paste0(out, "B")
    }else if(round%%5==4 & statme$Infected > 20){
        statme$Infected <- statme$Infected - 30
        out <- paste0(out, "Q")
    }else if(statme$Sane*statme$InfRate/100 >= 1){
        o <- ifelse(statme$Sane*statme$InfRate/100 < statme$Infected*statme$ContRate/100, "C", "M")
        if(o=="C") statme$Infected <- statme$Infected - 10
        if(o=="M") statme$InfRate <- statme$InfRate - 4
        out <- paste0(out, o)
    }else if(statme$Infected > 0){
        statme$Infected <- statme$Infected - 10
        out <- paste0(out, "C")
    }else if(median(stats$LethRate)<20){ 
        out <- paste0(out, "W")
    }else{
        out <- paste0(out, "E")     
    }
}
cat(substr(out,1,3))

由调用Rscript AllOrNothing.R

这里的想法是一方面将感染的最大风险(通过降低感染率,治愈感染者并防止感染者移民)限制到最大,另一方面增加疾病的致死率,使确诊的人被感染,在污染他人之前死亡。

编辑:稍微调整了策略。


很好,它对其他21个州的表现似乎特别出色!
Thrax

@Thrax实际上,尽管偶尔在某些运行过程中,它仍然会令人印象深刻地失败:)但是,大多数情况下,它会在您的测试运行中成功。
plannapus

那真是个了不起的机器人,干得好
Eumel 2016年

这看起来与我发现时间时要写的状态非常相似(如果不一致)。我的脑袋虽然只有我的脑子(“如果感染了20欧元,则将其隔离,如果感染10欧元,则将其治愈等等”)是如此出色的工作。
Draco18s

13

军医

军医总是…… 无药可救的人感到困扰。他喜欢练习医学,所以这就是他的全部。他还喜欢python,因此他用Python编写了代码。如果您考虑一下,这一切都是有道理的。不,实际上不是。实际上,它确实...

from random import *
commands = ""
while len(commands) < 3:
    chance = random()
    if chance < .5: commands += "V"
    elif chance < .66: commands += "I"
    elif chance < .84: commands += "E"
    else: commands += "M"

print(commands)

我是来帮忙的。

我是来帮忙的。


4
Python就像Asclepius一样吗?还是像爱马仕的员工一样?这可能是有道理的……
不是查尔斯(Charles)

3
要么!都!为什么不?这一切都说得通!
科纳·奥布莱恩

7
++ 1; 对于TF2:D

11

治愈

这似乎太简单了,但它似乎也是降低感染/死亡率的一种很好的方法。每转,输出MCQ

  • 降低感染率
  • 治愈一些感染
  • 隔离剩下的一些感染者

而已!

public class TheCure{
    public static void main(String[]a){
        System.out.println("MCQ");
    }
}

如果目前没有被感染的话,我可以通过输出更多M(或B)而不是进行固化和隔离来改善此效果,但我想先看看效果如何。不幸的是,先发布的一个副作用是很难评估有效性:


9

邪恶的科特林

记住,WICKED很好。

package wicked

import java.util.*

fun clamp(value : Double, floor : Double, ceil : Double = Double.POSITIVE_INFINITY) = Math.max(Math.min(value, ceil), floor)
fun clamp(value : Int, floor : Int, ceil : Int = Integer.MAX_VALUE) = Math.max(Math.min(value, ceil), floor)

data class Player(
        val id            : Int,
        var healthy          : Int,
        var infected      : Int,
        var dead          : Int,
        var infectionRate : Int,
        var contagionRate : Double,
        var lethalityRate : Double,
        var migrationRate : Double)

class Game(val players : List<Player>) {

    fun doAction(playerId: Int, a: Char) {
        val player = players.first { it.id == playerId }
        with(player) {
            when (a) {
                'N' -> {}
                'M' -> infectionRate = clamp(infectionRate - 4, 0)
                'E' -> contagionRate = clamp(contagionRate - .08, 0.0, 1.0)
                'I' -> lethalityRate = clamp(lethalityRate - .04, 0.0, 1.0)
                'V' -> {
                    infectionRate = clamp(infectionRate - 1, 0)
                    contagionRate = clamp(contagionRate - .04, 0.0, 1.0)
                    lethalityRate = clamp(lethalityRate - .02, 0.0, 1.0)
                }
                'C' -> {
                    val cured = Math.min(infected, 10)
                    infected -= cured
                    healthy += cured
                }
                'Q' -> infected = clamp(infected - 30, 0)
                'O' -> migrationRate = clamp(migrationRate + .1, 0.0, 1.0)
                'B' -> migrationRate = clamp(migrationRate - .1, 0.0, 1.0)
                'T' -> {
                    players.forEach {
                        val infected = Math.min(it.healthy, 4)
                        it.healthy -= infected
                        it.infected += infected
                    }
                }
                'W' -> {
                    players.forEach {
                        it.infectionRate++
                        it.lethalityRate = clamp(it.lethalityRate + .02, 0.0, 1.0)
                    }
                }
                'D' -> {
                    players.forEach {
                        it.infectionRate++
                        it.contagionRate = clamp(it.contagionRate + .02, 0.0, 1.0)
                    }
                }
                'P' -> {
                    players.forEach {
                        it.infectionRate = clamp(it.infectionRate - 1, 0)
                        it.contagionRate = clamp(it.contagionRate - .01, 0.0, 1.0)
                        it.lethalityRate = clamp(it.lethalityRate - .01, 0.0, 1.0)
                    }
                }
                else -> throw IllegalArgumentException("Invalid action: $a")
            }
        }
    }

    fun copy() = Game(players.map { it.copy() })

    fun migration() {
        var migratingHealthy = 0
        var migratingInfected = 0
        var totalMigratingWeight = 0.0

        players.forEach {
            migratingHealthy += (it.healthy * it.migrationRate).toInt()
            migratingInfected += (it.infected * it.migrationRate).toInt()
            totalMigratingWeight += it.migrationRate

            it.healthy = (it.healthy * (1 - it.migrationRate)).toInt()
            it.infected *= (it.healthy * (1 - it.migrationRate)).toInt()
        }

        players.forEach {
            it.healthy += (migratingHealthy * it.migrationRate / totalMigratingWeight).toInt()
            it.infected += (migratingInfected * it.migrationRate / totalMigratingWeight).toInt()
        }
    }

    fun infection() {
        players.forEach {
            val infected = it.infectionRate //Allow negative healthy.
            it.healthy -= infected
            it.infected += infected
        }
    }

    fun contagion() {
        players.forEach {
            val infected = (it.infected * it.contagionRate).toInt()
            it.healthy -= infected
            it.infected += infected
        }
    }

    fun extinction() {
        players.forEach {
            val killed = (it.infected * it.lethalityRate).toInt()
            it.infected -= killed
            it.dead += killed
        }
    }

    operator fun get(playerId : Int) = players.first { it.id == playerId }

    fun calculateBenefit(action : Char, myId: Int) : Int {

        val copy1 = copy()
        copy1.doAction(myId, action)

        copy1.migration()
        copy1.infection()
        copy1.contagion()
        copy1.extinction()

        return copy1[myId].healthy
    }

}

fun main(args : Array<String>) {
    @Suppress("NAME_SHADOWING")
    val args = args[0].split(';')

    val round = args[0].toInt()
    val myId = args[1].toInt()

    val players : MutableList<Player> = ArrayList()

    for ( i in 2..args.size-1) {
        val data = args[i].split('_')
        players.add(Player(data[0].toInt(), data[1].toInt(), data[2].toInt(), data[3].toInt(), data[4].toInt(), data[5].toDouble() / 100, data[6].toDouble() / 100, data[7].toDouble() / 100))
    }

    val currentGame = Game(players)

    if (round == 50) {
        println("CCC")  //Extra 30 at end of game.
        return
    }

    for (i in 1..3) {
        val action = determineBestAction(currentGame, myId)
        currentGame.doAction(myId, action)
        print(action)
    }
}

fun determineBestAction(game : Game, myId : Int) : Char {

    if (game[myId].lethalityRate > .02) {        //Save the executives!!!
        return 'I'
    } else if (game[myId].lethalityRate > 0) {
        return 'V'
    }

    val bestAction = "NMEIVQCOBP".maxBy { game.calculateBenefit(it, myId) }!!

    return bestAction

}

编译方式:kotlinc WICKED.kt
运行方式:kotlin wicked.WICKEDKt

PFC,科特林

试图在所有人身上释放这种疾病。

package pfc

import java.util.*

fun clamp(value : Double, floor : Double, ceil : Double = Double.POSITIVE_INFINITY) = Math.max(Math.min(value, ceil), floor)
fun clamp(value : Int, floor : Int, ceil : Int = Integer.MAX_VALUE) = Math.max(Math.min(value, ceil), floor)

data class Player(
        val id            : Int,
        var healthy          : Int,
        var infected      : Int,
        var dead          : Int,
        var infectionRate : Int,
        var contagionRate : Double,
        var lethalityRate : Double,
        var migrationRate : Double)

class Game(val players : List<Player>) {

    fun doAction(playerId: Int, a: Char) {
        val player = players.first { it.id == playerId }
        with(player) {
            when (a) {
                'N' -> {}
                'M' -> infectionRate = clamp(infectionRate - 4, 0)
                'E' -> contagionRate = clamp(contagionRate - .08, 0.0, 1.0)
                'I' -> lethalityRate = clamp(lethalityRate - .04, 0.0, 1.0)
                'V' -> {
                    infectionRate = clamp(infectionRate - 1, 0)
                    contagionRate = clamp(contagionRate - .04, 0.0, 1.0)
                    lethalityRate = clamp(lethalityRate - .02, 0.0, 1.0)
                }
                'C' -> {
                    val cured = Math.min(infected, 10)
                    infected -= cured
                    healthy += cured
                }
                'Q' -> infected = clamp(infected - 30, 0)
                'O' -> migrationRate = clamp(migrationRate + .1, 0.0, 1.0)
                'B' -> migrationRate = clamp(migrationRate - .1, 0.0, 1.0)
                'T' -> {
                    players.forEach {
                        val infected = Math.min(it.healthy, 4)
                        it.healthy -= infected
                        it.infected += infected
                    }
                }
                'W' -> {
                    players.forEach {
                        it.infectionRate++
                        it.lethalityRate = clamp(it.lethalityRate + .02, 0.0, 1.0)
                    }
                }
                'D' -> {
                    players.forEach {
                        it.infectionRate++
                        it.contagionRate = clamp(it.contagionRate + .02, 0.0, 1.0)
                    }
                }
                'P' -> {
                    players.forEach {
                        it.infectionRate = clamp(it.infectionRate - 1, 0)
                        it.contagionRate = clamp(it.contagionRate - .01, 0.0, 1.0)
                        it.lethalityRate = clamp(it.lethalityRate - .01, 0.0, 1.0)
                    }
                }
                else -> throw IllegalArgumentException("Invalid action: $a")
            }
        }
    }

    fun copy() = Game(players.map { it.copy() })

    fun migration() {
        var migratingHealthy = 0
        var migratingInfected = 0
        var totalMigratingWeight = 0.0

        players.forEach {
            migratingHealthy += (it.healthy * it.migrationRate).toInt()
            migratingInfected += (it.infected * it.migrationRate).toInt()
            totalMigratingWeight += it.migrationRate

            it.healthy = (it.healthy * (1 - it.migrationRate)).toInt()
            it.infected *= (it.healthy * (1 - it.migrationRate)).toInt()
        }

        players.forEach {
            it.healthy += (migratingHealthy * it.migrationRate / totalMigratingWeight).toInt()
            it.infected += (migratingInfected * it.migrationRate / totalMigratingWeight).toInt()
        }
    }

    fun infection() {
        players.forEach {
            val infected = Math.min(it.healthy, it.infectionRate)
            it.healthy -= infected
            it.infected += infected
        }
    }

    fun contagion() {
        players.forEach {
            val infected = Math.min(it.healthy, (it.infected * it.contagionRate).toInt())
            it.healthy -= infected
            it.infected += infected
        }
    }

    fun extinction() {
        players.forEach {
            val killed = (it.infected * it.lethalityRate).toInt()
            it.infected -= killed
            it.dead += killed
        }
    }

    operator fun get(playerId : Int) = players.first { it.id == playerId }

    fun calculateBenefit(action : Char, myId: Int) : Int {

        val copy1 = copy()
        copy1.doAction(myId, action)

        copy1.migration()
        copy1.infection()
        copy1.contagion()
        copy1.extinction()

        return copy1.players.sumBy { it.infected }
    }

}

fun main(args : Array<String>) {
    @Suppress("NAME_SHADOWING")
    val args = args[0].split(';')

    @Suppress("UNUSED_VARIABLE")
    val round = args[0].toInt()
    val myId = args[1].toInt()

    val players : MutableList<Player> = ArrayList()

    for ( i in 2..args.size-1) {
        val data = args[i].split('_')
        players.add(Player(data[0].toInt(), data[1].toInt(), data[2].toInt(), data[3].toInt(), data[4].toInt(), data[5].toDouble() / 100, data[6].toDouble() / 100, data[7].toDouble() / 100))
    }

    val currentGame = Game(players)

    for (i in 1..3) {
        val action = determineBestAction(currentGame, myId)
        currentGame.doAction(myId, action)
        print(action)
    }
}

fun determineBestAction(game : Game, myId : Int) : Char {

    val bestAction = "NMEIVCQOBTWDP".maxBy { game.calculateBenefit(it, myId) }!!

    return bestAction

}

编译方式:kotlinc PFC.kt
运行方式:kotlin pfc.PFCKt

恐怖分子,科特林

试图使所有人死亡。

package terrorist

import java.util.*

fun clamp(value : Double, floor : Double, ceil : Double = Double.POSITIVE_INFINITY) = Math.max(Math.min(value, ceil), floor)
fun clamp(value : Int, floor : Int, ceil : Int = Integer.MAX_VALUE) = Math.max(Math.min(value, ceil), floor)

data class Player(
        val id            : Int,
        var healthy          : Int,
        var infected      : Int,
        var dead          : Int,
        var infectionRate : Int,
        var contagionRate : Double,
        var lethalityRate : Double,
        var migrationRate : Double)

class Game(val players : List<Player>) {

    fun doAction(playerId: Int, a: Char) {
        val player = players.first { it.id == playerId }
        with(player) {
            when (a) {
                'N' -> {}
                'M' -> infectionRate = clamp(infectionRate - 4, 0)
                'E' -> contagionRate = clamp(contagionRate - .08, 0.0, 1.0)
                'I' -> lethalityRate = clamp(lethalityRate - .04, 0.0, 1.0)
                'V' -> {
                    infectionRate = clamp(infectionRate - 1, 0)
                    contagionRate = clamp(contagionRate - .04, 0.0, 1.0)
                    lethalityRate = clamp(lethalityRate - .02, 0.0, 1.0)
                }
                'C' -> {
                    val cured = Math.min(infected, 10)
                    infected -= cured
                    healthy += cured
                }
                'Q' -> infected = clamp(infected - 30, 0)
                'O' -> migrationRate = clamp(migrationRate + .1, 0.0, 1.0)
                'B' -> migrationRate = clamp(migrationRate - .1, 0.0, 1.0)
                'T' -> {
                    players.forEach {
                        val infected = Math.min(it.healthy, 4)
                        it.healthy -= infected
                        it.infected += infected
                    }
                }
                'W' -> {
                    players.forEach {
                        it.infectionRate++
                        it.lethalityRate = clamp(it.lethalityRate + .02, 0.0, 1.0)
                    }
                }
                'D' -> {
                    players.forEach {
                        it.infectionRate++
                        it.contagionRate = clamp(it.contagionRate + .02, 0.0, 1.0)
                    }
                }
                'P' -> {
                    players.forEach {
                        it.infectionRate = clamp(it.infectionRate - 1, 0)
                        it.contagionRate = clamp(it.contagionRate - .01, 0.0, 1.0)
                        it.lethalityRate = clamp(it.lethalityRate - .01, 0.0, 1.0)
                    }
                }
                else -> throw IllegalArgumentException("Invalid action: $a")
            }
        }
    }

    fun copy() = Game(players.map { it.copy() })

    fun migration() {
        var migratingHealthy = 0
        var migratingInfected = 0
        var totalMigratingWeight = 0.0

        players.forEach {
            migratingHealthy += (it.healthy * it.migrationRate).toInt()
            migratingInfected += (it.infected * it.migrationRate).toInt()
            totalMigratingWeight += it.migrationRate

            it.healthy = (it.healthy * (1 - it.migrationRate)).toInt()
            it.infected *= (it.healthy * (1 - it.migrationRate)).toInt()
        }

        players.forEach {
            it.healthy += (migratingHealthy * it.migrationRate / totalMigratingWeight).toInt()
            it.infected += (migratingInfected * it.migrationRate / totalMigratingWeight).toInt()
        }
    }

    fun infection() {
        players.forEach {
            val infected = Math.min(it.healthy, it.infectionRate)
            it.healthy -= infected
            it.infected += infected
        }
    }

    fun contagion() {
        players.forEach {
            val infected = Math.min(it.healthy, (it.infected * it.contagionRate).toInt())
            it.healthy -= infected
            it.infected += infected
        }
    }

    fun extinction() {
        players.forEach {
            val killed = (it.infected * it.lethalityRate).toInt()
            it.infected -= killed
            it.dead += killed
        }
    }

    operator fun get(playerId : Int) = players.first { it.id == playerId }

    fun calculateBenefit(action : Char, myId: Int) : Int {

        val copy1 = copy()
        copy1.doAction(myId, action)

        copy1.migration()
        copy1.infection()
        copy1.contagion()
        copy1.extinction()

        return copy1.players.sumBy { it.dead }
    }

}

fun main(args : Array<String>) {
    @Suppress("NAME_SHADOWING")
    val args = args[0].split(';')

    @Suppress("UNUSED_VARIABLE")
    val round = args[0].toInt()
    val myId = args[1].toInt()

    val players : MutableList<Player> = ArrayList()

    for ( i in 2..args.size-1) {
        val data = args[i].split('_')
        players.add(Player(data[0].toInt(), data[1].toInt(), data[2].toInt(), data[3].toInt(), data[4].toInt(), data[5].toDouble() / 100, data[6].toDouble() / 100, data[7].toDouble() / 100))
    }

    if (round == 50) {
        println("TTT")  //Let's mess up the scoreboard :D
        return
    }

    val currentGame = Game(players)
    for (i in 1..3) {
        val action = determineBestAction(currentGame, myId)
        currentGame.doAction(myId, action)
        print(action)
    }
}

fun determineBestAction(game : Game, myId : Int) : Char {

    if (game[myId].lethalityRate > .02) {          //We don't want to hurt ourselves.
        return 'I'
    } else if (game[myId].lethalityRate > 0) {
        return 'V'
    }

    val bestAction = "NMEIVCQOBTWDP".maxBy { game.calculateBenefit(it, myId) }!!

    return bestAction

}

编译方式:kotlinc Terrorist.kt
运行方式:kotlin terrorist.TerroristKt


编译为我提供了一个包含Game,Player和WICKEDkt类的“邪恶”文件夹。按照您描述的方式运行会返回:“错误:找不到或加载wicked.WICKEDKt主类”
Mwr247,2016年

奇怪,它可以在我的计算机上正常工作。您确定WICKEDkt类文件实际上没有命名为WICKEDKt吗?另外,请确保您的工作目录不在邪恶的文件夹内。
TheNumberOne '16

是WICKEDKt。我在评论中打错了字。
Mwr247 '16

@ Mwr247您是否将生成的邪恶文件夹留在submissions文件夹内?您是否从邪恶的文件夹中移动了生成的文件?
TheNumberOne

WICKED很好...该死的你和你对我刚读的东西的引用。
ArtOfCode

9

爪哇马达加斯加

是的,走马达加斯加的路线。第一轮,我们BBB关闭边界。否则,它可以治愈并专注于本地疫苗。

public class Madagascar{
    public static void main(String[]args){
        Boolean bool = false;
        bool = args[0].startsWith("1;");

        if(bool) {
            System.out.println("BBB");
        }
        else {
            System.out.println("CVV");
        }
    }
}

Edit1-我更喜欢马达加斯加的
Edit2-感谢@Geobits的startsWith提醒


如果Geobits关于从5开始而不是将其减少到零的迁移率是正确的,那么B绝对不做任何事情。
quintopia '16

当前看起来好像无法编译。if (b == true)(应if (b)作为样式问题)将给出错误,因为该变量实际上是被调用的bool
彼得·泰勒

如果针对round == 1进行检查是否比创建文件好得多?
Eumel,2016年

1
@TimmyD幸运的是,该回合是第一回合,因此无需太多解析。只需检查输入是否以1;
Geobits

@Geobits感谢您的startsWith()提醒。比分手;并试图重新夺回要容易得多。告诉我我对Java感到生锈。
AdmBorkBork

7

盐,科特林

这个机器人可以生存直到所有讨厌的玩家都死了。在那之后,它治愈了人口,并为健康的人口重新安置了该镇。

该机器人有5个步骤:

  1. 封闭边界。
  2. 让被感染者死亡,但不要过快死亡(准确地确定过快的速度是困难的部分)。
  3. 防止被感染者感染健康。
  4. 治愈感染者(用盐:P)。
  5. 复制。

这里是:

package salt

import java.io.File
import java.util.*

data class Player(
        val id            : Int,
        var healthy       : Int,
        var infected      : Int,
        var dead          : Int,
        var infectionRate : Int,
        var contagionRate : Int,
        var lethalityRate : Int,
        var migrationRate : Int)

fun main(args : Array<String>) {
    @Suppress("NAME_SHADOWING")
    val args = args[0].split(';')

    val round = args[0].toInt()
    val myId = args[1].toInt()

    val players : MutableList<Player> = ArrayList()

    for ( i in 2..args.size-1) {
        val data = args[i].split('_')
        players.add(Player(data[0].toInt(), data[1].toInt(), data[2].toInt(), data[3].toInt(), data[4].toInt(), data[5].toInt(), data[6].toInt(), data[7].toInt()))
    }

    if (round == 50) {
        println("CCC")  //Extra 30 at end of game.
        return
    }

    var actionsLeft = 3

    val me = players.first { it.id == myId }
    val dataFile = File("Salt.txt")
    val lastRoundInfected : Int
    var roundsInHole : Int
    if (round == 1) {
        lastRoundInfected = 1
        roundsInHole = 0
    } else {
        val lines = dataFile.readLines()
        lastRoundInfected = lines[0].toInt()
        roundsInHole = lines[1].toInt()
    }

    val wantedInfected = lastRoundInfected * Math.pow(1/1.5, 1.0/5) * (if (round % 5 == 0 && round != 0) 1.5 else 1.0)

    while (me.migrationRate > 0) {
        print('B')          //Close borders
        me.migrationRate = Math.max(0, me.migrationRate - 10)
        actionsLeft--
    }

    if (me.infected <= wantedInfected) {   //Our infected are dieing too quickly
        roundsInHole++
    } else {
        roundsInHole = Math.max(0, roundsInHole - 1)
    }

    if (me.lethalityRate > 0) {
        var lethalityRateDelta = roundsInHole * 2
        while (lethalityRateDelta > 0 && me.lethalityRate > 0 && actionsLeft > 0) {
            if (lethalityRateDelta == 2 || me.lethalityRate <= 2) {
                lethalityRateDelta -= 2
                print('V')  //Research vaccines
                me.infectionRate = Math.max(0, me.infectionRate - 1)
                me.contagionRate = Math.max(0, me.contagionRate - 4)
                me.lethalityRate = Math.max(0, me.lethalityRate - 2)
                actionsLeft--
            } else {
                lethalityRateDelta -= 4
                print('I')
                me.lethalityRate = Math.max(0, me.lethalityRate - 4)
                actionsLeft--
            }
        }
    }

    dataFile.writeText("${me.infected}\n$roundsInHole")

    while (actionsLeft > 0) {
        if (me.infectionRate + me.contagionRate * me.infected / 100 <= 0) {
            break
        }
        val mWeight = Math.min(me.infectionRate, 4)
        val eWeight = Math.min(me.contagionRate, 8) * me.infected / 100
        val vWeight = Math.min(me.contagionRate, 4) * me.infected / 100 + Math.min(me.infectionRate, 1)
        if (mWeight > eWeight && mWeight > vWeight) {
            print('M')      //Research microbiology
            me.infectionRate = Math.max(0, me.infectionRate - 4)
        } else if (eWeight > vWeight){
            print('E')      //Research epidemiology
            me.contagionRate = Math.max(0, me.contagionRate - 8)
        } else {
            print('V')      //Research vaccines
            me.infectionRate = Math.max(0, me.infectionRate - 1)
            me.contagionRate = Math.max(0, me.contagionRate - 4)
            me.lethalityRate = Math.max(0, me.lethalityRate - 2)
        }
        actionsLeft--
    }

    while (actionsLeft > 0) {
        if (me.infected <= 0) {
            break
        }
        print('C')          //Cure
        val cured = Math.min(me.infected, 10)
        me.infected -= cured
        me.healthy += cured
        actionsLeft--
    }

    while (actionsLeft > 0) {
        print('N')          //Do nothing
        actionsLeft--
    }

    return
}

编译方式:kotlinc Salt.kt
运行方式:kotlin salt.SaltKt

编辑:在大多数“终结世界”的机器人死了之前,生存的可能性更高。

结果示例:

1. Salt (247, 12, 280)
2. InfectedTown (30, 2016, 843)
3. ZombieState (30, 1030, 609)
4. WICKED (30, 413, 222)
5. Triage (18, 965, 706)
6. Mooch (18, 657, 597)
7. MadScienceBot (18, 305, 647)
8. TheKeeper (13, 0, 158)
9. FamilyValues (10, 110, 373)
10. Madagascar (2, 0, 271)
11. Terrorist (0, 1358, 651)
12. InfectionBot (0, 1217, 830)
13. Medic (0, 27, 340)
14. MedicBot (0, 1, 200)
15. UndecidedBot (0, 0, 33)
16. Researcher (0, 0, 63)
17. TheCure (0, 0, 71)
18. TrumpBot (0, 0, 88)
19. WeaponOfMassDissemination (0, 0, 137)
20. Strategist (0, 0, 142)
21. PassiveBot (0, 0, 149)
22. DisseminationBot (0, 0, 152)
23. PassiveBot (0, 0, 155)
24. Crossroads (0, 0, 164)
25. InfectedHaven (0, 0, 170)
26. Socialist (0, 0, 172)
27. BioterroristBot (0, 0, 175)
28. XenoBot (0, 0, 184)
29. ThePacifist (0, 0, 199)
30. CullBot (0, 0, 294)
31. AllOrNothing (0, 0, 327)

非常好的策略。我喜欢您以“良好”方式利用杀伤力!
Thrax

终结“世界末日”机器人的好工作!但是,如果还有更多这样的机器人,Salt可能会倒塌,但是我不确定。生存能力已经非常令人印象深刻,一个好人!
busukxuan

@busukxuan就像现在一样,有几个机器人必须杀死它们后才能杀死它,从而杀死它们。
TheNumberOne

7

PureBot(Haskell)

PureBot讨厌一件事:副作用!
它会尝试处理所有副作用,如果一切顺利,它将减少外界产生的副作用。
它也忽略了其计算中的所有副作用。
这使得它在对抗被动敌人(不会改变整体速度)方面表现更好。

如果infectedinfectioncontagionlethalitymigration都是零,这将有助于其他机器人与P(对Pure)命令。

module Main where
import Control.Monad (void)
import Data.List (find)
import System.Environment (getArgs)
import System.Exit (exitFailure)
import Text.Parsec

-- | The world
data World = World
    { worldRound  :: Int    -- ^ The current round
    , worldTownID :: Int    -- ^ The current town ID
    , worldTowns  :: [Town] -- ^ List of all towns in the world
    }
    deriving (Show)

-- | A town in the world
data Town = Town
    { townID            :: Int -- ^ The town ID
    , townDeath         :: Int -- ^ The number of death people in the town
    , townHealthy       :: Int -- ^ The number of healthy people in the town
    , townInfected      :: Int -- ^ The number of infected people in the town
    , townInfectionRate :: Int -- ^ The infaction rate of the town
    , townContagionRate :: Int -- ^ The contagion rate of the town
    , townLethalityRate :: Int -- ^ The lethality rate of the town
    , townMigrationRate :: Int -- ^ The migration rate of the town
    }
    deriving (Show)

-- | Parse a Int
parseInt :: Parsec String () Int
parseInt = do
    sign <- option '+' $ oneOf "+-"
    numb <- read <$> many1 digit
    return $ if sign == '+'
        then numb
        else negate numb

-- | Parse a town
parseTown :: Parsec String () Town
parseTown = do
    nID <- parseInt
    void $ char '_'
    nHealthy <- parseInt
    void $ char '_'
    nInfected <- parseInt
    void $ char '_'
    nDeath <- parseInt
    void $ char '_'
    nInfectionRate <- parseInt
    void $ char '_'
    nContagionRate <- parseInt
    void $ char '_'
    nLethalityRate <- parseInt
    void $ char '_'
    nMigrationRate <- parseInt
    return Town
        { townID            = nID
        , townDeath         = nDeath
        , townHealthy       = nHealthy
        , townInfected      = nInfected
        , townInfectionRate = nInfectionRate
        , townContagionRate = nContagionRate
        , townLethalityRate = nLethalityRate
        , townMigrationRate = nMigrationRate }

-- | Parse a world
parseWorld :: Parsec String () World
parseWorld = do
    nRound <- parseInt
    void $ char ';'
    nTownID <- parseInt
    void $ char ';'
    towns <- parseTown `sepBy` char ';'
    let nTowns = length towns
    if nTowns < nTownID
        then let nExpected   = (nTownID - nTowns) in
            fail $ "expected at least " ++ show nExpected ++ " more town(s)"
        else return World
            { worldRound  = nRound
            , worldTownID = nTownID
            , worldTowns  = towns }

-- | Update a town
updateTown :: World -> Town -> String
updateTown world town = take 3 $ lastRound
                   ++ prepareForReproduction
                   ++ decreaseInfected
                   ++ decreaseMigration
                   ++ decreaseInfection
                   ++ decreaseContagion
                   ++ decreaseLethality
                   ++ decreaseWorldWide
  where
    -- | The current round number
    nRound         = worldRound world
    -- | The current number of infected
    nInfected      = townInfected town
    -- | The current lethality rate
    nLethalityRate = townLethalityRate town
    -- | The current migration rate
    nMigrationRate = townMigrationRate town
    -- | The current infection rate
    nInfectionRate = townInfectionRate town
    -- | The current contagion rate
    nContagionRate = townContagionRate town
    -- | What to do on the last round
    lastRound
        | nRound == 50 = "CCC"
        | otherwise    = ""
    -- | What to do in order to prepare for reproduction
    prepareForReproduction
        | (nRound+1) `mod` 5 == 0 = decreaseInfected
        | otherwise               = ""
    -- | What to do in order to decrease infected
    decreaseInfected
        | nInfected > 25 = "CCC"
        | nInfected > 15 = "CC"
        | nInfected > 5  = "C"
        | otherwise      = ""
    -- | What to do in order to decrease lethality
    decreaseLethality
        | nLethalityRate > 4 = "I"
        | otherwise          = ""
    -- | What to do in order to decrease migration
    decreaseMigration
        | nMigrationRate > 0 = "B"
        | otherwise          = ""
    -- | What to do in order to decrease infection
    decreaseInfection
        | nInfectionRate > 0 = "M"
        | otherwise          = ""
    -- | What to do in order to decrease contagion
    decreaseContagion
        | nContagionRate > 4 = "E"
        | otherwise          = ""
    -- | What to do if everything else has been taken care of
    decreaseWorldWide = "PPP"

-- | Update a world
updateWorld :: World -> Maybe String
updateWorld world = updateTown world <$> town
  where
    town          = find ((==worldTownID world) . townID) (worldTowns world)

-- | Main program entry point
main :: IO ()
main = do
    cmds <- concat <$> getArgs
    case parse parseWorld "stdin" cmds of
        Left err    -> print err >> exitFailure
        Right world -> case updateWorld world of
            Just cmd -> putStrLn cmd
            Nothing  -> putStrLn "Failed to update world!" >> exitFailure

运行: runhaskell PureBot.hs


哇,什么技术纯净!我喜欢您解释P命令的方式。
busukxuan

我刚刚安装了Haskell 7.10.3,当我尝试运行您的机器人时,它会无限期地等待。我尝试了:runhaskell.exe PureBot.hs 1;0;0_97_3_0_2_5_15_5;1_97_3_0_2_5_15_5。在运行之前,我还有什么需要做的吗?
Thrax

@Thrax哦,对不起。我以为您通过stdin传递了命令...如果没有,我将更改程序。
YoYoYonnY

命令作为参数传递。更新您的漫游器后,我将进行下一次运行。
Thrax

@Thrax在这种情况下,它现在应该可以工作。
YoYoYonnY

7

爪哇被感染的小镇

只要人们不死,被感染的城镇就不会在乎是否受到感染。这就是为什么它将尽可能降低当地致死率的原因。

当致死率已经很低时,它会使用其剩余的行动来增加全球致死率,然后再降低自身的致死率。

由于它试图成为周围最大的小镇,因此移民余额只能是负数,因此其首要行动是关闭边界。

在最后一个回合中,致死率没有影响,并且对城镇中有理智的人数进行了排名,因此可以治愈30人,并希望足够。

import java.util.ArrayList;
import java.util.List;

public class InfectedTown {

    int playerID;
    State thisState;

    public static void main(String[] args){
        new InfectedTown().sleep(args[0].split(";"));
    }

    private void sleep(String[] args) {
        // Parse arguments
        int round = Integer.parseInt(args[0]);
        playerID = Integer.parseInt(args[1]);

        for (int i = 2; i < args.length; i++){
            thisState = new State(args[i]);
            if(thisState.isMine()){
                break;
            }
        }

        // Special actions on turn 1 and 50.
        String action="";
        if(round == 1){
            action = "B";
        } else if(round == 50){
            action="CCC";
        } 

        while(action.length()<3){
            if(thisState.lethalityRate<=2 && action.length()<2){
                // We still have at least one action: lets increase the 
                // lethality rate for everyone, we will decrease it with our 
                // remaining actions.
                action+="W";
                thisState.lethalityRate+=2;
            } else if (thisState.lethalityRate>=4 
                    ||(thisState.lethalityRate>0 && action.length()==2)) {
                // Don't let people die!
                action+="I";
                thisState.lethalityRate-=4;
            } else {
                // Nothing better to do, lets distract other towns by  
                // increasing some useless values
                action+="D";
            }
        }

       System.out.println(action);
    }

    private class State {
        public int ownerId;
        public int lethalityRate;

        public State(String string) {
            String[] args = string.split("_");
            ownerId = Integer.parseInt(args[0]);
            lethalityRate = Integer.parseInt(args[6]);
        }

        public boolean isMine(){
            return ownerId == playerID;
        }
    }
}

5

CullBot,Python 3

几乎可以关闭边界并试图降低城镇感染率的标准自我保护机器人。它是通过剔除动物载体来实现的(由于感染者对感染率没有影响,因此它必须与非人类载体有关;基本上,这就是“研究微生物学”)。有时它也会“杀死”受感染的人类...您知道,AI也会犯错误...

# Parsing code
from sys import argv

args = argv[1].split(";")

n = int(args[0])
pid = int(args[1])
dic = ["pid","healthy","infected","dead","infection","contagion","lethality","migration"]
players = []
for p in args[2:]:
    players += [{dic[i]:int(p.split("_")[i]) for i in range(len(p.split("_")))}]
    if int(p.split("_")[0]) == pid:
        me = players[-1]

# Bot code

actions = ""
nextInfected = me["infected"]*me["contagion"]/100 + me["infection"] + me["infected"] - me["infected"]*me["lethality"]/100
if n%5 == 4:
    nextInfected *= 1.5

if n == 1:
    actions += "BM"
    if nextInfected*1.3 > 10:
        actions += "C"
    elif me["infection"] > 6:
        actions += "M"
    elif me["infection"] > 4:
        actions += "V"
    else:
        actions += "E"
    print(actions)
    exit()
elif n == 50:
    print("CCC")
    exit()


if nextInfected*1.2 > 30:
    if me["infected"] >= 23:
        actions += "Q"
        me["infected"] -= 30
    else:
        actions += "C"
        me["infected"] -= 10
elif me["infection"] > 0:
    actions += "M"
    me["infection"] -= 4
elif me["contagion"] >= 6:
    actions += "E"
    me["contagion"] -= 8
elif me["infected"] > 0:
    actions += "C"
    me["infected"] -= 10
else:
    actions += "E"
    me["contagion"] -= 8

if me["infection"] >= 3:
    actions += "M"
    me["infection"] -= 4
elif me["infected"] >= 7 :
    actions += "C"
    me["infected"] -= 10
elif me["infection"] > 0 and me["contagion"] >= 3:
    actions += "V"
    me["infection"] -= 1
    me["contagion"] -= 4
elif me["contagion"] >= 6:
    actions += "E"
    me["contagion"] -= 8
elif me["infection"] > 0:
    actions += "M"
    me["infection"] -= 4
elif me["infected"] > 0:
    actions += "C"
    me["infected"] -= 10
else:
    actions += "E"
    me["contagion"] -= 8

if me["infection"] >= 3:
    actions += "M"
    me["infection"] -= 4
elif me["infected"] >= 7 :
    actions += "C"
    me["infected"] -= 10
elif me["infection"] > 0 and me["contagion"] >= 3:
    actions += "V"
    me["infection"] -= 1
    me["contagion"] -= 4
elif me["contagion"] >= 6:
    actions += "E"
    me["contagion"] -= 8
elif me["infection"] > 0:
    actions += "M"
    me["infection"] -= 4
elif me["infected"] > 0:
    actions += "C"
    me["infected"] -= 10
else:
    actions += "E"
    me["contagion"] -= 8

if actions[-2:] == "VV":
    actions = actions[0] + "ME"
print(actions)

1
我不是Python专家,所以我可能做错了,但是在Python 3.4中运行它会在行9上给我“ NameError:未定义名称'dictionary'”
。– Mwr247

@ Mwr247谢谢,事实证明,当我编写解析代码时,我完全不介意……还有很多问题。
busukxuan '16

现在,它在第11行上给出“ TypeError:'列表'对象无法解释为整数”
Mwr247 '16

现在有效=)
Mwr247 '16

@ Mwr247哈哈!我以为我已解决此问题,但是我没有复制并粘贴新代码,所以我想我错过了那个代码。我测试过,现在应该可以正常运行了。除非我以某种方式误解了I / O规则。
busukxuan

5

Java的EvilBot

EvilBot并不关心治愈人。只要他们还活着(有点)。试图使世界其他地方感到不适。

在我的本地测试中,BlunderBot的表现要好得多,直到我还介绍了EvilBot。似乎有点动摇。

import java.util.ArrayList;
import java.util.List;

public class EvilBot {

int round;
int phase;
int playerID;
int thisTownID;

List<State> states;
List<State> otherStates;

State thisState;
String action = "";
int cc=0; // command count

public static void main(String[] args){
    new EvilBot().sleep(args[0].split(";"));
}

private void action(String newAction) {
    action += newAction;
    cc+= newAction.length();
    if (cc>=3) {
        System.out.println(action.substring(0, 3));
        System.exit(0);;
    }
}
private void sleep(String[] args) {

    round = Integer.parseInt(args[0]);
    thisTownID = Integer.parseInt(args[1]);

    states = new ArrayList<>();
    otherStates = new ArrayList<>();

    for (int i = 2; i < args.length; i++){
        states.add(new State(args[i]));
    }

    for (State state : states){
        if (state.isMine()) {
            thisState = state;
        } else {
            otherStates.add(state);
        }
    }

    // Round specific commands
    if (round == 1 )                                { action("B");   }
    if (round == 50)                                { action("CCC"); }

    for (int i=0;i<3;i++){
        if (thisState.getLethalityRate() >= 4)  { action("I"); thisState.lethalityRate -= 4;}
    }

    // Nothing else to do, cause trouble.
    action("DWT");
}


private class State {

    private final int ownerId;
    private int healthy;
    private int infected;
    private int dead;
    private int infectionRate;
    private int contagionRate;
    private int lethalityRate;
    private int migrationRate;

    public State(String string) {
        String[] args = string.split("_");
        ownerId = Integer.parseInt(args[0]);
        healthy = Integer.parseInt(args[1]);
        infected = Integer.parseInt(args[2]);
        dead = Integer.parseInt(args[3]);
        infectionRate = Integer.parseInt(args[4]);
        contagionRate = Integer.parseInt(args[5]);
        lethalityRate = Integer.parseInt(args[6]);
        migrationRate = Integer.parseInt(args[7]);
    }

    public int getOwnerId() {
        return ownerId;
    }

    public int getHealthy() {
        return healthy;
    }

    public int getInfected() {
        return infected;
    }

    public int getDead() {
        return dead;
    }

    public int getInfectionRate() {
        return infectionRate;
    }

    public int getContagionRate() {
        return contagionRate;
    }

    public int getLethalityRate() {
        return lethalityRate;
    }

    public int getMigrationRate() {
        return migrationRate;
    }

    public boolean isMine(){
        return getOwnerId() == thisTownID;
    }

}

}

5

大众传播武器

public class WMDbot{
    public static void main(String[]a){
        System.out.println("WMD");
    }
}

WMD机器人真是个混蛋:将自己的感染率保持在较低水平,并提高所有人的感染率。

Bot纯粹是为首字母缩写词而构建的,可能不是一个有力的竞争者,但它将使竞争领域更具吸引力。代码是从TheCure借来的,只是更改了其操作字符串。


从技术上来说,您还更改了班级名称; P
上尉曼船长

@DenhamCoote:请不要随意添加大量语言标签。如果您要编辑帖子,请确保它具有更重要的意义(语法,格式等)。谢谢。
扎克·盖茨

哦?我曾经将其作为我的其中一个帖子的唯一编辑-我只是在跟随别人的领导...
Denham Coote

@DenhamCoote这是不添加任何内容但实际上不被禁止的“简单便宜的编辑”之一。一堆都变得垃圾。
Draco18s

不确定“便宜”的意思-对我而言,它增加了可读性...与一般的高尔夫挑战相比,此挑战要读取的代码要多得多,因此我认为语法高亮会受到欢迎。并不是说我要这样做是为了积分,我只是碰巧享受了这一挑战。
Denham Coote

5

爪哇Graymalkin

Graymalkin的主要重点是将感染率降低到0,并增加其健康人群。它不相信隔离...除了当然来自外界。

我的第一个帖子-欢迎批评。:)

import java.util.ArrayList;
import java.util.List;

public class Graymalkin {

    int round;
    int phase;
    int playerID;
    int thisTownID;

    List<State> states;
    List<State> otherStates;

    State thisState;

    public static void main(String[] args) {
        new Graymalkin().sleep(args[0].split(";"));
    }

    private void sleep(String[] args) {

        round = Integer.parseInt(args[0]);
        playerID = Integer.parseInt(args[1]);

        states = new ArrayList<>();
        otherStates = new ArrayList<>();

        for (int i = 2; i < args.length; i++) {
            states.add(new State(args[i]));
        }

        for (State state : states) {
            if (state.isMine()) {
                thisState = state;
            } else {
                otherStates.add(state);
            }
        }

        if (round == 50) {
            System.out.println("CCC");
            return;
        }

        String out = "";

        if (round == 1) {
            out += "B";
        }

        if (thisState.infectionRate < 10 && thisState.infected >= 10) {
            out += "C";
            thisState.infected -= 10;
        }

        while (thisState.infectionRate >= 4) {
            out += "M";
            thisState.infectionRate -= 4;
        }

        while (thisState.infectionRate > 0) {
            out += "V";
            thisState.infectionRate -= 1;
        }

        while (out.length() < 3) {
            if (thisState.infected > 0) {
                out += "C";
                thisState.infected -= 10;
            } else if (thisState.contagionRate > 0) {
                out += "E";
                thisState.contagionRate -= 8;
            } else if (thisState.lethalityRate > 0) {
                out += "I";
                thisState.lethalityRate -= 4;
            } else {
                out += "N";
            }
        }

        System.out.println(out.substring(0, 3));
    }

    private class State {

        private final int ownerId;
        private int sane;
        private int infected;
        private int dead;
        private int infectionRate;
        private int contagionRate;
        private int lethalityRate;
        private int migrationRate;

        public State(String string) {
            String[] args = string.split("_");
            ownerId = Integer.parseInt(args[0]);
            sane = Integer.parseInt(args[1]);
            infected = Integer.parseInt(args[2]);
            dead = Integer.parseInt(args[3]);
            infectionRate = Integer.parseInt(args[4]);
            contagionRate = Integer.parseInt(args[5]);
            lethalityRate = Integer.parseInt(args[6]);
            migrationRate = Integer.parseInt(args[7]);
        }

        public int getOwnerId() {
            return ownerId;
        }

        public int getSane() {
            return sane;
        }

        public int getInfected() {
            return infected;
        }

        public int getDead() {
            return dead;
        }

        public int getInfectionRate() {
            return infectionRate;
        }

        public int getContagionRate() {
            return contagionRate;
        }

        public int getLethalityRate() {
            return lethalityRate;
        }

        public int getMigrationRate() {
            return migrationRate;
        }

        public boolean isMine() {
            return getOwnerId() == playerID;
        }
    }
}

@Thrax,您最近的运行中似乎未包含我的机器人。我很好奇它的功能!
Teatrousers,2016年

5

Java Triage

import java.util.ArrayList;
import java.util.List;

public class Triage {

    int round;
    int phase;
    int playerID;

    List<State> states;
    List<State> otherStates;

    State thisState;

    public static void main(String[] args){
        new Triage().sleep(args[0].split(";"));
    }

    private void sleep(String[] args) {

        round = Integer.parseInt(args[0]);
        playerID = Integer.parseInt(args[1]);

        states = new ArrayList<>();
        otherStates = new ArrayList<>();

        for (int i = 2; i < args.length; i++){
            states.add(new State(args[i]));
        }

        for (State state : states){
            if (state.isMine()) {
                thisState = state;
            } else {
                otherStates.add(state);
            }
        }

        if (round == 50) {
          System.out.println("CCC");
          return;
        }

        String output = "";

        while( thisState.lethalityRate >= 4) {
          output += "I";
          thisState.lethalityRate -= 4;
        }

        while( thisState.lethalityRate > 0) {
          output += "V";
          thisState.lethalityRate -= 2;
          thisState.contagionRate -= 4;
          thisState.infectionRate -= 1;
        }

        while( thisState.contagionRate >= 8) {
          output += "E";
          thisState.contagionRate -= 8;
        }

        while( thisState.contagionRate > 0) {
          output += "V";
          thisState.lethalityRate -= 2;
          thisState.contagionRate -= 4;
          thisState.infectionRate -= 1;
        }

        while( thisState.infectionRate > 0) {
          output += "M";
          thisState.infectionRate -= 4;
        }

        while( output.length() < 3) {
          output += "C";
        }

        System.out.println(output.substring(0,3));

    }

    private class State {

        private final int ownerId;
        public int sane;
        public int infected;
        public int dead;
        public int infectionRate;
        public int contagionRate;
        public int lethalityRate;
        public int migrationRate;

        public State(String string) {
            String[] args = string.split("_");
            ownerId = Integer.parseInt(args[0]);
            sane = Integer.parseInt(args[1]);
            infected = Integer.parseInt(args[2]);
            dead = Integer.parseInt(args[3]);
            infectionRate = Integer.parseInt(args[4]);
            contagionRate = Integer.parseInt(args[5]);
            lethalityRate = Integer.parseInt(args[6]);
            migrationRate = Integer.parseInt(args[7]);
        }

        public int getOwnerId() {
            return ownerId;
        }

        public boolean isMine(){
            return getOwnerId() == playerID;
        }

    }

}

首先要让其公民活着,然后阻止他们感染他人,然后治愈他们。

Java Mooch

import java.util.ArrayList;
import java.util.List;

public class Mooch {

    int round;
    int phase;
    int playerID;

    List<State> states;
    List<State> otherStates;

    State thisState;

    public static void main(String[] args){
        new Mooch().sleep(args[0].split(";"));
    }

    private void sleep(String[] args) {

        round = Integer.parseInt(args[0]);
        playerID = Integer.parseInt(args[1]);

        states = new ArrayList<>();
        otherStates = new ArrayList<>();

        for (int i = 2; i < args.length; i++){
            states.add(new State(args[i]));
        }

        for (State state : states){
            if (state.isMine()) {
                thisState = state;
            } else {
                otherStates.add(state);
            }
        }

        if (round == 50) {
          System.out.println("CCC");
          return;
        }

        String output = "";

        while( thisState.migrationRate < 100) {
          output += "O";
          thisState.migrationRate += 10;
        }

        while( thisState.lethalityRate >= 4) {
          output += "I";
          thisState.lethalityRate -= 4;
        }

        while( thisState.lethalityRate > 0) {
          output += "V";
          thisState.lethalityRate -= 2;
          thisState.contagionRate -= 4;
          thisState.infectionRate -= 1;
        }

        while( thisState.contagionRate >= 8) {
          output += "E";
          thisState.contagionRate -= 8;
        }

        while( thisState.contagionRate > 0) {
          output += "V";
          thisState.lethalityRate -= 2;
          thisState.contagionRate -= 4;
          thisState.infectionRate -= 1;
        }

        while( thisState.infectionRate > 0) {
          output += "M";
          thisState.infectionRate -= 4;
        }

        while( output.length() < 3) {
          output += "C";
        }

        System.out.println(output.substring(0,3));

    }

    private class State {

        private final int ownerId;
        public int sane;
        public int infected;
        public int dead;
        public int infectionRate;
        public int contagionRate;
        public int lethalityRate;
        public int migrationRate;

        public State(String string) {
            String[] args = string.split("_");
            ownerId = Integer.parseInt(args[0]);
            sane = Integer.parseInt(args[1]);
            infected = Integer.parseInt(args[2]);
            dead = Integer.parseInt(args[3]);
            infectionRate = Integer.parseInt(args[4]);
            contagionRate = Integer.parseInt(args[5]);
            lethalityRate = Integer.parseInt(args[6]);
            migrationRate = Integer.parseInt(args[7]);
        }

        public int getOwnerId() {
            return ownerId;
        }

        public boolean isMine(){
            return getOwnerId() == playerID;
        }

    }

}

与Triage相同,除了它通过完全打开边界开始。这样可以确保永久性地感染大量人口,从而给其他僵尸程序带来不便,并有可能成为抢七局。


Triage不断为金钱增值。另一方面,穆奇(Mooch)仍在继续组建一支恐怖的庞大的大军。做得好!
Mwr247 '16

Moochbot难道不想让所有人都受到感染吗?thisState.x是否不修改State值,然后游戏再次从字符串中更改它,从而使效果翻倍?尽管在最后一轮对thr CCC有个好主意
-Eumel

现在理解了代码,发现我的第二个问题很愚蠢
Eumel,2016年

Moochbot最终确实尝试创建了一个健康的种群,但是开放边界+零杀伤力确保了感染种群的增长更快。
历史学家

4

Python 3感染的天堂

边界封闭的人的避风港。设法使杀伤力最小化。如果最小化,则尝试增加其他州的杀伤力,以“惠及”当地感染者。

# parsing code
from sys import argv
args = argv[1].split(";")

n = int(args[0])
pid = int(args[1])
dic = ["pid","healthy","infected","dead","infection","contagion","lethality","migration"]
players = []
for p in args[2:]:
    players += [{dic[i]:int(p.split("_")[i]) for i in range(len(p.split("_")))}]
    if int(p.split("_")[0]) == pid:
        me = players[-1]

# bot code

actions =""

if n == 50:
    print("CCC")
    exit()
elif n == 1:
    actions += "B"
    if me["lethality"] <= 6:
        actions += "WI"
    else:
        actions += "II"
    print(actions)
    exit()

if me["lethality"] >= 9:
    actions += "III"
elif me["lethality"] >= 3:
    actions += "WII"
else:
    actions += "WWI"
print(actions)

您所做的修改将在下次运行时考虑在内。由于您的策略是为感染者建立避风港,因此它在第二轮运行中仍然不会竞争。仍然非常有趣!
Thrax

2
@Thrax Lol谢谢,这不是一个真正的策略。我只是认为那些被感染者可能会受到健康者的偏见或歧视,因此在混乱的世界中,这很可能会促进“针对被感染者”状态的形成。说实话,这是一个很有趣的机器人,但是后来我看到了它的潜力,因此我提交了。
busukxuan

@Thrax很抱歉,如果这样做不方便,但是我发现自己错误地计算了底部的条件,因此再次进行了更新。
busukxuan

4

十字路口,Python2

十字路口是一个民主国家,注重未来的科学价值。像大多数民主国家一样,大多数决定都是由未经科学训练,自私且功能失调的委员会做出的,这些委员会经常做出非常奇怪和糟糕的决定,显然是随机的,甚至是决定。但是,政府最终将为人民和人类的共同利益而努力。

import sys
import random
import itertools
def sample_wr(population, k):
    "Chooses k random elements (with replacement) from a population"
    n = len(population)
    _random, _int = random.random, int  # speed hack
    return [population[_int(_random() * n)] for i in itertools.repeat(None, k)]
a = sys.argv[1].split(';')
round = int(a[0])
myid = a[1]
players = {}
Sane = 0
Infected = 1
Dead = 2
InfectionRate = 3
ContagionRate = 4
LethalityRate = 5
MigrationRate = 6
worldpopulation = 0
for i in range(2,len(a)):
    b = a[i].split('_')
    players[b[0]]=map(int,b[1:])
    worldpopulation += (int(b[1])+int(b[2]))*int(b[7])/100
output = ""
if round == 1:
    output="BM"
    if players[myid][Infected]>6: output+="C"
    else: output+="E"
if round == 50: 
    if players[myid][Infected] > 20: output = "CCC"
    elif players[myid][Infected]> 6: output = "CTC"
    else: output = "TTC"
if round == 48 and players[myid][Infected] > 45 and players[myid][InfectionRate]>12:
    output = "MMM"
if round == 49 and players[myid][Infected] > 30:
    output = "CCC"
if (round+1)%5==0:
    if players[myid][Sane]==0 or players[myid][Infected]/players[myid][Sane] > 2: output+="I"*(players[myid][LethalityRate]/4)
    output+="M"*(players[myid][InfectionRate]/4)
    output+="C"*max((players[myid][Infected]/10),1)
if players[myid][InfectionRate] < 8 and players[myid][ContagionRate] < 20 and players[myid][Sane]+min(players[myid][Infected]/5,60)>players[myid][Infected] and (round+2)%5==0:
    output+="C"*max((players[myid][Infected]/10),1)
    players[myid][Infected] -= min(max((players[myid][Infected]/10),1)*10,players[myid][Infected])
if players[myid][Sane] > players[myid][Infected] > 30: 
    output +="Q"
    players[myid][Infected] -= min(players[myid][Infected],30)
if players[myid][Sane] > players[myid][Infected] > 20:
    output+="CC"
    players[myid][Infected] -= min(players[myid][Infected],20)
if (players[myid][Sane] > 2*players[myid][Infected] > 20):
    output+="C"
    players[myid][Infected] -= min(players[myid][Infected],10)
if round <= 5 and players[myid][Infected] > 10:
    output+="C"
    players[myid][Infected] -= min(players[myid][Infected],10)
if 25 <= players[myid][Infected] < 40 and players[myid][InfectionRate]<10:# and players[myid][ContagionRate]*(players[myid][Infected]-20)/100 < 10:
    output+="CCC"

if players[myid][InfectionRate]-players[myid][ContagionRate]>10: output+="M"
if players[myid][ContagionRate]-players[myid][InfectionRate]>20: output+="E"
population = []
population +=["I" for i in range(int(1.15**players[myid][LethalityRate]))]
if players[myid][Sane]<10 or players[myid][Infected]-players[myid][Sane]>10: population+=["I" if players[myid][LethalityRate]>8 else "V" for i in range(players[myid][InfectionRate])]
if players[myid][Sane]+players[myid][Infected]>10 and (players[myid][Sane]>15 or players[myid][LethalityRate]<10): population += ["M" if players[myid][InfectionRate] > 6 else "V" for i in range(2*max(players[myid][InfectionRate]*players[myid][Sane]/100,int((1.15+0.002*(50-round))**min(50,players[myid][InfectionRate]))))]
if players[myid][Sane]+players[myid][Infected]>10 and (players[myid][Sane]>15 or players[myid][LethalityRate]<10): population += ["E" if players[myid][ContagionRate] > 10 else "V" for i in range(max(min(players[myid][Sane],players[myid][ContagionRate]*players[myid][Infected]/100),int(1.15**min(50,players[myid][ContagionRate]))))]
if players[myid][InfectionRate]+players[myid][ContagionRate]<15: population += ["C" for i in range(players[myid][Infected])]
if players[myid][Infected] < 10: population += ["WV" for i in range(int(1.05**round))]
output += ''.join(sample_wr(population,3))
print output[:3]

涉及所有人的4次跑步:

1. Crossroads (36, 12, 185)
2. InfectedTown (14, 1040, 510)
3. InfectedHaven (14, 977, 481)
4. Triage (14, 668, 531)
5. ZombieState (14, 523, 393)

1. AllOrNothing (541, 0, 312)
2. InfectedTown (30, 1125, 574)
3. InfectedHaven (30, 1020, 612)
4. WICKED (30, 732, 622)
5. Triage (30, 553, 554)
6. Mooch (30, 80, 240)
7. Crossroads (25, 0, 162)

1. AllOrNothing (846, 12, 241)
2. Crossroads (440, 15, 146)
3. FamilyValues (388, 34, 201)
4. Salt (170, 0, 176)
5. InfectedHaven (18, 1290, 664)

1. Crossroads (80, 14, 365)
2. InfectedHaven (30, 1596, 603)
3. InfectedTown (30, 1286, 576)
4. Triage (30, 1084, 412)
5. WICKED (18, 1286, 578)

4个没有“世界末日漫游器”的运行:

1. Salt (6790, 0, 58)
2. FamilyValues (6697, 7, 9)
3. Crossroads (6616, 4, 16)
4. PureBot (6454, 0, 50)
5. Piecemeal (6260, 0, 111)

1. Crossroads (6970, 0, 39)
2. PureBot (6642, 0, 77)
3. CureThenQuarantine (6350, 2, 51)
4. FamilyValues (6153, 13, 21)
5. Piecemeal (5964, 4, 132)

1. PureBot (6142, 0, 34)
2. CureThenQuarantine (6010, 4, 75)
3. Piecemeal (5971, 4, 72)
4. CullBot (5409, 8, 115)
5. Crossroads (5129, 0, 27)

1. FamilyValues (7277, 12, 26)
2. Crossroads (6544, 4, 32)
3. Salt (5830, 26, 103)
4. Piecemeal (5757, 8, 164)
5. PureBot (5657, 8, 127)

编辑:看到了CullBot成功的“忽略致死力并专注于保持人们健康”的策略之后,我已将减少感染和传染性以及治愈的优先级提高到了降低致死率的高度,而同时又不放弃主要的决策权。

EDIT2:事实证明,忽略周围许多恐怖分子的杀伤力是不好的。降低致死率的优先级再次提高,现在与致死率成正比。还修复了其他一些较差的决定,例如在同一回合中打开和关闭边界,并增加了隔离的门槛,更愿意在可能的情况下进行补救。

EDIT3:进行了一些次要的优先级调整,以处理未处理的情况。现在,无论是否包含世界末日,它的得分都接近最高水平,以为Salt在这两种情况下都胜过了。我目前的投票权是Salt对此事的胜者。

编辑4:改进了固化时间和效率。

EDIT5:删除了与迁移有关的东西,因为它再也不会达到零人口了,并且还有一些更特殊的固化方法。

编辑6:在游戏早期增加降低感染率的优先级。删除注释行。我没有更新测试运行的结果,但是现在它在非世界末日运行中的得分要高得多(击败FamilyValues,而不是TrumpBot)

EDIT7:上限感染/感染率指数为50,以防止大量使用内存。


等等...以色列是模仿高墙的WWZ耶路撒冷吗?
busukxuan

@busukxuan是灵感,是的,除了这个以色列人更像电影中的耶路撒冷(被感染者迅速淹没),因为它基本上将它的边界拉开了一个Mooch。最初的计划是让它主要执行“ P”,但这不是一个有效的策略。
quintopia '16

嗯...当更多的机器人试图增加感染时,亲爱的CullBot似乎再也无法跟上了。
busukxuan

当我添加一个僵尸程序来减少感染(提高顺序随机性)时,它的效果非常好
quintopia '16

因此,基本上CullBot相当不稳定,并取决于具体情况。确实,我在编写代码时就假定感染可控制。唯一的回退是每回合最多1个隔离区。
busukxuan

3

守护者,卢阿

由一位法国青蛙兄弟做的KotH!我必须参加这场比赛!

该机器人将尽一切可能将其感染/传染性和致死率保持在尽可能低的水平。它的最大优先级是使杀伤力接近0。然后它将尝试猜测何时“引入”更多人是什么时候。

编辑:我假设我们得到的arg是按playerId排序的。这是一个错误的假设,因此我为添加了一个冒泡排序datas

input=arg[1]

datas={}
format={"playerID","sane","infected","dead","infection","contagion","lethality","migration"}
i=1
for s in input:gmatch("[^;]+") 
do
  j=1
  if round==nil then round=tonumber(s) 
  elseif me==nil then me=tonumber(s)+1
  else
    table.insert(datas,{})
    for r in s:gmatch("%d+")
    do
      datas[i][format[j]]=tonumber(r)
      j=j+1
    end
    i=i+1
  end
end
for i=#datas-1,1,-1
do
  for j=1,i
  do
    if datas[j].playerID>datas[j+1].playerID
    then
      datas[j],datas[j+1]=datas[j+1],datas[j]
    end
  end
end

-- First, we put ourself in a safe state
if round==1 then print("VVV")os.exit(0)end
if round==50 then print("CCC")os.exit(0)end

actions=""

-- Safety actions first
if datas[me].lethality>2 
then 
  actions=actions.."I"
  datas[me].lethality=datas[me].lethality-4>0 and datas[me].lethality-4 or 0
end

if datas[me].infected>=10
then
  if(datas[me].infection+datas[me].contagion+datas[me].lethality>4)
  then
    actions=actions.."V"
    datas[me].infection=datas[me].infection-1>0 and datas[me].infection-1 or 0
    datas[me].contagion=datas[me].contagion-4>0 and datas[me].contagion-4 or 0
    datas[me].lethality=datas[me].lethality-2>0 and datas[me].lethality-2 or 0
  end
  actions=actions.."C"
  datas[me].sane=datas[me].sane+10
  datas[me].infected=datas[me].infected-10
end

-- We can now try taking some initiatives
while #actions<3
do
  rates={}
  for i=1,#datas
  do
    if i~=me 
    then
      table.insert(rates,(datas[i].infected/datas[i].sane>0 and datas[i].sane or 0)*(datas[i].migration/100))
    end
  end
  rates["total"]=0
  for i=1,#rates
  do
    rates.total=rates.total+rates[i]
  end
  rates.total=(rates.total/#rates)*100


  if datas[me].migration<=15 and datas[me].migration+10>rates.total
  then
    actions=actions.."O"
    datas[me].migration=datas[me].migration+10>0 and datas[me].migration+10 or 0
  elseif (datas[me].sane/datas[me].infected)*100<rates.total
  then
    actions=actions.."B"
    datas[me].migration=datas[me].migration-10>0 and datas[me].migration-10 or 0
  elseif datas[me].infected>=10
  then
    actions=actions.."C"
    datas[me].infected=datas[me].infected-10
  else
    actions=actions.."V"
    datas[me].infection=datas[me].infection-1>0 and datas[me].infection-1 or 0
    datas[me].contagion=datas[me].contagion-4>0 and datas[me].contagion-4 or 0
    datas[me].lethality=datas[me].lethality-2>0 and datas[me].lethality-2 or 0
  end
end
print(actions)
os.exit(0)

@Thrax哦..更正了源代码,现在使用input=arg[1]代替input=io.read()
Katenkyo,2016年

3

MadScienceBot,Python2

你知道这个世界需要什么吗?

更多科学!

我们如何获得更多科学信息?

与脑力激荡

只在最后一秒钟治好人,除了在第50轮外,别无所求。每隔一轮就要成为一个僵尸农场

import sys, copy
import itertools

mults = {'mig_rate': -15, 'let_rate': -15, 'dead': -20, 'inf_rate': -20, 'sane': 0, 'infected': 60, 'con_rate': -30, 'id': 0}
def get_score(player_data):
    score = 0
    for k in player_data:
        score += player_data[k] * mults[k] / 100.
    return score


def add_rates(player_data):
    #Infection
    no_sane_converted = player_data["sane"]*player_data["inf_rate"]/100.
    player_data["infected"] += no_sane_converted
    player_data["sane"] -= no_sane_converted
    #Contagion
    no_sane_converted = player_data["con_rate"]
    player_data["infected"] += no_sane_converted
    player_data["sane"] -= no_sane_converted
    #Extinction
    no_killed = player_data["infected"]*player_data["let_rate"]/100.
    player_data["dead"] += no_killed
    player_data["infected"] -= no_killed

def correct(data):
    if round % 5 == 4:
        data["sane"] += int(data["sane"])/2
        data["infected"] += int(data["infected"])/2
    data["inf_rate"] += 2
    data["con_rate"] += 5
    data["let_rate"] += 5

args = sys.argv[1].split(";")
round = int(args[0])
self_id = int(args[1])
player_data = [map(int, player.split("_"))for player in args[2:]]
player_data = [dict(zip(("id", "sane", "infected", "dead", "inf_rate", "con_rate", "let_rate", "mig_rate"), player)) for player in player_data]
self_data = [player for player in player_data if player["id"] == self_id][0]

f = open("MadScienceBot.txt", "a")
f.write("\n")
f.write(`round`+"\n")
f.write("INPUT: "+`self_data`+"\n")

def m(p): p["inf_rate"] -= 4
def e(p): p["con_rate"] *= 92/100.
def i(p): p["let_rate"] -= 4
def v(p): p["inf_rate"] -= 1; p["con_rate"]-=4;p["let_rate"]-=2
def c(p): x=min(p['infected'], 10); p['infected']-=x; p['sane']+=x
def q(p): x=min(p['infected'], 30); p['infected']-=x; p['dead']+=x
def o(p): p["mig_rate"] += 10
def b(p): p["mig_rate"] -= 10

out = ""
instructions = {"M": m,
                "E": e,
                "I": i,
                "V": v,
                "C": c,
                "Q": q,
                "O": o,
                "B": b}

def run_inst(new_data, inst_id, i):
    inst = instructions[inst_id]
    if i != 2:
        inst(new_data)
        for j in new_data: new_data[j] = max(0, int(new_data[j]))
        #f.write("%s %s %s\n"%(inst_id, get_score(new_data), new_data))
    else:
        inst(new_data)
        for j in new_data: new_data[j] = max(0, int(new_data[j]))
        correct(new_data)
        add_rates(new_data)
        for j in new_data: new_data[j] = max(0, int(new_data[j]))
        #f.write("%s %s %s\n"%(inst_id, get_score(new_data), new_data))
    return new_data

def run_3_insts(self_data, insts):
    new_data = copy.copy(self_data)
    for i, inst in enumerate(insts):
        run_inst(new_data, inst, i)
    return get_score(new_data)

scores = {}
for combo in itertools.permutations(instructions.keys(), 3):
    joined = "".join(combo)
    score = run_3_insts(self_data, joined)
    scores[score] = joined
#print scores
out = scores[max(scores)]

if round == 50:
    out = "CCC"

f.write(out+"\n")
print out

3

ZombieState,Java

嘿,这是我在此网站上的第一篇文章。我基本上只是采用了一个示例机器人,并更改了有关输出的行。

import java.util.ArrayList;
import java.util.List;

public class ZombieState {

int round;
int phase;
int playerID;
int thisTownID;

List<State> states;
List<State> otherStates;

State thisState;

public static void main(String[] args){
    new ZombieState().sleep(args[0].split(";"));
}

private void sleep(String[] args) {

    round = Integer.parseInt(args[0]);
    thisTownID = Integer.parseInt(args[1]);

    states = new ArrayList<>();
    otherStates = new ArrayList<>();

    for (int i = 2; i < args.length; i++){
        states.add(new State(args[i]));
    }

    for (State state : states){
        if (state.isMine()) {
            thisState = state;
        } else {
            otherStates.add(state);
        }
    }

    StringBuilder sb = new StringBuilder();
    if(round == 1)
        System.out.println("TTT");
    else if(round == 50)
        System.out.println("CCC");
    else
    {
        while(thisState.lethalityRate >= 4)
        {
            sb.append("I");
            thisState.lethalityRate -= 4;
        }
        sb.append("DDD");
        System.out.println(sb.toString().substring(0, 3));
    }
}

private class State {

    private final int ownerId;
    public int sane;
    public int infected;
    public int dead;
    public int infectionRate;
    public int contagionRate;
    public int lethalityRate;
    public int migrationRate;

    public State(String string) {
        String[] args = string.split("_");
        ownerId = Integer.parseInt(args[0]);
        sane = Integer.parseInt(args[1]);
        infected = Integer.parseInt(args[2]);
        dead = Integer.parseInt(args[3]);
        infectionRate = Integer.parseInt(args[4]);
        contagionRate = Integer.parseInt(args[5]);
        lethalityRate = Integer.parseInt(args[6]);
        migrationRate = Integer.parseInt(args[7]);
    }

    public int getOwnerId() {
        return ownerId;
    }

    public boolean isMine(){
        return getOwnerId() == playerID;
    }

}

}

我希望可以,并且该机器人在我自己的运行中表现出色。因为谁可以维持生计,如果您可以拥有30位健康的人,并且最后感染的数量最多。它以3x BioTerrorism开始游戏,以使一切开始,并试图保持较低的局部杀伤力。如果小于4,则尝试通过“传播”提高整体感染率和传染率。


欢迎来到PPCG :-)希望您在这里
过得愉快

到目前为止,这似乎做得很好。欢迎使用PPCG,一切顺利!
Rɪᴋᴇʀ

2

DisseminationBot,Ruby

只要剩下10个或更多的治愈程序,该机器人就可以治愈。接下来,如果感染率至少为4,则漫游器将降低感染率。所有其他操作都花费在增加传染率上,这不会伤害我,因为我没有感染了。

#You can copy this code if you want. Not specific to my strategy.
PlayerId = 0
Sane = 1
Infected = 2
Dead = 3
InfectionRate = 4
ContagionRate = 5
LethalityRate = 6
MigrationRate = 7

a = ARGV[0].split ';'
round = a.shift.to_i
my_id = a.shift.to_i
players = a.map{|s|s.split('_').map{|str| str.to_i}}

my_index = players.index{|p|
    p[PlayerId] == my_id
}
me = players[my_index]

#strategy specific code starts here.

commands = ""
commands += 'C' if me[Infected] >= 10
commands += 'C' if me[Infected] >= 20
commands += 'C' if me[Infected] >= 30
commands += 'M' if me[InfectionRate] >= 4 and commands.length < 3
commands += 'D' while commands.length < 3

print commands
$stdout.flush

2

XenoBot(Node.js)

XenoBot惧怕人们,他对这种流行病的解决方案是隔离他的人口,治愈他有能力的人,并在他无能力的地方将他们隔离。他不会为所有这些战争废话而烦恼,他只是想让他的人民活下来。

像这样激活XenoBot:

node xenobot.js [data]

码:

const argv = String(process.argv),
    data = argv.split(";"),
    round = data[0],
    id = Number(data[1]),
    info = data[id + 1].split("_"),
    sane = info[1],
    infected = info[2],
    dead = info[3],
    infectionRate = info[4],
    contagionRate = info[5],
    lethalityRate = info[6],
    migrationRate = info[7]

var moves = 3
function exec(a) {
  process.stdout.write(a)
}
if(migrationRate >= 10) {
  exec("B")
}
if (infectionRate >= 8) {
  exec("MQ")
  moves-=2;
} else if(contagionRate >= 16) {
  exec("EC")
  moves-=2;
} else if(lethalityRate >= 8) {
  exec("IV")
  moves--;
} else {
  exec("B");
  moves--;
}

if (sane / 3 > infected + dead) {
  exec("Q")
  moves--;
}
if(moves > 0) {
  exec("B")
}

2

Python策略师

这个机器人真的很认真地生存。他分析了可能的策略,并提出了自己的制胜法。他现在将在源注释中记录该问题,因为他是一个好人,并且也希望其他人也能生存。

用调用python strategist.py

import sys
import random
import math


def main():
    id = int(get_player_id(sys.argv[1]))
    stats = get_player_stats(sys.argv[1], id)
    round = int(get_round(sys.argv[1]))

    if id == -1 or stats == None or round == -1:
        # Something is wrong here. RED ALERT! Close all possible entry routes and set 
        # quarantine levels to maximum!
        print("BQQ")
        sys.exit(1)

    if round == 1:
        # remove migration, cure some infected, and remove some danger
        print("BCM")
    elif round % 5 == 4:
        # Rounds 4, 9, 14 etc. One before repopulation. We want as many Healthy and as 
        # few Infected as possible to reproduce. Prioritise curing infected, because that
        # maximises Healthy for reproduction. If that's not possible, quarantine them.
        quarantine = math.ceil(int(stats['infected']) / 30)
        cure = math.ceil(int(stats['infected']) / 10)
        if cure <= 3:
            # we can deal with all our infections within 3 cures
            output = "C" * cure
            for i in range(3 - cure):
                # got moves left? Great, remove some danger.
                output += get_random_science()
            print(output)
        elif quarantine <= 3:
            # we can deal with all our infections within 3 quarantines
            output = "Q" * quarantine
            for i in range(3 - quarantine):
                # got moves left? Great, remove some danger.
                output += get_random_science()
            print(output)
        else:
            # We can't deal with all the infected in one round, so deal with some. Yes, we
            # don't get rid of as many as we could here, but we're about to reproduce so
            # we want Healthies in the next round.
            print("QQC")
    else:
        output = ""
        if int(stats['infected']) <= 10:
            # we can deal with all our infections by curing them
            output += "C"
        elif int(stats['infected']) <= 30:
            # we can deal with all our infections by quarantining them
            output += "Q"
        elif int(stats['infected']) >= int(stats['healthy']) * 0.5:
            # we're getting overrun with infected people, get rid of some
            output = "QCC"

        for i in range(3 - len(output)):
            # if we haven't used all our moves, we can remove some danger factors
            output += get_random_science()

        print(output)


def get_random_science():
    return random.choice(["M", "E", "I", "V"])


def get_player_id(args):
    splat = args.split(";")
    return splat[1] if len(splat) >= 2 else -1


def get_player_stats(args, id):
    splat = args.split(";")
    players_data = [x for x in splat if "_" in x]
    my_data = [y for y in players_data if y.split("_")[0] == str(id)]
    data_splat = my_data[0].split("_")

    if len(data_splat) == 8:
        # Id, Healthy, Infected, Dead, InfRate, ConfRate, LethRate, MigRate
        return {
            'healthy': data_splat[1],
            'infected': data_splat[2],
            'dead': data_splat[3],
            'inf_rate': data_splat[4],
            'conf_rate': data_splat[5],
            'leth_rate': data_splat[6],
            'mig_rate': data_splat[7]
        }
    else:
        return None


def get_round(args):
    splat = args.split(";")
    return splat[0] if len(splat) >= 1 else -1


if __name__ == "__main__":
    main()

2

打开和关闭

打开边界开始游戏,然后让所有病夫来。在我们有大量的病人(大约30岁)之后,请关闭边界并努力治愈病人。

#You can copy this code if you want. Not specific to my strategy.
PlayerId = 0
Healthy = 1
Infected = 2
Dead = 3
InfectionRate = 4
ContagionRate = 5
LethalityRate = 6
MigrationRate = 7

a = ARGV[0].split ';'
round = a.shift.to_i
my_id = a.shift.to_i
players = a.map{|s|s.split('_').map{|str| str.to_i}}

my_index = players.index{|p|
    p[PlayerId] == my_id
}
me = players[my_index]

#strategy specific code starts here.

commands = ""
if round < 30
  commands += me[MigrationRate] == 100 ? (me[InfectionRate] <= 1 ? "V" : "M") : "O"
  commands += me[LethalityRate] <= 2 ? "V" : "I"
  commands += me[ContagionRate] <= 4 ? "V" : "E"
elsif round < 50
  commands += me[MigrationRate] == 0 ? "V" : "B"
  commands += me[LethalityRate] < 20 ? "C" : "I"
  commands += me[ContagionRate] <  5 ? "C" : "E"
else
  commands = "CCC"
end

print commands
$stdout.flush

2

另外两个Python机器人

以色列

它与Mooch类似,但可能不如Mooch好,除非在少数情况下要好得多:

import sys
a = sys.argv[1].split(';')
round = int(a[0])
myid = a[1]
players = {}
Sane = 0
Infected = 1
Dead = 2
InfectionRate = 3
ContagionRate = 4
LethalityRate = 5
MigrationRate = 6
for i in range(2,len(a)):
    b = a[i].split('_')
    players[b[0]]=map(int,b[1:])
output=''
if round<=4:output = ["OOO","OOO","OOO","OII"][round-1]
if round==50: output = "CCC"
mycontrate = players[myid][ContagionRate]
myfatrate = players[myid][LethalityRate]
myinfrate = players[myid][InfectionRate]
if myinfrate+mycontrate<5:
    output+="V"
    myfatrate-=2
    if round < 47: 
        output+="I"*(myfatrate/4)
        if myfatrate%4: output+="V"
else:
    if round < 47: 
        output+="I"*(myfatrate/4)
        if myfatrate%4: output+="V"
    output+="M"*(myinfrate/4)
    if round < 47: 
        output+="E"*(mycontrate/4)
output+="CCC"

print output[:3]

红十字

有点像和平主义者,除了也试图使自己的人民免于死亡。惨败于此,但在运动场上结识另一个友善者真是太好了。

import sys
a = sys.argv[1].split(';')
round = int(a[0])
myid = a[1]
players = {}
Sane = 0
Infected = 1
Dead = 2
InfectionRate = 3
ContagionRate = 4
LethalityRate = 5
MigrationRate = 6
for i in range(2,len(a)):
    b = a[i].split('_')
    players[b[0]]=map(int,b[1:])
output="PPPPP"
if round<=4:output = ["OOO","OOO","OOO","OII"][round-1]
elif round==50: output = "CCC"
else: output = output[:2-3*round%5]+"I"+output[2-3*round%5:]
print output[:3]

2

Smaug(Python)

我是火;我死了

不论死亡发生在哪里,史矛革都会造成尽可能多的死亡。

# "I am fire, I am death"
# Smaug has two goals: hoard gold and bring death...
#    and this world seems to be all out of gold

from sys import argv
args = argv[1].split(";")

round = int(args.pop(0))
me = int(args.pop(0))

if round==50: # can't cause more death on the last round, might as well infect
    print('TTT')

def predict_infected(infected, infection_rate, contagion_rate):
    i = infected + infection_rate
    return i + int(i*contagion_rate)

def predict_dead(infected, lethality_rate):
    return int(infected*lethality_rate)

strategies = {'WWW':0, 'WWD':0, 'WDD':0, 'DDD':0}
for player in args:
    player=player.split('_')
    healthy=int(player[1])
    infected=int(player[2])
    infection_rate=int(player[4])
    contagion_rate=int(player[5])/100.
    lethality_rate=int(player[6])/100.

    if round%5==0:
        healthy+=healthy/2
        infected+=infected/2

    pi_old = predict_infected(infected, infection_rate, contagion_rate)
    pd_old = predict_dead(pi_old, lethality_rate)

    for strat in strategies:
        ir_new = infection_rate + 3
        lr_new = lethality_rate + (strat.count('W')*.02) 
        cr_new = contagion_rate + (strat.count('D')*.02) 

        pi_new = predict_infected(infected, ir_new, cr_new)
        pd_new = predict_dead(pi_new, lr_new)

        increase = pd_new - pd_old

        strategies[strat]+=increase

print max(strategies, key=strategies.get)

如果您想打高尔夫球,那么空文件会更短,并且可以完全执行观察者的操作(并且恰好也可以完全执行PassiveBot的操作-两者的行为相同),因为解释器将NNN替换为0长度响应。
quintopia '16

@quintopia我不是想要的,只是在我输入它时便意识到它可以很容易地用作多语言,但是我没有意识到PassiveBot的功能,所以我只是要删除Watcher(没有两个相同的东西)
SnoringFrog

2

删除感染的(Python)

尽管有所有的随机逻辑,但我很罕见地返回除Q和C之外的任何值(预防性措施似乎从未如此有用)。那好吧。可以将其借用给其他机器人,但以防万一。

# Remove as many of it's own infected as possible, preferably by curing, but quarantining if it's getting out of hand
# If not very many can be cured, takes preventative measures (B,E,M, or V)

from sys import argv

CMDS=3
C_RATE=10
E_RATE=.08
M_RATE=4
Q_RATE=30
V_RATE=(1,.04)

def find_me(args):
    for player in args:
        player=player.split('_')
        if int(player[0])==me:
            return player

def actions_available():
    global actions
    if len(actions) < CMDS:
        return True
    else:
        return False

def add_actions(new_actions):
    global actions
    actions = (actions + new_actions)[0:CMDS]

def get_remaining_infected(local_infected):
    global actions
    return local_infected - (Q_RATE*actions.count('Q')) - (C_RATE*actions.count('C'))

def too_many_infected(local_infected):
    max_infected = C_RATE*(CMDS+1) # If we can get down to 10 or less without quarantining, that's good
    if local_infected > max_infected:
        return True
    else: return False

def projection(infection_rate, remaining_infected, action):
    additional_M=0
    additional_E=0
    additional_V=0

    if action == "M":
        additional_M=1
    elif action == "E":
        additional_E=1
    else:
        additional_V=1

    M_level = M_RATE*(actions.count('M')+additional_M)
    E_level = E_RATE*(actions.count('E')+additional_E)
    V_level = (V_RATE[0]*(actions.count('V')+additional_V), V_RATE[1]*(actions.count('V')+additional_V))

    projection = infection_rate - M_level - V_level[0] + (remaining_infected * (contagion_rate - E_level - V_level[1])) 
    return int(projection)

def get_best_action(local_infected):
    global actions
    remaining_infected = get_remaining_infected(local_infected)

    # If we can leave no infected, do so
    if remaining_infected <= C_RATE and remaining_infected >= 0:
        return 'C'

    strategies = {'M':0, 'E':0, 'V':0,'C':min(remaining_infected,C_RATE)}

    pni = int(infection_rate + (remaining_infected*contagion_rate)) # predicted new infected
    strategies['M'] = pni - projection(infection_rate, remaining_infected, 'M')
    strategies['E'] = pni - projection(infection_rate, remaining_infected, 'E')
    strategies['V'] = pni - projection(infection_rate, remaining_infected, 'V')
    # any benefit to including P as an option? 

    #print(strategies)
    max_saved = 'C'
    for strat,saved in strategies.iteritems():
        if saved > strategies[max_saved]:
            max_saved=strat
        elif saved == strategies[max_saved]:
            #prioritize V because of it's extra benefit of reducind lethality_rate
            max_saved=max(strat,max_saved) 

    if strategies[max_saved] <= C_RATE/2:
        # can't save that many, just close borders instead
        selected_action = 'B'
    else: selected_action = max_saved
    return selected_action


args = argv[1].split(";")
round = int(args.pop(0))
me = int(args.pop(0))
actions = ""

my_town = find_me(args)

local_infected = int(my_town[2])
infection_rate = int(my_town[4])
contagion_rate = int(my_town[5])/100.

if round!=50 and too_many_infected(local_infected):
    # Things are getting out of hand, quarantine and consider preventative measures
    actions = ('Q'*(local_infected/Q_RATE))[0:CMDS]

    while actions_available():
        add_actions(get_best_action(local_infected))
else: actions='CCC'

print ''.join(sorted(actions)) # always cure first

@Thrax此机器人已更新
SnoringFrog

2

Java CureThenQuarantine

国家制定了一项政策,即治愈那些幸运的人,然后隔离其余的感染者。一旦减少了受感染的人口,那么就应着重于降低本地房价,然后帮助降低全球房价。

边界被关闭以确保没有感染者迁移到该州。

我只针对Java和Python僵尸程序测试了该僵尸程序...似乎对它们持反对态度。看来我的机器人的行为类似于CullBot。

public class CureThenQuarantine {
    static int playerID;

    public static void main(String[] args)
    {
        State thisState=null;

        args = args[0].split(";");

        // Parse arguments
        int round = Integer.parseInt(args[0]);
        playerID = Integer.parseInt(args[1]);

        for (int i = 2; i < args.length; i++){
            thisState = new State(args[i]);
            if(thisState.isMine()){
                break;
            }
        }

        String action="";
        if(round == 1) action = "B"; // ensure no migration.
        else if (round == 50 ) action ="CCC"; // not much else we can do so just cure some people.

        // Highest Priority to Curing and then Quarantining infected, but do not perform either action if it would be wasteful.
        if (thisState.infected>9)
        {
            if (thisState.infected<19) action+="C";
            else if (thisState.infected<29) action+="CC";
            else if (thisState.infected<39) action+="CCC";
            else if (thisState.infected<49) action+="CQ";
            else if (thisState.infected<59) action+="CCQ";
            else if (thisState.infected<79) action+="CQQ";
            else action+="QQQ";
        }

        // Next priority is to reduce infection rate
        if (thisState.infectionRate>8) action+="MMM";
        else if (thisState.infectionRate>4) action+="MM";
        else if (thisState.infectionRate>1) action+="M";
        else if (thisState.infectionRate>0) action+="V";

        // then reduce contagion rate
        if (thisState.contagionRate>16) action+="EEE";
        else if (thisState.contagionRate>8) action+="EE";
        else if (thisState.contagionRate>1) action+="E";
        else if (thisState.contagionRate>0) action+="V";

        // and least priority is lethality rate... since we are only going to quarantine infected persons anyway.
        if (thisState.lethalityRate>8) action+="III";
        else if (thisState.lethalityRate>4) action+="II";
        else if (thisState.lethalityRate>1) action+="I";
        else if (thisState.lethalityRate>0) action+="V";

        // and if we have managed to clean up our state then we help others states.
        action+="PPP";

        System.out.println(action.substring(0,3));
    }

    static private class State {
        public int ownerId;
        public int lethalityRate;
        public int healthy;
        public int infected;
        public int infectionRate;
        public int contagionRate;

        public State(String string) {
            String[] args = string.split("_");
            ownerId = Integer.parseInt(args[0]);
            healthy = Integer.parseInt(args[1]);
            infected = Integer.parseInt(args[2]);
            infectionRate = Integer.parseInt(args[4]);
            contagionRate = Integer.parseInt(args[5]);
            lethalityRate = Integer.parseInt(args[6]);
        }

        public boolean isMine(){
            return ownerId == playerID;
        }
        public String toString()
        {
            return "H: "+healthy+" I: "+infected+" IR: "+infectionRate+" LR: "+lethalityRate+" CR: "+contagionRate;
        }
    }
}

2

Java研究员

该机器人专注于研究。如果被感染的数量低于15,它将尝试治愈它们。如果高于该值,则选择更有效的解决方案

public class Researcher {
    public static void main(String[] args){
        String[] args1 = args[0].split(";");
        int id = Integer.parseInt(args1[1]);
        for (int i = 2; i < args1.length; ++ i) {
            String[] args2 = args1[i].split("_");
            if (Integer.parseInt(args2[0]) == id) {
                int infected = Integer.parseInt(args2[2]);
                if (infected == 0) {
                    System.out.println("MEI");
                } else if(infected < 15) {
                    System.out.println("MEC");
                } else {
                    System.out.println("MEQ");
                }
            }
        }
    }
}

1
我猜是Java语言吗?

2

Java零碎

根据我以前的机器人(CureThenQuarantine),我发现在使用侵略性机器人的情况下,无需隔离,因为被感染者会很快死亡,因此,该机器人每转机将机会治愈10个被感染者(迁移或来自健康人群的感染)。然后,它将使用剩余的动作来确保健康的人口依靠出生来保持健康,从而促进健康的人口。

边界被关闭以确保没有感染者迁移到该州。

public class Piecemeal{
    static int playerID;

    public static void main(String[] args)
    {
        State thisState=null;

        args = args[0].split(";");

        // Parse arguments
        int round = Integer.parseInt(args[0]);
        playerID = Integer.parseInt(args[1]);

        for (int i = 2; i < args.length; i++){
            thisState = new State(args[i]);
            if(thisState.isMine()){
                break;
            }
        }

        String action="";
        if(round == 1) action = "B"; // ensure no migration.
        else if (round == 50 ) action ="CCC"; // not much else we can do so just cure some people.

        // Highest Priority to Curing up to ten infected if there are any.
        if (thisState.infected>0)
        {
            action+="C";
        }

        // Next priority is to reduce infection rate
        if (thisState.infectionRate>8) action+="MMM";
        else if (thisState.infectionRate>4) action+="MM";
        else if (thisState.infectionRate>1) action+="M";
        else if (thisState.infectionRate>0) action+="V";

        // then reduce contagion rate
        if (thisState.contagionRate>16) action+="EEE";
        else if (thisState.contagionRate>8) action+="EE";
        else if (thisState.contagionRate>1) action+="E";
        else if (thisState.contagionRate>0) action+="V";

        // and least priority is lethality rate... since we are only going to quarantine infected persons anyway.
        if (thisState.lethalityRate>8) action+="III";
        else if (thisState.lethalityRate>4) action+="II";
        else if (thisState.lethalityRate>1) action+="I";
        else if (thisState.lethalityRate>0) action+="V";

        // and if we have managed to clean up our state then we help others states.
        action+="PPP";

        System.out.println(action.substring(0,3));
    }

    static private class State {
        public int ownerId;
        public int lethalityRate;
        public int healthy;
        public int infected;
        public int infectionRate;
        public int contagionRate;

        public State(String string) {
            String[] args = string.split("_");
            ownerId = Integer.parseInt(args[0]);
            healthy = Integer.parseInt(args[1]);
            infected = Integer.parseInt(args[2]);
            infectionRate = Integer.parseInt(args[4]);
            contagionRate = Integer.parseInt(args[5]);
            lethalityRate = Integer.parseInt(args[6]);
        }

        public boolean isMine(){
            return ownerId == playerID;
        }
        public String toString()
        {
            return "H: "+healthy+" I: "+infected+" IR: "+infectionRate+" LR: "+lethalityRate+" CR: "+contagionRate;
        }
    }
}
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.