Skip to content

Commit

Permalink
バグの修正
Browse files Browse the repository at this point in the history
  • Loading branch information
k-k-github authored Nov 20, 2023
1 parent cadf31f commit f20c498
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
6 changes: 6 additions & 0 deletions simulator/src/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,12 @@ def firstMovement(self, pos, target, directions=directionSet, destroy=True,
ans = nextPos = None
newDistance = distance[pos]
for i, x, y in self.allDirection(pos, directions):
if -1 < distance[x][y] < newDistance and \
self.walls[x][y] != otherWall:
newDistance = distance[x][y]
nextPos = (x, y)
ans = i
for i, x, y in self.allDirection(pos, fourDirectionSet):
if -1 < distance[x][y] < newDistance:
newDistance = distance[x][y]
nextPos = (x, y)
Expand Down
1 change: 1 addition & 0 deletions simulator/src/solve1.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from simulator import *
import time
from collections import deque
import view
boolean = True
def solve1(interface, solver):
matchInfo = interface.getMatchInfo()
Expand Down
21 changes: 16 additions & 5 deletions simulator/src/solve5.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ def building(board, mason, notProtectedCastles, targets, alreadyTarget):
fourDirectionList) if target not in alreadyTarget], destroy=True)
if target is None:
# solve1
target = board.nearest(mason,
board.around(board.around(notProtectedCastles, fourDirectionList),
fourDirectionList),
destroy=True)
walls = board.around(notProtectedCastles, fourDirectionList)
wallPoints = []
for point in walls:
if board.walls[point] != 1: wallPoints.append(point)
target = board.nearest(mason, board.around(wallPoints,
fourDirectionList))
if target is None: return [0, 0]
if mason == target:
for i, x, y in board.allDirection(mason, fourDirectionSet):
Expand All @@ -25,7 +27,10 @@ def building(board, mason, notProtectedCastles, targets, alreadyTarget):
match board.walls[x][y]:
case 0: return [2, i]
case 2: return [3, i]
return [0, 0]
targets = board.around(board.around(notProtectedCastles,
fourDirectionList), fourDirectionList)
targets.remove(target)
target = board.nearest(mason, targets, destroy=True)
ans = board.firstMovement(mason, target)
if ans is None: return [0, 0]
return ans
Expand Down Expand Up @@ -232,6 +237,12 @@ def solve5(interface, solver):
if y in cantMoveTo[x]: movement[-1] = [0, 0]
else: cantMoveTo[x].add(y)

viewPos = []
for mason, d in zip(board.myMasons, movement):
if d[1] == 0: continue
direction = eightDirectionList[d[1]-1]
viewPos.append(tuple(map(sum,zip(mason, direction))))
view.viewPos = viewPos
interface.postMovement(movement)
turn = matchInfo.turn
time.sleep(preTime+matchInfo.turnTime*2-0.2-time.time())
Expand Down

0 comments on commit f20c498

Please sign in to comment.