ChessLang 조건 완전 레퍼런스
조건 레퍼런스
조건은 이동이 가능한 시점, 트리거가 발동하는 시점, 승리/무승부 조건이 적용되는 시점을 제한하는 데 사용됩니다.
이동 조건
이 조건들은 where 키워드와 함께 사용하여 기물 이동을 제한합니다.
칸 조건
| 조건 | 설명 | 예시 |
|---|---|---|
empty | 대상 칸이 비어있음 | step(forward) where empty |
enemy | 대상에 적 기물이 있음 | step(diagonal) where enemy |
friend | 대상에 아군 기물이 있음 | step(any) where friend |
occupied | 대상에 기물이 있음 | step(any) where occupied |
chesslang
piece Pawn {
move: step(forward) where empty
capture: step(forward-diagonal) where enemy
}경로 조건
| 조건 | 설명 | 예시 |
|---|---|---|
clear | 경로가 막히지 않음 | step(forward, 2) where clear |
blocked | 경로가 막힘 | 특수 이동에 사용 |
chesslang
piece Pawn {
move: step(forward, 2) where first_move and clear
}
piece Rook {
move: slide(orthogonal) # 막히면 암묵적으로 멈춤
}기물 상태 조건
| 조건 | 설명 | 예시 |
|---|---|---|
first_move | 기물이 아직 이동하지 않음 | step(forward, 2) where first_move |
has_moved | 기물이 이동한 적 있음 | step(any) where has_moved |
chesslang
piece King {
move: step(any)
# 캐슬링은 first_move 필요
move: castle where first_move and not check
}게임 상태 조건
| 조건 | 설명 | 예시 |
|---|---|---|
check | 킹이 체크 상태 | move where check |
not check | 킹이 체크 상태가 아님 | castle where not check |
chesslang
piece King {
# 체크 중에는 캐슬링 불가
move: castle where first_move and not check
}존 조건
| 조건 | 설명 | 예시 |
|---|---|---|
in zone.X | 위치가 존 X에 있음 | target in zone.hill |
on rank N | 위치가 랭크 N에 있음 | piece on rank 8 |
on file X | 위치가 파일 X에 있음 | piece on file e |
chesslang
board:
zones:
promotion: [a8, b8, c8, d8, e8, f8, g8, h8]
piece Pawn {
move: step(forward) where target not in zone.promotion
move: promote where target in zone.promotion
}조건 조합
논리 연산자
| 연산자 | 설명 | 예시 |
|---|---|---|
and | 두 조건이 모두 참 | first_move and clear |
or | 하나라도 참 | empty or enemy |
not | 조건이 거짓 | not check |
chesslang
piece Pawn {
move: step(forward, 2) where first_move and clear and empty
}
piece King {
move: castle where first_move and not check and clear
}우선순위
not(가장 높음)andor(가장 낮음)
명확성을 위해 괄호를 사용하세요:
chesslang
# 이것들은 동일합니다
step(any) where (empty or enemy) and not check
step(any) where empty or enemy and not check # 우선순위로 인해 동일승리 조건
승리 조건을 정의하기 위해 victory 섹션에서 사용됩니다.
조건 결합 규칙 (OR 로직)
⚠️ 중요: 여러 승리 조건은 OR로 결합됩니다.
- 조건 중 하나라도 만족하면 게임이 종료됩니다.
- AND 로직이 필요하면 단일 조건 내에서
and를 사용합니다.
| 액션 | 설명 | 결합 방식 |
|---|---|---|
add | 새 조건 추가 | 기존 조건 OR 새 조건 |
replace | 같은 이름의 조건 교체 | OR 결합 유지 |
remove | 조건 제거 | - |
내장 조건
| 조건 | 설명 |
|---|---|
checkmate | 상대가 체크메이트 |
stalemate | 상대가 합법적인 수가 없음 (기본적으로 무승부) |
기물 조건
| 조건 | 설명 | 예시 |
|---|---|---|
King captured | 킹이 잡힘 | victory: King captured |
King in zone.X | 킹이 존에 있음 | King in zone.hill |
King on rank N | 킹이 랭크에 있음 | King on rank 8 |
pieces == N | 정확한 기물 수 | opponent.pieces == 0 |
pieces <= N | 기물 수 제한 | opponent.pieces <= 1 |
chesslang
# OR 결합: checkmate OR hill OR elimination 중 하나 만족시 승리
victory:
add:
hill: King in zone.hill
elimination: opponent.pieces == 0chesslang
# AND 로직: 단일 조건 내에서 and 사용
victory:
add:
# 킹이 존에 있고 AND 기물이 1개일 때만 승리
bare_king_hill: King in zone.hill and opponent.pieces == 1카운터 조건
| 조건 | 설명 | 예시 |
|---|---|---|
checks >= N | N회 이상 체크 | checks >= 3 |
captures >= N | N회 이상 잡기 | captures >= 10 |
moves >= N | N회 이상 이동 | moves >= 50 |
chesslang
# checkmate OR three_check 중 하나 만족시 승리
victory:
add:
three_check: checks >= 3무승부 조건
무승부 조건을 정의하기 위해 draw 섹션에서 사용됩니다.
조건 결합 규칙 (OR 로직)
⚠️ 중요: 승리 조건과 마찬가지로 여러 무승부 조건은 OR로 결합됩니다.
- 조건 중 하나라도 만족하면 무승부로 종료됩니다.
| 액션 | 설명 | 결합 방식 |
|---|---|---|
add | 새 조건 추가 | 기존 조건 OR 새 조건 |
replace | 같은 이름의 조건 교체 | OR 결합 유지 |
remove | 조건 제거 | - |
내장 무승부 조건
| 조건 | 설명 | 기본값 |
|---|---|---|
stalemate | 합법적인 수 없음 | 활성화 |
repetition | 포지션 3회 반복 | 활성화 |
fifty_moves | 50수 동안 잡기/폰 이동 없음 | 활성화 |
insufficient | 불충분한 기물 | 활성화 |
chesslang
# 기존 조건 교체
draw:
replace:
repetition: position_count >= 5 # 5회 반복으로 변경커스텀 무승부 조건
chesslang
# OR 결합: stalemate OR repetition OR ... OR bare_kings 중 하나 만족시 무승부
draw:
add:
bare_kings: White.pieces == 1 and Black.pieces == 1chesslang
# 특정 조건 제거
draw:
remove:
- stalemate # 스테일메이트는 패배로 처리할 때트리거 조건
트리거의 when 절에서 사용됩니다.
이벤트 데이터
| 변수 | 사용 가능 | 설명 |
|---|---|---|
piece | move, capture | 이동하는 기물 |
origin | move, capture | 시작 위치 |
target | move, capture | 종료 위치 |
captured | capture | 잡힌 기물 |
player | turn_start, turn_end | 현재 플레이어 |
chesslang
trigger on_capture {
on: capture
when: piece.type == Pawn and captured.type == Queen
do: set piece.state.promoted = true
}기물 타입 조건
| 조건 | 설명 | 예시 |
|---|---|---|
piece.type == X | 기물이 타입 X | piece.type == Knight |
piece.owner == X | 기물이 X 소유 | piece.owner == White |
chesslang
trigger knight_bonus {
on: capture
when: piece.type == Knight
do: add_bonus(player, 1)
}상태 조건
| 조건 | 설명 | 예시 |
|---|---|---|
piece.state.X == Y | 상태 값 확인 | piece.state.rage >= 3 |
piece.traits.has(X) | 특성 보유 | piece.traits.has(royal) |
chesslang
trigger rage_attack {
on: move
when: piece.type == Berserker and piece.state.rage >= 3
do: transform piece to RagingBerserker
}위치 조건
| 조건 | 설명 | 예시 |
|---|---|---|
target in zone.X | 대상이 존에 있음 | target in zone.danger |
origin on rank N | 출발지가 랭크에 있음 | origin on rank 2 |
distance(a, b) < N | 거리 확인 | distance(origin, target) > 3 |
chesslang
trigger teleport_check {
on: move
when: distance(origin, target) > 3
do: mark target with warp_effect
}존재 조건
| 조건 | 설명 | 예시 |
|---|---|---|
exists piece where X | 조건에 맞는 기물 존재 | exists Knight where owner == White |
all pieces where X | 모든 기물이 조건 충족 | all Pawns where on rank 7 |
count pieces where X | 조건 충족 기물 수 | count Queens where owner == player |
chesslang
trigger last_piece {
on: capture
when: count pieces where owner == captured.owner == 1
do: win player
}예시
조건부 이동
chesslang
piece DesperatePawn {
# 일반 이동
move: step(forward) where empty
# 첫 턴에 더블 무브
move: step(forward, 2) where first_move and clear and empty
# 대각선으로 잡기
capture: step(forward-diagonal) where enemy
# 위험할 때 뒤로 이동 가능
move: step(backward) where check and empty
}조건부 트리거
chesslang
trigger promote_on_hill {
on: move
when: piece.type == Pawn and target in zone.hill
do: transform piece to Queen
}
trigger atomic_explosion {
on: capture
when: not (captured.type == Pawn) # 폰은 폭발하지 않음
do: {
remove pieces in radius(1) from target
}
}복잡한 승리 조건
chesslang
victory:
add:
# 레이싱 킹스 - 먼저 8랭크에 도달하면 승리
race: King on rank 8 and not opponent.King on rank 8
# 깃발 잡기 - 상대 코너에 도달
flag: King in zone.opponent_corner
# 제거 - 모든 기물 잡기
elimination: opponent.pieces == 0
# 기물 우위
domination: pieces >= opponent.pieces * 2참고
- 승리 & 무승부 조건 - 조건 결합 규칙 상세 설명
- 액션 레퍼런스
- 방향 레퍼런스
- 레벨 2 - Compose