리더 보드
154 Calculator
144 Taxman
138 Statistician
137 Solver
137 RandoAggroLawyer
136 Gambler
134 Turncoat
119 Lawyer
119 BloodyMurder
113 Bandit
79 Challenger
74 Mask
64 Random
로그 및 모든 출력 파일을 포함하여 최신 일치 아카이브를 사용할 수 있습니다.
Brilliand의 계산기가 승자입니다! 그의 대답은 받아 들여지지 만 도전이 끝났다는 의미는 아닙니다. 새로운 출품작을 제출하거나 현재 출품작을 편집하여 그의 왕좌를 두 드리십시오. 매월 말에 리더에게 현상금을 수여합니다.
플레이 규칙
일격 는 2-6 명의 플레이어를 위해 디자인 된 카드 게임으로 2 명과 함께 플레이합니다. 그것은 동전 재무부 (우리의 목적을 위해 무한대)와 15 개의 카드로 구성되며, 대사, 암살자, 선장, 콘테 사, 듀크의 3 가지 유형을 포함합니다. 게임이 시작될 때, 각 플레이어는 동전 하나를주고 무작위로 두 장의 카드를 처리하며, 필요할 때까지 비밀을 유지합니다. 목표는 당신의 손에 카드를 가진 마지막 플레이어입니다.
자신의 차례에 플레이어는 카드에 상관없이 다음 행동 중 하나를 수행 할 수 있습니다.
- 수입 : 재무부에서 동전 1 개를 가져옵니다. 막을 수없고 도전 할 수없는.
- 외국 원조 : 재무부에서 동전 2 개를 가져갑니다. 듀크 플레이어가 막을 수 있습니다. 변할 수 없는.
- 쿠데타 : 선택한 상대의 카드 한 장을 게임에서 제거합니다. 동전 7 개를 소비합니다. 피해자는 버릴 카드를 선택할 수 있습니다. 턴 시작시 10 개 이상의 코인을 보유한 플레이어는 쿠데타 해야합니다 . 막을 수없고 도전 할 수없는.
플레이어는 자신의 카드에 따라 다음 행동 중 하나를 차례대로 수행 할 수 있습니다.
- 교환 : 대사가있는 플레이어는 덱에서 2 장의 카드를받을 수 있습니다. 그런 다음 손과 뽑은 카드 중에서 원래 카드 수만큼 많은 카드를 선택할 수 있습니다. (즉, 카드가 하나만 있으면 뽑은 카드 중 하나와 교환하거나 보관할 수 있으며, 카드가 두 개인 경우 4 장 중 2 장을 선택할 수 있습니다.) 원하지 않는 2 장의 카드는 덱으로 돌아갑니다 . 차단할 수 없지만 도전 할 수 있습니다.
- 암살 : 암살자가있는 플레이어는 게임에서 상대방의 카드를 제거하기 위해 동전 3 개를 소비 할 수 있습니다. 피해자는 버릴 카드를 선택할 수 있습니다. Contessa를 보유한 플레이어가 차단할 수 있으며,이 경우 동전이 반환되지 않습니다. 도전이 가능하며,이 경우 동전 이 반환됩니다.
- 훔치기 : 함장을 가진 플레이어는 상대방에게서 동전 2 개를 가져갈 수 있습니다. 상대방이 동전 하나를 가지고 있다면, 그 동전 하나를 가져갑니다. 상대방의 동전이 0이면 훔칠 수 없습니다. 대사 또는 선장과 플레이어가 차단할 수 있습니다. 도전 할 수 있습니다.
- 세금 : 듀크를 가진 플레이어는 재무부에서 동전 3 개를 가져갈 수 있습니다. 차단할 수 없지만 도전 할 수 있습니다.
쿠데타의 까다로운 부분은 플레이어가 자신이 가진 카드에 대해 거짓말을 할 수 있다는 것입니다! 이와 관련된 행동이나 차단을 시도하기 위해 카드가 필요하지 않습니다.
플레이어가 카드의 행동을 수행 할 때, 상대방 (해당 행동으로 피해를받지 않은 사람이라도)은 배우에게 도전하여 그 행동에 대한 카드가 있다고 생각하지 않을 수 있습니다. 챌린저가 올 바르면 액션이 취소되고 액터는 선택한 카드 한 장을 버려야합니다 (해당되는 경우 사용한 코인을 되 찾아야합니다). 그렇지 않은 경우, 행동이 취해지고, 배우는 자신이 도전 한 카드를 덱에 반환하고 새로운 카드를 뽑습니다. 그리고 도전자는 자신의 카드 중 하나를 버려야합니다. 플레이어는 도전 할 때 보유한 카드에 대해 진실해야합니다.
Assassinate, Coup 및 잃어버린 챌린지에서 플레이에서 제외 된 카드는 덱으로 반환되지 않지만 원 챌린지의 일부로 공개 된 카드는 덱으로 반환됩니다.
블록은 액션처럼 도전 할 수 있습니다. 예를 들어, 플레이어 A가 외국 원조를 청구하고 플레이어 B가 "나는 듀크를 가지고 있고 당신의 외국 원조를 차단합니다"라고 말하면, A는 "당신은 듀크가 있다고 생각하지 않습니다."라고 말할 수 있습니다. 그 주장이 맞다면, B는 거짓말로 잡힌 카드를 잃고 A는 2 개의 동전을받습니다; 그렇지 않으면 A는 카드를 잃고 동전을 얻지 못하며, B는 자신의 공작을 갑판에 돌려 놓고 새로운 카드를 뽑아야합니다.
Assassinate와의 블록 및 챌린지 방식은 반드시 구체화되어야합니다. 플레이어 A가 "암살자가 있고 플레이어 B를 암살"한다고 가정합니다. B가 A에게 도전하거나 차단하려고 시도하지 않으면 암살이 진행됩니다. B는 카드를 잃고 A는 3 동전을 지불합니다.
또는 B는 "나는 당신이 어 ass 신을 믿지 않는다"고 말함으로써 도전 할 수 있습니다. 그것이 사실이라면, A는 카드를 버리고 그들의 동전은 반환되고 B는 영향을받지 않으며 A의 차례는 끝납니다. 만약 B의 신념이 부정확하고 A가 어 ass 신을 보유하고 있다면, B는 자신의 카드를 모두 잃고 실패합니다.
도전하는 대신 B는 "Contessa가 있고 Assassnate를 차단합니다"라고 말할 수 있습니다. A가 B를 믿는다면 A의 차례는 끝나고 그들의 동전은 반환되지 않습니다. 그러나 A는 블록에 도전하고 "Contessa가 있다고 생각하지 않습니다."라고 말할 수 있습니다. B가 실제로 Contessa를 보유하고 있다면 A는 잘못된 도전에 대한 카드를 잃습니다. 그러나 B가 그렇지 않다면, B는 암살에서 거짓말을 한 카드와 다른 카드를 잃습니다.
위의 설명과 유사한 논리가 행동이나 블록에 도전 할 수있는 선장의 도용 능력에 적용됩니다.
암살자에게 도전에 실패하거나 암살을 막기 위해 Contessa가 있다고 주장하는 경우 한 번에 두 카드를 모두 잃어 버릴 수 있습니다. 도전에서 하나의 카드와 암살에서 하나의 카드를 잃습니다.
도전
당신의 임무는 쿠데타를 재생할 프로그램을 작성하는 것입니다. 명령 행 인수로 제공됩니다.
- 지금까지 파일 및 상대의 조치 목록을 포함하는 파일 이름.
- 상대방의 코인 수를 나타내는 0에서 12 사이의 정수입니다.
- 코인 수를 나타내는 0에서 12 사이의 정수입니다.
- 1 ~ 4 자의 문자열로 카드를 나타냅니다. 일반적으로이 카드는 프로그램에있는 하나 또는 두 개의 카드 일 뿐이지 만 Exchange에서 프로그램이 성공한 경우 n + 2 자이며 n 은 남은 카드 수입니다. 그런 다음 프로그램은 STDOUT에 유지하려는 n 개의 카드 를 출력해야합니다 . (이 목적 이외의 프로그램은 STDOUT을 읽거나 액세스하면 안됩니다. 디버그 출력을 생성하려면 STDERR에 작성하십시오.)
- 합법적 인 행동을 나타내는 하나 이상의 주장.
(예 : 호출 : yourprogram file.txt 1 7 '~!' a c p q"상대에게 1 개의 동전이 있습니다. 7 개의 동전, 대사, 그리고 Contessa가 있습니다. 게임 기록과 현재 게임 상태에 따라 a, c, p 또는 q 중 원하는 것을 file.txt에 쓰십시오. ")
프로그램은 조치를 나타내는 제공된 파일에 하나 또는 두 개의 특정 상황에서 두 문자를 추가해야합니다. 그렇지 않으면 파일의 기존 내용을 변경해서는 안됩니다. 원하는 새 파일을 만들 수 있지만 실행되는 디렉토리 내에서만 가능합니다. 프로그램을 컴파일하고 실행하는 데 필요한 모든 명령을 제공하십시오.
아래에 Go로 작성된 두 가지 예제 경쟁자를 제공했습니다.
출력 형식은 다음과 같습니다.
I\n: 소득. 법적 답변 : 모든 턴 액션 (Assassnate / Coup 용 코인이 있다고 가정).F: 외국 원조. 법적 답변 :d(공작으로 차단),p(통과).C쿠데타 법률 응답 :의 중_,',<,=,0당신의 손에 있습니다.E: 교환. 법률 응답 :q(도전, 플레이어를 믿지 않는 것은 대사가 있습니다)p.T: 세금. 법률 응답 :q(도전, 플레이어를 믿지 않는 것은 공작이있다)p.A: 암살. 법률 응답 :s(A 콘테와 같은 블록),q(도전), 그리고 중의_,',<,=,0당신의 손에 있습니다.S: 도둑질. 법률 응답 :a(대사와 같은 블록),c(선장 같은 블록),q(도전은, 플레이어를 믿지 않는 것은 선장이있다)p.d: 외계인을 공작으로 차단하십시오. 법적 답변 :\n(블록을 수락 함),q(플레이어에 듀크가 있다고 생각하지 않음)a: 대사로 도둑을 막습니다. 법적 답변 :\n(차단 허용),q(선수가 대사를 믿지 않는 것에 대한 도전).c: 함장으로 도둑을 막습니다.\n(블록을 수락 함q)s: Contessa로 Assassinate를 차단합니다. 법적 답변 :\n(차단 허용q)p: 당신의 차례가 아닌 Exchange / Tax / Steal에 도전하십시오. 와 함께 사용하지 않음A; 암살에 도전하는 것을 거부하는 중 하나를 작성하십시오_'<=0. 법적 답변 :\n(턴 종료), 교환에서 성공한 경우, 네 번째 명령 줄 인수에서 STDOUT에 보관하려는 카드를 작성하십시오.q: 가장 최근의 행동이나 차단에 도전하십시오. 법적 답변 : 이의를 제기 한 행동에 대한 카드가있는 경우 그 중 어느~^*!$것이 든 해당 됩니다. 당신이하지 않으면, 당신이_'<=0포기하고 싶은 당신의 손에서, 당신의 차례 인 경우에만 개행이 이어집니다.~,^,*,!,$: 당신이 대가로 각각 대사, 어쌔신, 선장하는 콘테, 또한 명령 행 인수에이 카드를 나타 내기 위해 사용되는 공작 (및 STDOUT 출력을 유지에 대한 진실을 말하고 있다고 공개 ). 법률 응답 :의 중_,',<,=,0당신이 당신의 손에 있습니다._,',<,=,0: 당신이 도전을 분실하거나 Couped / 암살 되었기 때문에, 각각 처벌 대사, 그리고 암살자, 선장하는 콘테 및 공작을 제공합니다. 법적 답변 :\n.\n: 해당되는 경우 블록에 도전하기 위해 거절하는 방식으로 자신의 차례를 끝내십시오. 법적 답변 : 모든 자본 문자 조치
형식에는 다음과 같은 유용한 속성이 있습니다.
- 회전은 대문자로 시작합니다.
- 행은 대문자, 소문자, 선택적으로 문장 부호 또는 공개 된 카드의 경우 0 (개행) 패턴을 따릅니다.
- 개행 문자 또는 빈 파일로 끝나는 파일은 프로그램의 시작이며 대문자 동작을 선택해야 함을 나타냅니다.
- 호출에 대한 법적 조치는 일반적으로 파일의 마지막 문자에 의해 고유하게 결정됩니다. 예외는
q입니다. 관련 논리가 있습니다.get_legal_actions이해를 돕기 위해 중재자 의 기능 을 참조하십시오 . 또는 명령 행에서 제공 한 법적 조치 만 사용할 수 있습니다. - 한 줄에 짝수의 문자가 있으면 차례가 본인의 것이며 프로그램은 행동을 선택하거나, 블록에 도전하거나, 차례를 끝내도록 요청받습니다.
- 줄에 홀수의 문자가 있으면 차례가 자신의 것이 아니며 프로그램에서 카드를 차단, 챌린지 또는 공개 / 발송하라는 요청을받습니다.
모든 행동에 대해 모범을 보일 것입니다.
I\n이해하기가 가장 쉽습니다. 프로그램은 수입의 동전 하나를 가져다가 그 차례를 끝냅니다. 수입은 상대방이 영향을받지 않고 차단하거나 도전 할 수없는 유일한 조치이므로 프로그램이 두 문자를 인쇄해야하는 두 가지 경우 중 하나입니다.
Fp\n하나의 프로그램이 Foreign Aid를 취한 후 상대방은 ( p) 차단을 거부했습니다 . 다음 번 호출에서 첫 번째 프로그램은 마지막 소문자 p및 / 또는이 줄의 짝수 문자 로이 차례가 걸리지 않았으므로 줄 바꿈을 인쇄하여 현재 차례를 끝내는 것으로 알고 있습니다.
C=\n하나의 프로그램이 쿠데타를 시작했음을 의미합니다. 상대는 라인의 홀수 개의 문자로 반응하도록 부름 받았다는 것을 알고 콘테 사를 포기했습니다. 다시, 첫 번째 프로그램은 이것이 짝수의 문자에 의한 다음 호출에서 불완전한 턴이라는 것을 알았으므로 턴을 끝내기 위해 줄 바꿈을 작성했습니다.
Eq~<\n하나의 프로그램이 Exchange ( E)를 시도 하고 상대방이 ( q)에 도전 했다는 의미입니다 . 교환 프로그램은 진실로 대사 ( ~)가 있고 도전자는 선장을 처벌 ( <) 으로 포기한 것으로 밝혀졌다 . 챌린저가 종료 된 후, 네 번째 문자열을 네 번째 명령 행 인수로 사용하여 교환 프로그램이 다시 호출됩니다 (또는 한 개의 카드 만있는 경우 세 개의 문자). STDOUT에 유지하려는 카드를 나타내는 문자와 파일에 줄 바꿈을 씁니다.
Tq'\n하나의 프로그램이 진실하지 않은 세금을 시도하고 도전을 받고 암살자를 포기했음을 의미합니다. 그것은 당신이 당신의 차례이고 상대방의 올바른 챌린지 (여기에서와 같이) 또는 블록의 잘못된 챌린지에서 카드를 포기하도록 강요된 경우, 두 문자를 쓰는 다른 경우를 보여줍니다. 포기한 카드와 차례를 끝내는 줄 바꿈.
Asq!'\n이는 플레이어 B가 플레이어 A를 암살하려 A했지만 (A) 콘테 사가이를 막을 수 있다고 주장했습니다 ( s). B는 A를 믿지 않고 도전했다 ( q). A는 그들이 실제로 Contessa ( !)를 가지고 있음을 보여 주었다 . B는 암살자를 처벌로 포기하고 동전을 잃어 버렸고 차례 ( '\n)를 끝내고 특별한 경우와 같이 두 문자를 썼습니다. (A가 막거나 도전하지 않기로 결정했다면, 글을 쓸 수 있었고 =, 상대방은 턴이 끝났고 개행을 썼다는 것을 알았을 것 A=\n입니다.
Sq*0\n하나의 프로그램이 도용을 시도한다는 것을 의미합니다. 상대방은 도둑이 함장을 가지고 있다고 믿지 않고 도전합니다. 원래의 프로그램은 선장을 보여 주므로 도전은 실패하고 도전자는 듀크를 형벌로 포기합니다. (그 상대에 대한 또 다른 옵션은 서면에 의해 훔치는 동의하는 것입니다 p. 그 상대가 다음의 차례와 쓰기의 끝을 감지 할 \n의 선 결과 Sp\n.)
중재자
이 Python 스크립트에 의해 프로그램이 호출됩니다. 그것은 10 라운드를 진행하는데, 모든 경쟁자는 다른 모든 경쟁자와 마주보고 첫 번째와 두 번째로 진행합니다. 카드와 동전 수를 추적하고 구두점으로 두 번 줄을 끝내는 첫 번째 프로그램에서 패자를 결정합니다. 0이 아닌 상태로 종료되고 파일을 수정하거나 파일로 불법 이동을 작성하거나 불법 Exchange를 시도하는 프로그램은 자동으로 몰수됩니다. 각 플레이어가 승자없이 블록과 챌린지를 포함하여 100 가지가 넘는 행동을 취하면 두 프로그램 모두 잃게됩니다. 승자는 1 점을받습니다. 프로그램 점수가 가장 높은 플레이어가 승리합니다.
Arbiter의 소스 코드, 특히 get_legal_actions함수 를 읽는 것이 좋습니다 . 사양을 이해하고 자신의 프로그램을 작성하는 데 도움이 될 수 있습니다.
import itertools
import os
import random
import subprocess
class Player:
def __init__(self, name, command):
self.name = name
self.command = command
self.score = 0
self.coins = 1
self.cards = ""
actions_dict = {
'E': '_', 'T': '0', 'A': "'", 'S': '<',
'd': '0', 'a': '_', 'c': '<', 's': '='
}
punishment_to_reveal = {'_': '~', "'": '^', '<': '*', '=': '!', '0': '$'}
reveal_to_punishment = {
punishment_to_reveal[k]: k for k in punishment_to_reveal
}
def get_legal_actions(history, player, opponent):
c = history[-1]
result = ""
# Our turn begins; choose an action.
if c == '\n':
if player.coins >= 10:
return ["C"]
ret = ['I\n'] + list("FET")
if player.coins >= 3:
ret.append("A")
if player.coins >= 7:
ret.append('C')
if opponent.coins > 0:
ret.append("S")
return ret
# Opponent attempted foreign aid; can pass or claim Duke to block.
elif c == 'F':
return list('dp')
# We have been Couped; must surrender a card.
elif c == 'C':
return player.cards
# We failed a challenge; must surrender a card and print a newline
# if it is our turn.
elif c in '~^*!$':
if history[-3] in 'acds':
return [card + '\n' for card in player.cards]
return player.cards
# Opponent attempted Exchange or Tax; can pass or challenge.
elif c == 'E' or c == 'T':
return list('pq')
# Opponent attempted an Assassination; can block, challenge, or give in.
elif c == 'A':
return list('sq') + player.cards
# Opponent attempted to Steal; can pass, block as Ambassador/Captain,
# or challenge.
elif c == 'S':
return list('acpq')
# Opponent blocked; can challenge or withdraw.
elif c in 'acds':
return list('q\n')
# Opponent passed on blocking Foreign Aid/Tax/Exchange or they gave up a
# card as punishment, must end turn.
elif c in "p_'<=0":
return ['\n']
# Opponent challenged us.
elif c == 'q':
challenged_action = history[-2]
# If we have the card they challenged us over, must reveal it.
necessary_card = actions_dict[challenged_action]
if necessary_card in player.cards:
return [punishment_to_reveal[necessary_card]]
# Otherwise, we can give up either of our cards, writing a newline
# if it is our turn.
if challenged_action in 'acds':
return list(player.cards)
else:
return [card + '\n' for card in player.cards]
else:
return None
deck = ['_', "'", '<', '=', '0'] * 3
random.shuffle(deck)
def determine_turn_effects(line, output, cards, current_player, opponent):
last_action = line[-2]
# Only operate if the opponent declined to challenge (p) or the
# program successfully challenged their block
if last_action in "p_'<=0":
primary_action = line[0]
# Foreign Aid
if primary_action == 'F':
print current_player.name, "received 2 coins of Foreign Aid"
current_player.coins += 2
# Tax
elif primary_action == 'T':
print current_player.name, "received 3 coins of Tax"
current_player.coins += 3
# Steal
elif primary_action == 'S':
stolen_coins = 1 if opponent.coins == 1 else 2
print current_player.name,\
"stole %d coins from %s" % (stolen_coins, opponent.name)
current_player.coins += stolen_coins
opponent.coins -= stolen_coins
# Exchange, store desired cards and replace undesired ones
elif primary_action == 'E':
print current_player.name, "tried to take %r" % output, "from", cards
legal_outputs = [''.join(p) for p in itertools.permutations(
cards, len(current_player.cards))]
if output not in legal_outputs:
print current_player.name, "forfeits by illegal exchange"
return opponent
current_player.cards = [
reveal_to_punishment[c] for c in output
]
undesired_cards = list(cards)
for c in output:
undesired_cards.remove(c)
for card in undesired_cards:
deck.append(reveal_to_punishment[card])
random.shuffle(deck)
# Coins are not returned from a successful Contessa block
elif last_action == 's':
print current_player.name, "lost 3 coins from a Contessa block"
current_player.coins -= 3
return None
def play_game(player1, player2, round_number, game_number):
outfilename = os.path.abspath(__file__)[:-len(__file__)] + '_'.join([
player1.name, player2.name, str(round_number), str(game_number)
]) + '.txt'
print outfilename
f = open(outfilename, 'w')
f.close()
players_list = [player1, player2]
player1.cards = [deck.pop(), deck.pop()]
player2.cards = [deck.pop(), deck.pop()]
current_player_index = 0
for i in range(200):
current_player = players_list[current_player_index]
opponent = players_list[(current_player_index+1) % 2]
legal_actions = []
original_contents = []
original_contents_joined = ""
with open(outfilename, 'r') as outfile:
original_contents = outfile.readlines()
original_contents_joined = ''.join(original_contents)
if len(original_contents) == 0:
legal_actions = ['I\n'] + list("FEST")
else:
legal_actions = get_legal_actions(
original_contents[-1], current_player, opponent)
if not legal_actions:
print "Error: file ended in invalid character"
return current_player
# Has the player completed an Exchange? Pass them new cards if so.
exchange_cards = ""
old_last_line = original_contents[-1] if len(original_contents) > 0 else '\n'
if old_last_line[-1] != '\n' and old_last_line[0] == 'E' and \
len(old_last_line) % 2 == 0 and old_last_line[-1] in "p_'<=0":
exchange_cards = punishment_to_reveal[deck.pop()] + \
punishment_to_reveal[deck.pop()]
cards = exchange_cards + ''.join(
punishment_to_reveal[card] for card in current_player.cards)
args = current_player.command + [
outfilename,
str(opponent.coins),
str(current_player.coins),
cards
] + legal_actions
print ' '.join(args)
output = ""
os.chdir(current_player.name)
try:
output = subprocess.check_output(args)
# Competitors that fail to execute must forfeit
except subprocess.CalledProcessError:
print current_player.name, "forfeits by non-zero exit status"
return opponent
finally:
os.chdir('..')
new_contents = []
new_contents_joined = ""
with open(outfilename, 'r') as outfile:
new_contents = outfile.readlines()
new_contents_joined = ''.join(new_contents)
if original_contents_joined != new_contents_joined[:-2] and \
original_contents_joined != new_contents_joined[:-1]:
print current_player.name, "forfeits by modifying the file"
print "old:", original_contents
print "new:", new_contents
return opponent
new_last_line = new_contents[-1]
the_move_made = ""
for action in legal_actions:
if new_last_line.endswith(action):
the_move_made = action
break
# Competitors that make an illegal move must forfeit
if not the_move_made:
print current_player.name, "forfeits with an illegal move,",\
"last line: %r" % new_last_line
print opponent.name, "wins!"
return opponent
print current_player.name, "played %r" % the_move_made
# Side effects of moves.
#
# Income, give the current player a coin.
if the_move_made == "I\n":
print current_player.name, "received 1 coin of income"
current_player.coins += 1
# The program surrendered a card on its turn; take it away.
elif len(the_move_made) == 2:
print current_player.name, "lost a card from being challenged"
current_player.cards.remove(the_move_made[0])
# Coins are not returned from a successful Contessa block
if new_last_line[-3] == '!':
print current_player.name, "lost 3 coins from a Contessa block"
current_player.coins -= 3
# The program surrendered a card when it was not its turn.
elif the_move_made in "_'<=0":
print current_player.name, "gave up a", the_move_made
current_player.cards.remove(the_move_made)
if new_last_line[0] == 'C':
opponent.coins -= 7
elif new_last_line[0] == 'A':
opponent.coins -= 3
# Did the program unsuccessfully challenge an Assassination
# (e.g. Aq^0\n)
# or get caught falsely blocking with a Contessa
# (e.g. Asq0\n)?
# If yes, it loses right away.
if new_last_line[0] == 'A' and new_last_line[1] in 'qs' and \
len(new_last_line) == 4:
print current_player.name, "lost both cards in the same turn."
print opponent.name, "wins!"
return opponent
elif the_move_made == 'S':
print current_player.name, "attempted Steal"
elif the_move_made == 'T':
print current_player.name, "attempted Tax"
elif the_move_made == 'A':
print current_player.name, "attempted Assassinate"
elif the_move_made == 'C':
print current_player.name, "launched a Coup"
elif the_move_made == 'F':
print current_player.name, "attempted Foreign Aid"
elif the_move_made == 'E':
print current_player.name, "attempted Exchange"
elif the_move_made == 'q':
print current_player.name, "challenged"
elif the_move_made == 'p':
print current_player.name, "passed"
elif the_move_made == 'a':
print current_player.name, "blocked with an Ambassador"
elif the_move_made == 'c':
print current_player.name, "blocked with a Captain"
elif the_move_made == 's':
print current_player.name, "blocked with a Contessa"
elif the_move_made == 'd':
print current_player.name, "blocked with a Duke"
# The program revealed a card from an opponent's unsuccessful challenge.
# Give it a new card.
# Special case: a program whose Exchange is unsuccessfully challenged
# may keep the Ambassador it revealed in the Exchange, so give a new
# card for a revealed Ambassador only if it was used to block a Steal.
elif the_move_made in '^*!$' or (the_move_made == '~' and
new_last_line[0] == 'S'):
p = reveal_to_punishment[the_move_made]
current_player.cards.remove(p)
current_player.cards.append(deck.pop())
deck.append(p)
random.shuffle(deck)
print current_player.name, "did have a", the_move_made
# The program ended its turn. We must examine the rest of the line to
# determine the side effects.
elif the_move_made == '\n':
potential_winner = determine_turn_effects(
new_last_line, output.strip(), cards, current_player,
opponent)
if potential_winner:
print potential_winner.name,\
"wins because their opponent made an illegal exchange!"
return potential_winner
# One player has lost all their cards. Victory for the opponent!
if current_player.cards == []:
print opponent.name, "wins by eliminating both opponent cards!"
return opponent
current_player_index += 1
current_player_index %= 2
return None
competitors = []
competitors.append(Player("Challenger", ["./challenger"]))
competitors.append(Player("Random", ["./random"]))
# ...More competitors here
for i in range(10):
print "-- Round", i
j = 0
for pairing in itertools.permutations(competitors, 2):
player1, player2 = pairing
print '--- Game', j, ':', player1.name, 'vs.', player2.name
winner = play_game(player1, player2, i, j)
if not winner:
j += 1
continue
winner.score += 1
player1.coins = 1
player1.cards = ""
player2.coins = 1
player2.cards = ""
deck = ['_', "'", '<', '=', '0'] * 3
random.shuffle(deck)
j += 1
competitors.sort(reverse=True, key=lambda player: player.score)
for player in competitors:
print '%5d %s' % (player.score, player.name)
여러 가지 잡다한
한 프로그램은 다른 프로그램에 특정한 코드를 가질 수 없으며 프로그램은 서로 도울 수 없습니다. (여러 프로그램이있을 수 있지만 어떤 방식 으로든 상호 작용할 수 없습니다.)
만약 당신의 프로그램이 같은 차례에 두 카드를 모두 잃어 버리면, 하나만 쓰면됩니다. 중재자는 제거되었음을 감지합니다.
프로그램이 파일에서 게임의 이력을 검사하는 것이 가능하고 권장되지만 필수는 아닙니다. 그렇게함으로써 그들은 상대방이 어떤 카드를 가지고 있다고 주장하고 거짓말을했는지 파악할 수 있습니다.
실제 쿠데타 게임에서는 액션에 도전 한 다음 같은 차례에 액션을 차단할 수 있습니다. 내가 허용하면 사양을 작동시킬 수 없으므로 주어진 동작에 도전하거나 차단할 수 있지만 둘다는 아닙니다.
@PeterTaylor에 대한 사과, 이전 에이 게시물을 게시 한 제안을 샌드 박스에 게시하고 프로토콜을 다시 작성하여 STDOUT / STDIN에서 출력을주고받습니다. 나는 하루 종일 (원래 도전 과제를 작성하는 데 하루 종일 보냈을 때) 그 일을하기 위해 열심히 노력했습니다. 그러나 거래소는 이러한 방식으로 구현하기가 매우 복잡했으며, 자체 코인 수를 추적하도록 요구함으로써 제출의 복잡성을 증가 시켰습니다. 그래서 나는 도전을 원래대로 다소 게시했습니다.
S, program B blocks writing by c, A는 writing by challenge을 거부합니다 \n. 훔치기의 성공적인 도전은 다음과 같습니다 : A 쓰기 S, B 쓰기로 챌린지 q, A는 다음과 같이 작성하여 챌린지를 인정합니다 _\n. Exchange에 대한 법적 대응은 통과와 도전입니다.