당신의 작업 은 가장 높은 점수와 아토 마를 재생 봇을 만듭니다 .
게임 작동 방식 :
게임 보드는 6 개의 "원자"고리로 시작하며 숫자 범위는 1~ 사이 3입니다. 원자 자체에 따라 두 원자 사이 또는 다른 원자에서 원자를 "재생"할 수 있습니다.
일반 원자 또는 특수 원자를 가질 수 있습니다.
정상적인 원자 :
보드에서 사용 가능한 두 개의 원자 사이에서 일반 원자를 재생할 수 있습니다.
범위에서 원자로 시작 1 to 3하지만 40이 움직일 때마다 범위가 1 씩 증가합니다 (40이 이동하면 범위가됩니다 2 to 4).
보드에 범위보다 낮은 원자가 있으면 1 / no. of atoms of that number on the board생성 될 가능성이 있습니다.
2게임을하고 보드가 다음과 같다고 가정 해 봅시다 .
1 1 2 1
2의 오른쪽에를 배치합시다 1.
보드는 이제 다음과 같이됩니다 :
1 1 2 1 2
참고 : 보드가 감싸서 1맨 왼쪽이 실제로 옆에 있습니다.2 맨 오른쪽에 있습니다. 이것은 나중에 중요 할 것입니다.
"특수"원자에는 4 가지 유형이 있으며 다음과 같습니다.
+원자 :
이 원자는 두 원자 사이에서 재생됩니다. 산란 할 확률이 1/5입니다.
원자의 양쪽에있는 +원자가 동일하면 융합이 발생합니다. 작동 방식은 다음과 같습니다.
The two atoms fuse together to create an atom one higher.
(So, two 3 atoms fuse together to form one 4 atom.)
While the atoms on both sides of the fused atom are equal:
If the atoms on the side >= the fused atom:
The new fused atom = the old fused atom's value + 2.
If the atoms on the side < the fused atom:
The new fused atom = the old fused atom's value + 1.
예:
1 1 3 2 2 3 (the 1 on the left-hand side "wraps back"
to the 3 on the right-hand side)
Let's use the + on the two 2's in the middle.
-> 1 1 3 3 3 (the two 2's fused together to make a 3)
-> 1 1 5 (the two 3's fused with the 3, and because 3 >= 3,
the new fused atom = 3 + 2 = 5)
-> 6 (the two 1's fused with the 5, since the board wraps,
and because 1 < 5, the new fused atom = 5 + 1 = 6)
Because the atoms on the sides of the 6 don't exist, fusion stops,
and the board is now [6].
원자의 양쪽에있는 +원자가 다르면 +보드에 남아 있습니다.
예:
1 3 2 3 1 1
Let's use the + on the 2 and 3 in the middle.
-> 1 3 2 + 3 1 1 (2 != 3, so the + stays on the board)
-원자 :
이 원자는 다른 원자에서 재생됩니다. 산란 할 확률이 10 분의 1입니다.
-원자는 보드에서 원자를 제거하고, 하나에 당신에게 선택권을 제공합니다 :
- 다음 라운드에서 제거 된 원자를 재생하거나
- 다음 라운드에서 플레이하려면 + 원자로 바꾸십시오.
예:
1 3 2 3 1 1
Let's use the - on the left-hand 2.
-> 1 3 3 1 1 (the 2 is now removed from the board)
Let's turn it into a +, and place it in between the 3's.
-> 1 4 1 1 (the two 3's fused together to make a 4)
-> 5 1 (the two 1's fused with the 4, and because 1 < 4,
the new fused atom = 4 + 1 = 5)
검은 +원자 (B ) :
이 원자는 2 개의 원자 사이에서 재생됩니다. 80에서 1의 확률로 생성되며 점수가 750을 초과하면 생성됩니다.
이 원자는 기본적으로 +원자와 동일하지만 두 원자를 함께 융합한다는 점을 제외하고 는 원자와 동일합니다 +. 그때부터는 +규칙을 따릅니다 (융합 원자의 양쪽에있는 원자가 같은 경우에만 원자를 융합합니다).
블랙의 결과로 융합 된 원자 +는 다음과 같습니다.
- 융합에서 더 높은 수의 원자 + 3
4두 융합 원자 인 경우+의이
예:
1 3 2 1 3 1
Let's use the black + on the 2 and 1 in the middle.
-> 1 3 5 3 1 (the 2 and 1 fused together to make a 2 + 3 = 5)
-> 1 6 1 (+ rule)
-> 7 (+ rule)
또 다른 예:
2 + + 2
Let's use the black + on the two +'s.
-> 2 4 2 (the two +'s fused together to make a 4)
-> 5 (+ rule)
클론 원자 (C ) :
이 원자는 다른 원자에서 재생됩니다. 스폰 확률은 60 분의 1이며, 점수가 1500을 초과하면 스폰됩니다.
클론 원자를 사용하면 원자를 선택하고 다음 라운드에서 재생할 수 있습니다.
예:
1 1 2 1
Let's use the clone on the 2, and place it to the right of the 1.
-> 1 1 2 1 2
다음은 Python 2의 게임 빌드입니다.
import random
import subprocess
logs='atoms.log'
atom_range = [1, 3]
board = []
score = 0
move_number = 0
carry_over = " "
previous_moves = []
specials = ["+", "-", "B", "C"]
def plus_process(user_input):
global board, score, previous_moves, matches
previous_moves = []
matches = 0
def score_calc(atom):
global score, matches
if matches == 0:
score += int(round((1.5 * atom) + 1.25, 0))
else:
if atom < final_atom:
outer = final_atom - 1
else:
outer = atom
score += ((-final_atom + outer + 3) * matches) - final_atom + (3 * outer) + 3
matches += 1
if len(board) < 1 or user_input == "":
board.append("+")
return None
board_start = board[:int(user_input) + 1]
board_end = board[int(user_input) + 1:]
final_atom = 0
while len(board_start) > 0 and len(board_end) > 0:
if board_start[-1] == board_end[0] and board_end[0] != "+":
if final_atom == 0:
final_atom = board_end[0] + 1
elif board_end[0] >= final_atom:
final_atom += 2
else:
final_atom += 1
score_calc(board_end[0])
board_start = board_start[:-1]
board_end = board_end[1:]
else:
break
if len(board_start) == 0:
while len(board_end) > 1:
if board_end[0] == board_end[-1] and board_end[0] != "+":
if final_atom == 0:
final_atom = board_end[0]
elif board_end[0] >= final_atom:
final_atom += 2
else:
final_atom += 1
score_calc(board_end[0])
board_end = board_end[1:-1]
else:
break
if len(board_end) == 0:
while len(board_start) > 1:
if board_start[0] == board_start[-1] and board_start[0] != "+":
if board_start[0] >= final_atom:
final_atom += 2
else:
final_atom += 1
score_calc(board_start[0])
board_start = board_start[1:-1]
else:
break
if matches == 0:
board = board_start + ["+"] + board_end
else:
board = board_start + [final_atom] + board_end
for a in range(len(board) - 1):
if board[a] == "+":
if board[(a + 1) % len(board)] == board[a - 1]:
board = board[:a - 1] + board[a:]
plus_process(a)
break
def minus_process(user_input, minus_check):
global carry_over, board
carry_atom = board[int(user_input)]
if user_input == len(board) - 1:
board = board[:-1]
else:
board = board[:int(user_input)] + board[int(user_input) + 1:]
if minus_check == "y":
carry_over = "+"
elif minus_check == "n":
carry_over = str(carry_atom)
def black_plus_process(user_input):
global board
if board[int(user_input)] == "+":
if board[int(user_input) + 1] == "+":
inter_atom = 4
else:
inter_atom = board[int(user_input) + 1] + 2
else:
if board[int(user_input)] + 1 == "+":
inter_atom = board[int(user_input)] + 2
else:
inter_list = [board[int(user_input)], board[int(user_input) + 1]]
inter_atom = (inter_list.sort())[1] + 2
board = board[int(user_input) - 1:] + [inter_atom] * 2 + board[int(user_input) + 1:]
plus_process(int(user_input) - 1)
def clone_process(user_input):
global carry_over
carry_over = str(board[int(user_input)])
def regular_process(atom,user_input):
global board
if user_input == "":
board.append(random.randint(atom_range[0], atom_range[1]))
else:
board = board[:int(user_input) + 1] + [int(atom)] + board[int(user_input) + 1:]
def gen_specials():
special = random.randint(1, 240)
if special <= 48:
return "+"
elif special <= 60 and len(board) > 0:
return "-"
elif special <= 64 and len(board) > 0 and score >= 750:
return "B"
elif special <= 67 and len(board) > 0 and score >= 1500:
return "C"
else:
small_atoms = []
for atom in board:
if atom not in specials and atom < atom_range[0]:
small_atoms.append(atom)
small_atom_check = random.randint(1, len(board))
if small_atom_check <= len(small_atoms):
return str(small_atoms[small_atom_check - 1])
else:
return str(random.randint(atom_range[0], atom_range[1]))
def specials_call(atom, user_input):
specials_dict = {
"+": plus_process,
"-": minus_process,
"B": black_plus_process,
"C": clone_process
}
if atom in specials_dict.keys():
if atom == "-":
minus_process(user_input[0], user_input[1])
else:
specials_dict[atom](user_input[0])
else:
regular_process(atom,user_input[0])
def init():
global board, score, move_number, carry_over, previous_moves
board = []
score = 0
for _ in range(6):
board.append(random.randint(1, 3))
while len(board) <= 18:
move_number += 1
if move_number % 40 == 0:
atom_range[0] += 1
atom_range[1] += 1
if carry_over != " ":
special_atom = carry_over
carry_over = " "
elif len(previous_moves) >= 5:
special_atom = "+"
else:
special_atom = gen_specials()
previous_moves.append(special_atom)
bot_command = "python yourBot.py"
bot = subprocess.Popen(bot_command.split(),
stdout = subprocess.PIPE,
stdin = subprocess.PIPE)
to_send="/".join([
# str(score),
# str(move_number),
str(special_atom),
" ".join([str(x) for x in board])
])
bot.stdin.write(to_send)
with open(logs, 'a') as f:f.write(to_send+'\n')
bot.stdin.close()
all_user_input = bot.stdout.readline().strip("\n").split(" ")
specials_call(special_atom, all_user_input)
print("Game over! Your score is " + str(score))
if __name__ == "__main__":
for a in range(20):
with open(logs, 'a') as f:f.write('round '+str(a)+'-'*50+'\n')
init()
봇 작동 방식 :
입력
- 봇은 현재 플레이중인 원자와 보드 상태의 2 가지 입력을받습니다.
- 원자는 다음과 같습니다.
++원자를 위해--원자를 위해B검은+원자C클론 원자{atom}정상 원자
- 보드의 상태는 다음과 같습니다.
atom 0 atom 1 atom 2... atom n, 공백으로 분리 된 원자 를 사용하여 ( "링"게임 보드를 시뮬레이션하기 위해atom n랩핑 함atom 1)
- 이 두 개는로 구분됩니다
/.
입력 예 :
1/1 2 2 3 (the atom in play is 1, and the board is [1 2 2 3])
+/1 (the atom in play is +, and the board is [1] on its own)
산출
재생중인 원자가 무엇인지에 따라 문자열을 출력합니다.
원자가 두 원자 사이에서 재생되는 경우 :
원자를 재생하려는 간격을 출력합니다. 간격은 다음과 같이 각 원자 간의 간격과 같습니다.
atom 0, GAP 0, atom 1, GAP 1, atom 2, GAP 2... atom n, GAP N(
gap n아톰atom 1과 원자 사이에 원자를 놓으려는 것을 나타냅니다.n) 따라서 원자2를 연주하려면 출력 하십시오gap 2.
- 원자가 원자에서 재생되는 경우 :
- 출력은, 그래서 그것을 재생하고자하는 원자
2당신이 원자를 재생하려는 경우atom 2.
- 출력은, 그래서 그것을 재생하고자하는 원자
- 원자가
-:- 재생하려는 원자를 출력 한 다음 공백을 입력 한 다음 나중에
y/n원자를+나중에 선택할 수 있도록2, "y"선택합니다. 따라서 원자를 재생하려는 경우 원자atom 2를로 설정하려고합니다+. 참고 : 여기에는 1 대신 2 개의 입력이 필요합니다.
- 재생하려는 원자를 출력 한 다음 공백을 입력 한 다음 나중에
출력 예 :
(Atom in play is a +)
2 (you want to play the + in gap 2 - between atom 2 and 3)
(Atom in play is a -)
3 y (you want to play the - on atom 3, and you want to change it to a +)
2 n (you want to play the - on atom 2, and you don't want to change it)
- 로봇 작동하려면, 당신은에 가야
Popen(프로그램이 그래서 경우 파이썬 목록으로 프로그램 실행을하게 무엇이든 그것을 (코드의 끝 부분 주위에) 비트 및 교체derp.java, 교체["python", "bot.py"]로["java", "derp.java"]).
답변 별 사양 :
- 봇의 전체 코드를 답에 넣으십시오. 맞지 않으면 계산되지 않습니다.
- 각 사용자는 하나 이상의 봇을 가질 수 있지만 모두 별도의 답변 게시물에 있어야합니다.
- 또한 봇 이름을 지정하십시오.
채점 :
- 가장 높은 점수를받은 봇이 승리합니다.
- 봇은 20 게임에서 테스트되며 최종 점수는 20 게임의 평균입니다.
- 타이 브레이커는 답변을 업로드 할 때가됩니다.
따라서 귀하의 답변 형식은 다음과 같습니다.
{language}, {bot name} Score: {score}
행운을 빕니다!
input_atom\natom0 atom1 .... atomn\n를 들어 STDIN의 경우
+는 요소 목록 에 넣을 수있는 것처럼 보이지만 텍스트 설명에는 없습니다.
+A의-원자 사용할 수 있습니까? 만약 당신이 선택한다면 당신은 다음 움직임을y보장받을 것+입니까?