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
}

우선순위

  1. not (가장 높음)
  2. and
  3. or (가장 낮음)

명확성을 위해 괄호를 사용하세요:

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 == 0
chesslang
# AND 로직: 단일 조건 내에서 and 사용
victory:
  add:
    # 킹이 존에 있고 AND 기물이 1개일 때만 승리
    bare_king_hill: King in zone.hill and opponent.pieces == 1

카운터 조건

조건설명예시
checks >= NN회 이상 체크checks >= 3
captures >= NN회 이상 잡기captures >= 10
moves >= NN회 이상 이동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_moves50수 동안 잡기/폰 이동 없음활성화
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 == 1
chesslang
# 특정 조건 제거
draw:
  remove:
    - stalemate     # 스테일메이트는 패배로 처리할 때

트리거 조건

트리거의 when 절에서 사용됩니다.

이벤트 데이터

변수사용 가능설명
piecemove, capture이동하는 기물
originmove, capture시작 위치
targetmove, capture종료 위치
capturedcapture잡힌 기물
playerturn_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기물이 타입 Xpiece.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

참고