flagとattribute

①フラグ<flag>:その駒の移動ブロック内でのみ有効
②位置フラグ<position-flag>:その駒の移動ブロック内でのみ有効
③属性<attribute>:その駒種でのみゲーム中ずっと有効

 ①②は異なる移動ブロック間で値の受け渡しができず、移動が終わる度(手番が変わる度)に値が破棄されます。
 ③は異なる移動ブロック間で値の受け渡しができ、移動が終わっても(手番が変わっても)ゲーム中は(駒が破棄されるまで)値が保存されます。

①フラグ<flag>
 設定・変更:(set-flag <flag-name> true/false) ・・・移動ブロック内で使用

②位置フラグ<position-flag>
 設定・変更:(set-position-flag <position-flag-name> true/false) ・・・移動ブロック内で使用

③属性<attribute>
 設定:(attribute <attribute-name> true/false) ・・・駒の定義内で使用
 変更:(set-attribute <attribute-name> true/false) ・・・移動ブロック内で使用

※移動ブロック内で値を設定する場合は「set-XXX」を使用します。

※attributeは、駒の定義(piece XX)内で初期値を設定しておく必要があります。

①フラグ<flag>
 参照:(flag? <flag-name>)
 否定参照:(not-flag? <flag-name>)

②位置フラグ<position-flag>
 参照:(position-flag? <position-flag-name>)
 否定参照:(not-position-flag? <position-flag-name>)

③属性<attribute>
 参照:<attribute-name>
 否定参照:(not <attribute-name>)

※attributeは、「(attribute <attribute-name>)」「(not-attribute <attribute-name>)」ではないので注意が必要です。

①flagは、位置に関係なく設定します。
 移動ブロック内で使用する仮変数の位置付けです。

②position-flagは、位置に対して設定します。
 「position-flag」を設定した位置を「position-flag?」で確認するのは、「mark」した位置を「marked?」で確認するのに近い働きです。
 (ただし、「back」=「(go mark)」のような機能はありません)
 移動ブロック内で1箇所にしか使用できない「mark」と違って、「position-flag」は同じ移動ブロック内で複数の位置に対して設定できます。
 また、「position-flag」は同じ位置に対して別の位置フラグ名で重複して設定できます。

③attributeは、駒に対して設定します。
 「(attribute XX)」は駒種全体に共通の初期値を設定し、「(set-attribute XX)」は移動している駒の値を変更します。
 「change-type」で駒種を変更しても、同じattributeがあれば値を引き継げます。






最終更新:2020年08月29日 16:30