Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
freem
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Openai/692b2791-efd0-8000-b05e-3c2e0d9cb768
(section)
Add languages
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Let's build a tiny Go helper to simulate a proposed ladder. === from typing import List, Tuple, Set Board = List[List[str]] # 'B', 'W', or '.' def empty_board(size=9) -> Board: return [['.' for _ in range(size)] for _ in range(size)] def neighbors(x, y, size=9): for dx,dy in [(-1,0),(1,0),(0,-1),(0,1)]: nx,ny = x+dx, y+dy if 0 <= nx < size and 0 <= ny < size: yield nx,ny def get_group(board: Board, x: int, y: int) -> Set[Tuple[int,int]]: size = len(board) color = board[y][x] assert color in ('B','W') group = set() stack = [(x,y)] while stack: cx,cy = stack.pop() if (cx,cy) in group: continue if board[cy][cx] != color: continue group.add((cx,cy)) for nx,ny in neighbors(cx,cy,size): if board[ny][nx] == color and (nx,ny) not in group: stack.append((nx,ny)) return group def liberties(board: Board, group: Set[Tuple[int,int]]) -> Set[Tuple[int,int]]: size = len(board) libs = set() for x,y in group: for nx,ny in neighbors(x,y,size): if board[ny][nx] == '.': libs.add((nx,ny)) return libs def place(board: Board, x: int, y: int, color: str) -> Board: size = len(board) assert board[ny][nx] != color if False else True ๋์งํธ ๋ฐ๋ํ ๊ทธ๋ฃน ์ฐพ๊ธฐ from typing import List, Tuple, Set Board = List[List[str]] # 'B', 'W', or '.' def empty_board(size=9) -> Board: return [['.' for _ in range(size)] for _ in range(size)] def neighbors(x, y, size=9): for dx,dy in [(-1,0),(1,0),(0,-1),(0,1)]: nx,ny = x+dx, y+dy if 0 <= nx < size and 0 <= ny < size: yield nx,ny def get_group(board: Board, x: int, y: int) -> Set[Tuple[int,int]]: size = len(board) color = board[y][x] assert color in ('B','W') group = set() stack = [(x,y)] while stack: cx,cy = stack.pop() if (cx,cy) ์ฌ๋ค๋ฆฌ ํจํด ์ค๊ณ 7x7 ๋ณด๋์์ ์ฌ๋ค๋ฆฌ ํจํด์ ์ ์ํฉ๋๋ค. ์ด๊ธฐ ๋ ๋ฐฐ์ด์ ์ค์ ํ๊ณ , ์๋ฅผ ๋ค์ด, ํฐ ๋์ด (4,1)์ ์์นํ์ฌ ์ถ์ ์ ์์ํ๊ฒ ํฉ๋๋ค. ํฐ ๋ ๊ทธ๋ฃน์ 2๊ฐ์ ์์ ๋๋ฅผ ๊ฐ์ง๋ฉฐ, ๋ฐ๋ณต๋๋ ํจํด์ ๋๊ฐ์ ์ผ๋ก ์๋์ชฝ์ผ๋ก ์ด๋ํฉ๋๋ค. ํ๋ฉด์์ ์ถ์ ํด ๊ฐ๋ฉฐ ํจํด์ ์ฌ๊ตฌ์ฑํ ์ ์์ต๋๋ค. ์ฌ๋ค๋ฆฌ ํจํด ์ค๊ณ์ ๋์ฒด ์ ๊ทผ๋ฒ ๋ณด์ฌ์ค ์ด๋ฏธ์ง์์ ์ ํํ ์ขํ๋ฅผ ์ถ์ถํ๋ ๊ฒ์ด ์ด๋ ค์ด ์ํฉ์ด์ง๋ง, ๋์ ๋ ผ๋ฆฌ์ ์ธ ๋ฐฉ์์ ์ฌ์ฉํ๋ ค ํฉ๋๋ค. Go ๊ด๋ จ ์ฌ์ดํธ์์ ํ์ค ํจํด์ ์ ํํ๊ฑฐ๋, ๊ธฐ์กด์ ์๋ ค์ง ํจํด์ ์ฐธ๊ณ ํ ์ ์์ต๋๋ค. ์ค์ํ ๊ฒ์ ๋ฐ๋ณต๋๋ ์ฌ๋ค๋ฆฌ ํํ๋ฅผ ๋ฐ๋ผ๊ฐ๋ ๊ฒ์ด์ง, ์ธ๋ถ ์ขํ์ ์ผ์นํ ํ์๋ ์์ต๋๋ค. ์ฌ๋ค๋ฆฌ ํจํด ์ฌ๊ฒํ ์ฐ๋ฆฌ๊ฐ ๊ฐ์ง 9x9 ๋ณด๋์์ ํฐ ๋๊ณผ ๊ฒ์ ๋์ ๋๊ฐ์ ๋ฐฉํฅ์ผ๋ก ๋ฐฐ์น๋์์ง๋ง, ์ ํ์ ์ธ ์ฌ๋ค๋ฆฌ ํํ๋ ๊ฒ์ ๋๊ณผ ํฐ ๋์ด ๊ต๋๋ก ๊ฒน์ณ์ ธ ๋ค๋ฆฌ์ฒ๋ผ ์ฐ๊ฒฐ๋ฉ๋๋ค. ์ด ๋ฐฐ์ด์ ์ค์ ์ถ๊ฒฉ ์ํ๋ฅผ ๋ํ๋ด์ง ์์ผ๋ฉฐ, ์์ ์์น๋ ์ด๊ธฐ ๊ตฌ๋๋ ๋ณด์ฌ์ฃผ์ง ์๋ ์ ์์ ๋ค์ ์ ์ ์ธ ํํ์ ๋๋ค. ์ฌ๋ค๋ฆฌ ์งํ ์ํฉ ๊ทธ๋ฆผ ์ค๊ณ ์ฐ๋ฆฌ๋ 9x9 ๋๋ 7x7 ๋ณด๋๋ก ์ค๊ฐ ๋จ๊ณ์์ ์ฌ๋ค๋ฆฌ ๊ทธ๋ฆผ์ ๊ทธ๋ฆด ์ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด ํฐ ๋ 1์ D3, ๊ฒ์ ๋ 2๋ C3(์ํ๋ฆฌ), ํฐ ๋ 3์ C4, ๊ฒ์ ๋ 4๋ B4 ๋ฑ์ผ๋ก ๊ฐ ๋จ๊ณ๋ฅผ ์ซ์ 1๋ถํฐ N๊น์ง ํ์ํ์ฌ ๋จ๊ณ๋ณ๋ก ๋ณด์ฌ์ค ์ ์์ต๋๋ค. ์ฌ์ฉ์๋ ์ ํํ ์์น๋ฅผ ๊ฐ์กฐํ๋ฏ๋ก ๋์ ์ธ ๋ค์ด์ด๊ทธ๋จ๋ ํ์ฉํ ์ ์์ต๋๋ค. ์ฌ๋ค๋ฆฌ ์งํ ์ํฉ ๊ทธ๋ํฝ ์ค๊ณ ๋ณด๊ณ ์์์ 9x9 ๋๋ 7x7 ๋ณด๋๋ก ์ผ๋ถ ๋์ ํ์ํ๋ ์ค๊ฐ ์ฌ๋ค๋ฆฌ ๋จ๊ณ๋ฅผ ๋ณด์ฌ์ฃผ๋, ๊ฐ ๋จ๊ณ๋ฅผ ์์ฐจ์ ์ผ๋ก ๋ง๊ฒ๋ 1๋ถํฐ N๊น์ง ๋ฒํธ๋ฅผ ๋ถ์ฌ์ ํ์ํ ์ ์์ต๋๋ค. ๋ค๋ง, ๋ ์์ ๋ฒํธ๋ฅผ ๊ฒน์น๋ ๊ฑด ์ด๋ ต๊ธฐ ๋๋ฌธ์, ๋ฒํธ๋ ๋ณ๋๋ก ๋์ดํ๋ ๊ฒ ์ข๊ฒ ์ด์. ๊ทธ๋ฌ๋ฉด์ 7x7 ๋ณด๋๋ก ์ฝ๊ฒ ์งํํ ์ ์๊ฒ ๊ตฌ์ฑํ๋ ๊ฒ ์ข๊ฒ ๋ค์. ๊ตฌ์ฒด์ ์ฌ๋ค๋ฆฌ ํจํด ์ค๊ณ ์ฌ๋ค๋ฆฌ ํจํด์ ์์ฑํ๋ ค๋ฉด ๋จผ์ ์ค์ฌ ๊ทผ์ฒ์ ์์ ์ขํ์์ ๊ฒฝ๋ก๋ฅผ ์ค์ ํด ๋ด ๋๋ค. ํฐ ๋์ด ๋๊ฐ์ ์ผ๋ก ๋ด๋ ค๊ฐ๋ฉฐ ์ฐ๊ฒฐ๋๋ ๊ฒฝ๋ก๋ฅผ ์ค์ ํ ํ, ๊ฐ ๋จ๊ณ๋ณ๋ก ํฐ ๋์ ์ถ๊ฐํ๊ณ , ๊ฒ์ ๋์ ๋ฐ๋ ๋ฐฉํฅ์ ๋ฐฐ์นํฉ๋๋ค. ์ด๋ฅผ 7x7 ๋ณด๋์์ ๋จ์ํํ์ฌ ์๋ฎฌ๋ ์ด์ ํ ์ ์์ต๋๋ค. ์ฌ๋ค๋ฆฌ ์๊ณ ๋ฆฌ์ฆ ์ค๊ณ "์ด๋ค ์์ง์ ์์"๋ฅผ ์ ์ํ๋ ๋์ , ์์ง์ ์์๋ฅผ ์๊ณ ๋ฆฌ์ฆ์ผ๋ก ์ค๊ณํ ํ ์ด๋ฅผ ๋ฐํ์ผ๋ก ๋ณด๋๋ฅผ ์๋ ์์ฑํ๋ ๋ฐฉ์์ผ๋ก ์ ๊ทผํ๊ณ ์ ํฉ๋๋ค. ๋จผ์ , ์ฌ๋ค๋ฆฌ ์ถ์ ์๊ณ ๋ฆฌ์ฆ์ ์ ์ํ๊ณ , ๋น ๋ณด๋์์ ์ฐ์์ ์ผ๋ก ์ด๋ํ๋ฉฐ ์ฌ๋ค๋ฆฌ ํจํด์ด ์์ฑ๋ ์ง ํ์ธํด ๋ณด๊ฒ ์ต๋๋ค. Searching for Go ladder sequence examples in SGF ์ฌ๋ค๋ฆฌ ๊ตฌ์กฐ ์ค๊ณ ์ขํ ์กฐํ์ ์ด๋ ค์์ ๊ณ ๋ คํด, ์์ฒด์ ์ผ๋ก ์ฌ๋ค๋ฆฌ ๊ตฌ์กฐ๋ฅผ ์๋ฎฌ๋ ์ด์ ํ์ฌ ์์ฑํ๋ ๋ฐฉ์์ ํํ๊ฒ ์ต๋๋ค. 7x7 ๋ณด๋ ์์์ ์ต๋จ์ ์ฌ๋ค๋ฆฌ ์์๋ฅผ ์ค๊ณํ๊ณ , ๊ฐ ์ด๋์ ๋ณด์ฅํ๋๋ก ํ์ฌ ํฉ๋ฒ์ ์ด๋ฉฐ ๊ตฌ์กฐ์ ์ธ ์ฌ๋ค๋ฆฌ ํจํด์ ๊ตฌํํ ์ ์์ต๋๋ค. ์ฌ๋ค๋ฆฌ ์งํ ์กฐ๊ฑด ์กฐ์ ์ฌ๋ค๋ฆฌ๊ฐ ์์ ๊ทธ๋ฃน์์ ์๋ฆฌ๋ฉด์ ์๊ธฐ๋๋ฐ, ๋ธ๋์ ํฐ ๋์ ์์ ๋๋ฅผ 2๋ก ์ค์ด๊ธฐ ์ํด ์ถ๊ฐ ๋์ ๋์์ผ ํฉ๋๋ค. ํฐ ๊ทธ๋ฃน์ด ์ํ๋ฆฌ๊ฐ ๋๊ธฐ ์ ์๋ ๋ธ๋์ด ์ํ๋ฆฌ๋ฅผ ๋ง๋ค์ด์ผ ํ๋ค๋ ์กฐ๊ฑด์ ์ถ๊ฐํด์ผ ํฉ๋๋ค. ๊ทธ๋์ ๋งค๋ฒ ํฐ ๋์ด ํ์ฅ๋ ๋, ๋ธ๋์ ๋ง์ง๋ง ์์ง์์ด ์ํ๋ฆฌ๋ฅผ ๋ง๋ค๋๋ก ์ค๊ณํด์ผ ํฉ๋๋ค. ์ฌ๋ค๋ฆฌ ์๊ณ ๋ฆฌ์ฆ ์ค๊ณ ์ฐ๋ฆฌ๋ ์์ ๋ณด๋์ ์์ง์์ ์ ์ํ์ฌ, ๊ฐ ๋ธ๋์ ์์ง์์ด ์ํ๋ฆฌ๋ก ์ด์ด์ง๋์ง ํ์ธํ ์ ์กฐ์ ํ ์ ์์ต๋๋ค. 7x7 ํฌ๊ธฐ์ ๋น ๋ณด๋์์ ์์ํด, ์ขํ๋ฅผ ์ค์ ํ๊ณ , ์ฌ๋ค๋ฆฌ ์๊ณ ๋ฆฌ์ฆ์ ์คํํด์ ๋งค ๋จ๊ณ๋ง๋ค ํฐ ๋ ๋์ํ์ ๊ณ ๋ฅผ ์ ์์ต๋๋ค. ์ฌ๋ค๋ฆฌ ํจํด ๋ถ์ ๋ธ๋์ ์ํ๋ฆฌ ํฌ์ธํธ๋ (x0-1,y0) ๋๋ (x0-2,y0+1) ๋ฑ์ผ ์ ์์ต๋๋ค. ์ด๋ค์ ์ ํํ ํ๋จํ๋ ค๋ฉด ์ธ์ ์ฑ์ ๋ถ์ํด์ผ ํฉ๋๋ค. ์๋ฅผ ๋ค์ด, ํฐ ๋์ ๋ง์ง๋ง ํ์ฅ ์ง์ ์ด๋, ์ฌ๋ค๋ฆฌ ํจํด์ ๊ดํ ๊ฐ๋จํ 2x3 ์ง์ฌ๊ฐํ ๊ตฌ์กฐ๋ฅผ ๊ณ ๋ คํด๋ณผ ์ ์์ต๋๋ค. ์คํํ๋ ์ฌ๋ค๋ฆฌ ํจํด ์๋ฎฌ๋ ์ด์
Summary:
Please note that all contributions to freem are considered to be released under the Creative Commons Attribution-ShareAlike 4.0 (see
Freem:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)