SlideShare a Scribd company logo
#JULIALANG AND SHOGI(JAPANESE CHESS)
twitter: @kimrin	

Takeshi KIMURA
IN THIS PRESENTATION:
!

About us	

Why we choose #Julialang	

Shogi and Chess: differences between two games	

principles and technics of Shogi playing software
ABOUT US:

Mecha Lady Shogi team (twitter = @mechajyo, 5 members):	

the team of Shogi Program developers	

with 2 Lady Shogi Professionals, 2 ladies and a geek:)	

developing Japanese Chess Program written in #Julialang !
WHY WE CHOOSE #JULIALANG:
Speed	

most other Shogi programs are written in C/C++	

needed H/W resources: CPU and Memory access (not HDD
access)	

Maintenance	

dynamic language like code style is very useful for developing
Shogi programs
CHESS:
Chess:	

8x8=64 squares	

about 80 available moves in
middle game	

computer programs already
won by human professionals
SHOGI
Shogi	

9x9 = 81 squares	

can reuse captured pieces	

about160 available moves in
endgame	

most of pieces can promote in
enemy’s field	

computer programs NOT YET
win by human professionals!
PRINCIPLE AND TECHNICS IN
SHOGI PLAYING SOFTWARE

Alpha-Beta search	

bit board and magic board technics	

machine-learning evaluation functions
ALPHA-BETA SEARCH
problem:	

in the given Shogi board representation, find best move from
its available moves	

solution:	

search partial tree of game tree and find a best move and root
node’s tree value(Evaluation Value)	

Depth-first search by using a recursive function
function AlphaBeta( gs::GameStatus, WB, depth, alpha, beta)

if depth <= 0.0 

va = eval(gs, alpha, beta)

return va

end



moves = generate(gs)



for i = 1:length(moves)

makeMove( gs, moves[i], WB)



val = -AlphaBeta( gs, WB$1, depth-1.0, -beta, -alpha)



takeBack( gs, moves[i], WB)



if val > alpha # alpha-update

alpha = val



# save this move



if alpha >= beta # beta-cutoff

return beta

end

end

end

alpha

end


return eval	

(leaf node)
generate moves

(good move first)

pseudo code	

(simplified)

recursive

calls

find good moves
cutoff redundant

search
PSEUDO CODE SUMMARY
If node is leaf node, return the value of evaluation function	

Generate child node moves(=available moves)	

For each moves:	

Make move	

Call myself(=this function) in NegaMax manner	

Take back move	

If it’s good move, record this move(=Alpha Update)	

if very good move, cutoff subsequent child node’s search(Beta Cutoff)	

return beta	

return alpha
BITBOARD TECHNICS	

(IN MOVE GENERATION)
In chess programs, board representation is 64bit Unsigned Integer
value: each bit represents existence of pieces	

Pawn, Knight,…, King, for each piece kinds, there are 2 bitmap
values(one for White, another for Black)	

In Shogi programs, square of the board is 81. So in ordinal
programming languages(such as C++), we use 3x32bit Unsigned
Integer = 96bit bitmap values	

#Julialang’s 128bit Unsigned Integer is suitable for storing 81bit Shogi
bitmaps!
BASIC IDEAS OF BITBOARD
for each pieces of white side(for example: White King):	

get piece position that of move from	

dest = BitMapTable( piece, from, White) # available moves table	

dest &= (not White pieces) # with single bitwise AND!	

for each dest bits:	

generates Move and stores move buffers
SOURCE CODE OF WHITE KING
target = (~p.WhitePieces) & MaskOfBoard

!
bbp = p.bb[MJOU] #White King’s bitmap
while bbp > uint128(0)
from = trailing_zeros(bbp)
bbp $= BitSet[from+1]
dest::BitBoard = target & gs.AttackTableNonSlide[MJOU,from+1]
toru::BitBoard = dest & p.BlackPieces #captured pieces
while dest > uint128(0)
to = trailing_zeros(dest)
dest $= BitSet[to+1]
toriflag = ((toru & BitSet[to+1]) > 0)?FLAG_TORI:0
count += 1
out[count] = Move(MJOU,from,to,toriflag,p.square[to+1]&0x0f,0)::Move
InsertMoveAB(count,out,gs)
end
end
MJOU = White King(OU,王)	

tori/toru = capture	

!

Magic board (More advanced technics):	

calculate dest bitmap by multiples MAGIC numbers(one
direction hash)
MACHINE LEARNING

EVALUATION FUNCTIONS
This technic is established by Hoki-san’s “Bonanza” program	

Evaluation function value = dot(WeightVector, FeatureVector)	

Val = w1*f1 + w2*f2 + … + wn*fn	

Hoki-san established the way of learning Weight Vectors by Machine Learning(reinforcement
learning)	

King - OpponentKing - another piece relationships	

King - piece - and another piece relationships	

(Three pieces relationships)	

We use Hoki-san’s fv.bin for calculation function values
CONCLUSION:
We will attend WCSC24 (The 24th World Computer Shogi Championship)	

Mecha Lady Shogi (メカ女子将棋, @mechajyo) is using #Julialang

for her programming language	

メカ=Mecha, 女子=Girl, Lady	

But actually, playing ability of mechajyo is not so strong :(	

We will also attend DenOu Sen tournament (電王戦トーナメント) may will be hold in Nov. 2014	

電王=Electrical King	

Thank you!

More Related Content

Similar to #Julialang and Computer Shogi (Japanese Chess)

Need to make a ReversiOthello Board game in JAVAThe board size ca.pdf
Need to make a ReversiOthello Board game in JAVAThe board size ca.pdfNeed to make a ReversiOthello Board game in JAVAThe board size ca.pdf
Need to make a ReversiOthello Board game in JAVAThe board size ca.pdf
flashfashioncasualwe
 
[Ultracode Munich #4] Demo on Animatron by Anton Kotenko
[Ultracode Munich #4] Demo on Animatron by Anton Kotenko[Ultracode Munich #4] Demo on Animatron by Anton Kotenko
[Ultracode Munich #4] Demo on Animatron by Anton Kotenko
BeMyApp
 
ACI-Webinar-3-MinMaxAlphaBetaPruning-TicTacToe.pptx
ACI-Webinar-3-MinMaxAlphaBetaPruning-TicTacToe.pptxACI-Webinar-3-MinMaxAlphaBetaPruning-TicTacToe.pptx
ACI-Webinar-3-MinMaxAlphaBetaPruning-TicTacToe.pptx
ssuser1eba67
 
19012011102_Nayan Oza_Practical-7_AI.pdf
19012011102_Nayan Oza_Practical-7_AI.pdf19012011102_Nayan Oza_Practical-7_AI.pdf
19012011102_Nayan Oza_Practical-7_AI.pdf
NayanOza
 
Music as data
Music as dataMusic as data
Music as data
John Vlachoyiannis
 
«Python на острие бритвы: PyPy project» Александр Кошкин, Positive Technologies
«Python на острие бритвы: PyPy project» Александр Кошкин, Positive Technologies«Python на острие бритвы: PyPy project» Александр Кошкин, Positive Technologies
«Python на острие бритвы: PyPy project» Александр Кошкин, Positive Technologies
it-people
 
Artificial intelligence games
Artificial intelligence gamesArtificial intelligence games
Artificial intelligence games
Sujithmlamthadam
 
Ai
AiAi
[SI] Ada Lovelace Day 2014 - Tampon Run
[SI] Ada Lovelace Day 2014  - Tampon Run[SI] Ada Lovelace Day 2014  - Tampon Run
[SI] Ada Lovelace Day 2014 - Tampon Run
Maja Kraljič
 
(Alpha) Zero to Elo (with demo)
(Alpha) Zero to Elo (with demo)(Alpha) Zero to Elo (with demo)
(Alpha) Zero to Elo (with demo)
MeetupDataScienceRoma
 
AI.ppt
AI.pptAI.ppt
AI.ppt
ArghyaGayen2
 
Artificial intelligence - python
Artificial intelligence - pythonArtificial intelligence - python
Artificial intelligence - python
Sunjid Hasan
 
Objectives Create a Java program using programming fundamentals (fi.docx
Objectives Create a Java program using programming fundamentals (fi.docxObjectives Create a Java program using programming fundamentals (fi.docx
Objectives Create a Java program using programming fundamentals (fi.docx
amit657720
 
Python Puzzlers
Python PuzzlersPython Puzzlers
Python Puzzlers
Tendayi Mawushe
 
Speeding up bowtie2 by improving cache-hit rate
Speeding up bowtie2 by improving cache-hit rateSpeeding up bowtie2 by improving cache-hit rate
Speeding up bowtie2 by improving cache-hit rate
Igor Sfiligoi
 
Swift for tensorflow
Swift for tensorflowSwift for tensorflow
Swift for tensorflow
규영 허
 
Atari 2600 VCS Programming
Atari 2600 VCS ProgrammingAtari 2600 VCS Programming
Atari 2600 VCS Programming
Carlos Duarte do Nascimento
 
The Ring programming language version 1.7 book - Part 53 of 196
The Ring programming language version 1.7 book - Part 53 of 196The Ring programming language version 1.7 book - Part 53 of 196
The Ring programming language version 1.7 book - Part 53 of 196
Mahmoud Samir Fayed
 
API Python Chess: Distribution of Chess Wins based on random moves
API Python Chess: Distribution of Chess Wins based on random movesAPI Python Chess: Distribution of Chess Wins based on random moves
API Python Chess: Distribution of Chess Wins based on random moves
Yao Yao
 
JAVA- need help with my code! Need help updating the GUI part of my co.docx
JAVA- need help with my code! Need help updating the GUI part of my co.docxJAVA- need help with my code! Need help updating the GUI part of my co.docx
JAVA- need help with my code! Need help updating the GUI part of my co.docx
olsenlinnea427
 

Similar to #Julialang and Computer Shogi (Japanese Chess) (20)

Need to make a ReversiOthello Board game in JAVAThe board size ca.pdf
Need to make a ReversiOthello Board game in JAVAThe board size ca.pdfNeed to make a ReversiOthello Board game in JAVAThe board size ca.pdf
Need to make a ReversiOthello Board game in JAVAThe board size ca.pdf
 
[Ultracode Munich #4] Demo on Animatron by Anton Kotenko
[Ultracode Munich #4] Demo on Animatron by Anton Kotenko[Ultracode Munich #4] Demo on Animatron by Anton Kotenko
[Ultracode Munich #4] Demo on Animatron by Anton Kotenko
 
ACI-Webinar-3-MinMaxAlphaBetaPruning-TicTacToe.pptx
ACI-Webinar-3-MinMaxAlphaBetaPruning-TicTacToe.pptxACI-Webinar-3-MinMaxAlphaBetaPruning-TicTacToe.pptx
ACI-Webinar-3-MinMaxAlphaBetaPruning-TicTacToe.pptx
 
19012011102_Nayan Oza_Practical-7_AI.pdf
19012011102_Nayan Oza_Practical-7_AI.pdf19012011102_Nayan Oza_Practical-7_AI.pdf
19012011102_Nayan Oza_Practical-7_AI.pdf
 
Music as data
Music as dataMusic as data
Music as data
 
«Python на острие бритвы: PyPy project» Александр Кошкин, Positive Technologies
«Python на острие бритвы: PyPy project» Александр Кошкин, Positive Technologies«Python на острие бритвы: PyPy project» Александр Кошкин, Positive Technologies
«Python на острие бритвы: PyPy project» Александр Кошкин, Positive Technologies
 
Artificial intelligence games
Artificial intelligence gamesArtificial intelligence games
Artificial intelligence games
 
Ai
AiAi
Ai
 
[SI] Ada Lovelace Day 2014 - Tampon Run
[SI] Ada Lovelace Day 2014  - Tampon Run[SI] Ada Lovelace Day 2014  - Tampon Run
[SI] Ada Lovelace Day 2014 - Tampon Run
 
(Alpha) Zero to Elo (with demo)
(Alpha) Zero to Elo (with demo)(Alpha) Zero to Elo (with demo)
(Alpha) Zero to Elo (with demo)
 
AI.ppt
AI.pptAI.ppt
AI.ppt
 
Artificial intelligence - python
Artificial intelligence - pythonArtificial intelligence - python
Artificial intelligence - python
 
Objectives Create a Java program using programming fundamentals (fi.docx
Objectives Create a Java program using programming fundamentals (fi.docxObjectives Create a Java program using programming fundamentals (fi.docx
Objectives Create a Java program using programming fundamentals (fi.docx
 
Python Puzzlers
Python PuzzlersPython Puzzlers
Python Puzzlers
 
Speeding up bowtie2 by improving cache-hit rate
Speeding up bowtie2 by improving cache-hit rateSpeeding up bowtie2 by improving cache-hit rate
Speeding up bowtie2 by improving cache-hit rate
 
Swift for tensorflow
Swift for tensorflowSwift for tensorflow
Swift for tensorflow
 
Atari 2600 VCS Programming
Atari 2600 VCS ProgrammingAtari 2600 VCS Programming
Atari 2600 VCS Programming
 
The Ring programming language version 1.7 book - Part 53 of 196
The Ring programming language version 1.7 book - Part 53 of 196The Ring programming language version 1.7 book - Part 53 of 196
The Ring programming language version 1.7 book - Part 53 of 196
 
API Python Chess: Distribution of Chess Wins based on random moves
API Python Chess: Distribution of Chess Wins based on random movesAPI Python Chess: Distribution of Chess Wins based on random moves
API Python Chess: Distribution of Chess Wins based on random moves
 
JAVA- need help with my code! Need help updating the GUI part of my co.docx
JAVA- need help with my code! Need help updating the GUI part of my co.docxJAVA- need help with my code! Need help updating the GUI part of my co.docx
JAVA- need help with my code! Need help updating the GUI part of my co.docx
 

Recently uploaded

9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
saastr
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
Safe Software
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid ResearchHarnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Neo4j
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
Neo4j
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
Neo4j
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
c5vrf27qcz
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Precisely
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
Fwdays
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
BibashShahi
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
Javier Junquera
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
operationspcvita
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
Fwdays
 

Recently uploaded (20)

9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid ResearchHarnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
 

#Julialang and Computer Shogi (Japanese Chess)

  • 1. #JULIALANG AND SHOGI(JAPANESE CHESS) twitter: @kimrin Takeshi KIMURA
  • 2. IN THIS PRESENTATION: ! About us Why we choose #Julialang Shogi and Chess: differences between two games principles and technics of Shogi playing software
  • 3. ABOUT US: Mecha Lady Shogi team (twitter = @mechajyo, 5 members): the team of Shogi Program developers with 2 Lady Shogi Professionals, 2 ladies and a geek:) developing Japanese Chess Program written in #Julialang !
  • 4. WHY WE CHOOSE #JULIALANG: Speed most other Shogi programs are written in C/C++ needed H/W resources: CPU and Memory access (not HDD access) Maintenance dynamic language like code style is very useful for developing Shogi programs
  • 5. CHESS: Chess: 8x8=64 squares about 80 available moves in middle game computer programs already won by human professionals
  • 6. SHOGI Shogi 9x9 = 81 squares can reuse captured pieces about160 available moves in endgame most of pieces can promote in enemy’s field computer programs NOT YET win by human professionals!
  • 7. PRINCIPLE AND TECHNICS IN SHOGI PLAYING SOFTWARE Alpha-Beta search bit board and magic board technics machine-learning evaluation functions
  • 8. ALPHA-BETA SEARCH problem: in the given Shogi board representation, find best move from its available moves solution: search partial tree of game tree and find a best move and root node’s tree value(Evaluation Value) Depth-first search by using a recursive function
  • 9. function AlphaBeta( gs::GameStatus, WB, depth, alpha, beta) if depth <= 0.0 va = eval(gs, alpha, beta) return va end moves = generate(gs) for i = 1:length(moves) makeMove( gs, moves[i], WB) val = -AlphaBeta( gs, WB$1, depth-1.0, -beta, -alpha) takeBack( gs, moves[i], WB) if val > alpha # alpha-update alpha = val # save this move if alpha >= beta # beta-cutoff return beta end end end alpha end return eval (leaf node) generate moves
 (good move first) pseudo code (simplified) recursive
 calls find good moves cutoff redundant
 search
  • 10. PSEUDO CODE SUMMARY If node is leaf node, return the value of evaluation function Generate child node moves(=available moves) For each moves: Make move Call myself(=this function) in NegaMax manner Take back move If it’s good move, record this move(=Alpha Update) if very good move, cutoff subsequent child node’s search(Beta Cutoff) return beta return alpha
  • 11. BITBOARD TECHNICS (IN MOVE GENERATION) In chess programs, board representation is 64bit Unsigned Integer value: each bit represents existence of pieces Pawn, Knight,…, King, for each piece kinds, there are 2 bitmap values(one for White, another for Black) In Shogi programs, square of the board is 81. So in ordinal programming languages(such as C++), we use 3x32bit Unsigned Integer = 96bit bitmap values #Julialang’s 128bit Unsigned Integer is suitable for storing 81bit Shogi bitmaps!
  • 12. BASIC IDEAS OF BITBOARD for each pieces of white side(for example: White King): get piece position that of move from dest = BitMapTable( piece, from, White) # available moves table dest &= (not White pieces) # with single bitwise AND! for each dest bits: generates Move and stores move buffers
  • 13. SOURCE CODE OF WHITE KING target = (~p.WhitePieces) & MaskOfBoard ! bbp = p.bb[MJOU] #White King’s bitmap while bbp > uint128(0) from = trailing_zeros(bbp) bbp $= BitSet[from+1] dest::BitBoard = target & gs.AttackTableNonSlide[MJOU,from+1] toru::BitBoard = dest & p.BlackPieces #captured pieces while dest > uint128(0) to = trailing_zeros(dest) dest $= BitSet[to+1] toriflag = ((toru & BitSet[to+1]) > 0)?FLAG_TORI:0 count += 1 out[count] = Move(MJOU,from,to,toriflag,p.square[to+1]&0x0f,0)::Move InsertMoveAB(count,out,gs) end end
  • 14. MJOU = White King(OU,王) tori/toru = capture ! Magic board (More advanced technics): calculate dest bitmap by multiples MAGIC numbers(one direction hash)
  • 15. MACHINE LEARNING
 EVALUATION FUNCTIONS This technic is established by Hoki-san’s “Bonanza” program Evaluation function value = dot(WeightVector, FeatureVector) Val = w1*f1 + w2*f2 + … + wn*fn Hoki-san established the way of learning Weight Vectors by Machine Learning(reinforcement learning) King - OpponentKing - another piece relationships King - piece - and another piece relationships (Three pieces relationships) We use Hoki-san’s fv.bin for calculation function values
  • 16. CONCLUSION: We will attend WCSC24 (The 24th World Computer Shogi Championship) Mecha Lady Shogi (メカ女子将棋, @mechajyo) is using #Julialang
 for her programming language メカ=Mecha, 女子=Girl, Lady But actually, playing ability of mechajyo is not so strong :( We will also attend DenOu Sen tournament (電王戦トーナメント) may will be hold in Nov. 2014 電王=Electrical King Thank you!