Menu

#7 About giving Royal attribute to pieces

1.0
pending
FBR (3)
2020-10-27
2020-02-20
Qi Liang
No

In Ko Shogi https://en.wikipedia.org/wiki/Ko_shogi?wprov=sfti1 There is a multi-royal-pieces game.
In this game. When the General is captured, if the Middle troop and Banner on the player's field, the player is not lose. But when Banner or Middle troop is captured, the player is lose. When the Middle troop promote to Governor, it have the attribute of royal piece. I think when Banner on the field, Middle troop have the attribute of royal piece, but when Banner is captured, Middle troop is lose it's royal attribute.
How can I achieve it in C/CIF?

Discussion

  • Gregor Cramer

    Gregor Cramer - 2020-03-02
    • status: open --> pending
     
  • Gregor Cramer

    Gregor Cramer - 2020-03-02

    Ko Shogi has very complex rules, especially the promotion rules are very complex, and I need to invent some more board rules:

    royal{PieceSet}

    • capture(N)
      This means that only N of the royal piece types have to be captured to win the game. Per default all royal pieces have to be captured to win the game. Note that this attribute is useful only if also attribute "expose" will be applied. Example:
      royal{KM}=expose,capture(1)
      As soon as one of the pieces K or M will be captured, the game is won.

    promotion

    • range{PieceSet}{Rule}
      If any pair of the given pieces are fulfilling the underlying rule then the associated piece promotion rules will be applied. Example:
      promotion-=range{:FF::IM:}{:Q5:} -:FF:==:TB: @:Q5:=Q5
      If piece :FF: and :IM: ever find themselves within five open intersections of each other in a queen's direction (rule associated with :Q5:), piece :FF: immediately reverts to :TB: (with rule system "-").
    • annulling{PieceSet}
      Remove this promotion rule for the side that has moved as soon as one of the given pieces have been captured. This implies that all the promoted pieces of the side that has moved will demote, if their promotion was caused by this promotion rule. Example:
      promotion*=annulling{:TB:} *B==:RA:
      As soon as the opponent is capturing piece :TB:, all friendly pieces of type :RA: will demote to B immediately, and the promotion rule "*B==:RA:" is not applicable anymore for the side who has lost piece :TB:.
    • die{PieceSet}
      All enemy pieces in given piece set will die (removed from board) as soon as any associated piece promotion rule will be applied. Example:
      promotion+{:SC:}=die{:PF:} +:SC:==:MM:
      As soon as a piece :SC: is promoting to :MM: (with rule system "+"), all enemy pieces :PF: will be removed from board.
    • withinzone{PieceSet}
      Only promote if also at least one piece of each piece type is inside the promotion zone. Example:
      promotion+{:SC:}=withinzone{:FD:R} +:SC:==:MM:
      As soon as piece :SC: is entering the last rank (promotion zone), it will promote to :MM:, but only if either a piece of type :FD: or of type R is already located on last rank.
    • promote{PieceSet}
      Promote all pieces belonging to given piece types on the spot with associated piece promotion rule if any of the pieces belonging to the piece type set of the board rule is promoting. Example:
      promotion+{A}=promote{B} +A==C +B==D
      Promote pieces of type B as well on the spot concurrently when a piece of type A is promoting to C (with rule system "+").

    Now we are ready for defining the rules of Ko Shogi:

    Ko-Shogi  19x19 -- 58
    
    :fd::sm::en::cs::gh::sr::wr:a:sc:g:pl:a:wr::sr::gh::cs::en::tb::fd:
    r:fh:1q1:du:1:sn:d:ma:b:sn:1:du:1q1:fh:r/
    ec:sb::lb:ec:sb::lb:e:fw:e:lb::sb:ce:lb::sb:ce/
    :ca:1:hs:1:hs:1:hs:1:hs:1:hs:1:hs:1:hs:1:hs:1:ca:/
    1p1p1p1p1:pu:1p1p1p1:pu:1/
    :cu::su::ch::sp::ch::sp::ch::sp::ch::su::ch::sp::ch::sp::ch::sp::ch::su::cu:/
    9:va:9/
    19/19/19/19/19/
    9:VA:9/
    :CU::SU::CH::SP::CH::SP::CH::SP::CH::SU::CH::SP::CH::SP::CH::SP::CH::SU::CU:/
    1P1P1P1P1:PU:1P1P1P1:PU:1/
    :CA:1:HS:1:HS:1:HS:1:HS:1:HS:1:HS:1:HS:1:HS:1:CA:/
    EC:SB::LB:EC:SB::LB:E:FW:E:LB::SB:CE:LB::SB:CE/
    R:FH:1Q1:DU:1:SN:D:MA:B:SN:1:DU:1Q1:FH:R/
    :FD::SM::EN::CS::GH::SR::WR:A:SC:G:PL:A:WR::SR::GH::CS::EN::TB::FD: b
    
    a1=:FD:|*Zen’ei*||Advance Guard|
    a2=R|*Go'ei*||Rear Guard|
    a3=E|**||Elephant|
    a4=:CA:|*Kisō*||Cavalry|
    a6=:CU:|*Shasō*||Chariot Unit|
    b1=:SM:|*Shinzō*||Spiritual Monk|
    b2=:FH:|*Hyakusō*||Centuria|
    b3=C|**||Cannon|
    b5=P|*Fuhyō*||Pawn|
    b6=:SU:|*Haisō*||Shield Unit|
    c1=:EN:|*Gunshō*||Engineer|
    c3=:SB:|*Kyū*||Crossbow|
    c4=:HS:|*Bahei*||Cavalryman|
    c6=:CH:|*Sha*||Chariot|
    d1=:CS:|*Gunri*||Chief of Staff|
    d2=Q|*Wasō*||Quartermaster|
    d3=:LB:|*Kyū*||Longbow|
    d6=:SP:|*Hai*||Shield|
    e1=:GH:|*Shayo*||Staff|
    f1=:SR:|*Toneri*||Aide|
    f2=:DU:|*Sensō*||Millenary|
    g1=:WR:|*Rikishi*||Sumo Wrestler|
    h1=A|*Shimpei*||Aide de Camp|
    h2=:SN:|*Gohei*||Sentry|
    i1=:SC:|*Kishitsu*||Clerk|
    i2=D|*Ko*||Drum|
    j1=G|*Shō*||General|
    j2=:MA:|*Chūgun*||Middle Troop|
    j3=:FW:|*Butsurōki*||European Cannon|
    j5=:PU:|*Fusō*||Patrol Unit|
    j7=:VA:|*Sempō*||Vanguard|
    k1=:PL:|*Sambō*||Staff Officer|
    k2=B|*Ki*||Banner|
    r1=:TB:|*Kōdō*||Taoist Priest|
    +a1=:HV:|*Temmō*||Heaven's Vengeance|
    +a2=:EV:|*Chimō*||Earth’s Vengeance|
    +a4=:WI:|*Temba*||Winged Horse|
    +b1=:IL:|*Shōtō*||Immaculate Light|
    +b2=:WH:|*Yōyō*||War Hawk|
    +b3=:GC:|*Hōsha*||Gun Carriage|
    +b5=O|*Fuhyō*||Pawn|
    +b6=:IB:|*Tenrui*||Imperial Base|
    +c1=:PF:|*Dokka*||Poison Flame|
    +c3=:CC:|*Doki*||Crossbow Cavalryman|
    +d1:VC:|*Fukushi*||Vice Commander|
    +d2=:TW:|*Koyoku*||Tiger Wing|
    +d3=:LC:|*Kōki*||Longbow Cavalryman|
    +e1:VB:|*Hyakko*||Village Brigade|
    +f1=:TO:|*Senko*||Town Brigade|
    +f2=:DA:|*Ryūjō*||Dragon Ascending|
    +i1=:MM:|*Gunshi*||Master at Arms|
    +i2=:TH:|*Hekireki*||Thunderclap|
    +j2=:GO:|*Sui*||Governer|
    +j3=:CG:|*Shinkisha*||Chariot of the Gods|
    +j7=:CO:|*Toshi*||Commissar|
    +k1=:BD:|*Kiko*||Banner and Drums|
    +k2=:RA:|*Shōyō*||Roaming Assault|
    +r1=:FF:|*Gorimu*||Five-li Fog|
    
    promotion+[14-19]=enter,move,leave,optional
    promotion+[1-19]=capture{:GO::MA:}
    promotion+{:SC:}=die{:PF:},withinzone{:FD:R},promote{:FD:R}
    promotion*[14-19]=enter,move,leave,optional
    promotion*[1-19]=capture{GB},annulling{:TB:}
    promotion&=capture{:WR::DA::RA::TH:}
    promotion#=capture{:WR::DA::RA::TH:},annulling{:TB:}
    promotion$=capture{:FW:}
    promotion%=capture{:TB:}
    promotion-=range{:FF::IM:}{:Q5:}
    draw=repetition(4)
    royal{G:GO:}=expose,noperpetualcheck,castle{}
    royal{B:MA:}=expose,noperpetualcheck,castle{},capture(1)
    
    @:XC:=c{^:IB::FF:}Q+(mQ06-c{:FF:}Q)
    @:XL:=c{^:IB::SP::SU::CU::GC::FF:}Q
    @:XM:=c{^:FF:}Q
    @:PM:=mc{:TB::SM::FF::IL:}AD--!cK
    @:CX:=!ppy{^:IB::SU:}?Q
    @:Q5:=Q5
    
    A=F+frlW +A==Q &A==Q
    B=F+lrW *B==:RA: #B==:RA:
    C=mF--:CX: +C==:GC:
    :CA:=(N-[ffN])(!N) +:CA:==:WI:
    :CH:=mc{^:IB:}R5 +:CH:==:CU:
    :CS:=F+fbW +:CS:==:VC: &:CS:==:VC:
    :CU:=mc{^:IB:}R +:CU:==:DU:
    D=F+lrW *D==:TH: #D==:TH:
    :DU:=Q +:DU:==:DA:
    E=B
    :EN:=fF+fbW +:EN:==:PF: &:EN:==:PF:
    :FD:=fR+bW +:FD:==:HV:
    :FH:=WB +:FH:==:WH:
    :FW:=mF--[(!:XC:--[!:XC:])+!(:XC:-[c{^:IB:}Q])] +:FW:==:CG: &:FW:==:CG:
    G=K
    :GH:=F+fW +:GH:==:VB: &:GH:==:VB:
    :HS:=N +:HS:==:CA: $:HS:==:CA:
    :LB:=mF--!(:XL:)3 +:LB:==:LC: &:LB:==:LC:
    :MA:=K +:MA:==:GO: &:MA:==:GO:
    P=W +P==:PU: &P==:PU: %P==O
    O=lrbW +O==:PU: &O==:PU:
    :PL:=WA +:PL:==:BD:
    :PU:=fbR+W +:PU:==:CO:
    Q=FR +Q==:TW:
    R=fW+bR +R==:EV:
    :SB:=mF--!(:XL:)5 +:SB:==:CC: &:SB:==:CC:
    :SC:=FD +:SC:==:MM:
    :SM:=:PM: +:SM:==:IL:
    :SN:=F+lrbW +:SN:==:FH: &:SN:==:FH:
    :SP:=F +:SP:==:SU: &:SP:==:SU:
    :SR:=W+fF +:SR:==:TO: &:SR:==:TO:
    :SU:=F+rlR +:SU:==:IB:
    :TB:=:PM: +:TB:==:FF:
    :VA:=fR5 +:VA:==:CO:
    :WR:=aK--[K]
    
    :MM:=F--D
    :BD:=W--A
    :TO:=sK+fbR
    :VB:=vK+lrR
    :VC:=B+fR
    :PF:=(fF+fbW)--!(dcK)0*
    :FF:=:PM:--:PM: -:FF:==:TB:
    :IL:=:PM:--:PM:
    :HV:=bW+fQ
    :GO:=K
    :TH:=(adW)05 %:TH:==D
    :RA:=(aW)05
    :DA:=Q--aK--[K]
    :TW:=R+(F--[F])
    :WH:=B+(W--[W])
    :EV:=bB+sR+fW
    :CG:=mR5--[(!:XC:--[!:XC:])+!(:XC:-[c{^:IB:}Q])]
    :LC:=mN--!(:XM:)3
    :CC:=mN--!(:XM:)5
    :GC:=mR5--:CX:
    :WI:=N-[N]
    :CO:=B+fbR
    :IB:=B+lrR
    
     

    Last edit: Gregor Cramer 2020-03-02
  • Qi Liang

    Qi Liang - 2020-10-27

    there is a little wrong, Pawn could not go foward only if the drum has captured.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.