SlideShare a Scribd company logo
Women playing bridge in Tallahassee by Florida Memory Project Public Domain
Computer Bridge with F#:
DSLs and Genetic Programming
Computer Bridge with F#:
DSLs and Genetic Programming
@felienne
Women playing bridge in Tallahassee by Florida Memory Project Public Domain
We interrupt the presentation for an
important message on SCIENCE
We interupt the presentation for an
important message on SCIENCE
Using F# and genetic programming to play computer bridge
Computer Bridge with F#:
DSLs and Genetic Programming
@felienne
Women playing bridge in Tallahassee by Florida Memory Project Public Domain
Omar Sharif bridge by Nationaal Archief (Ron Kroon) CC-BY-SA-3.0
N
S
E
W
Omar Sharif bridge by Nationaal Archief (Ron Kroon) CC-BY-SA-3.0
52 cards
in 4 suits
Tricks of
four cards
Tricks of
four cards
52 cards
Tricks of
four cards
52 cards
= 13 tricks
Trump
Trump
Always wins
Trump
Always wins
Trump
Always wins
4 hands
Let’s explain
with code
The basics
I	could	also	say	just	Hand	of	list,	
but	I	like	this	because:
The basics
Before we
play
though...
Bidding
phase
Hand
Bidding
phase
BidHand
The basics
I	could	also	say	just	Hand	of	list,	
but	I	like	this	because:
Add bids
Start small,
but real
DSL Tip #1
Add bids
Add bids
No Trump?!
Bidding
Bidding
Bidding
Bidding
SAd
Two suit types
Two suit types
Two suit types
Two suit types
Two suit types
Two suit types
Duplication
Monads to
the rescue?!
Monads to
the rescue?!
Monads to
the rescue?!
Monads to
the rescue?!
Monads to
the rescue?!
Monads to
the rescue?!
Monads to
the rescue?!
Monads to
the rescue?!
Add bids
Does not sound
like domain
Balancing
act
Simple
language
Simple
language
Simple
language
Simple
language
Simple
language
over
perfect
model
DSL Tip #2
Hand
BidHand
BidHand
BidHand
635,013,559,600
BidHand
635,013,559,600 35
Mapping
Mapping
Hand
Hand
4
Hand
4
1) Max suit length
Hand
Hand
2) Card value
Hand
4
4
3
2
Hand
3) Balance4
4
3
2
Getting a bid
Getting a bid
Getting a bid
Getting a bid
Getting a bid
Getting a bid
Getting a bid
Pattern =>
Language
opportunity!
DSL Tip #3
Getting a bid
Getting a bid
Getting a bid
Getting a bid
Getting a bid
Getting a bid
Getting a bid
Evaluating a hand
Evaluating a hand
Evaluating a hand
Traverse the
list until a
match
Using F# and genetic programming to play computer bridge
It takes two
Hand
4
1) Max suit length
Hand
2) Card value
It takes two
It takes two
It takes two
It takes two
It takes two
Read aloud
once in a while
DSL Tip #4
Better syntax
Better syntax
Better syntax
Better syntax
Better syntax
Better syntax
Using F# and genetic programming to play computer bridge
We can
make it
EVEN BETTER!
Even better!
Even better!
Even better!
Even better!
Even better!
Even better!
Even better!
Even better!
Even better!
Even better!
Error!
Let’s read the
lang specs!
Let’s read the
lang specs!
Let’s read the
lang specs!
Let’s read the
lang specs!
We cannot
overload ‘->’
Let’s read the
lang specs!
Even better!
Even better!
Thanks
Tomas!!!
Regularly
hang out
with Tomas
DSL Tip #5
Regularly
hang out
with Tomas
DSL Tip #5
Know about
language
features
DSL Tip #5
It takes two
It takes three!
Hand
4
1) Max suit length
Hand
2) Card value
Hand
3) Balance4
4
3
2
It takes three!
It takes three!
No
pretty
Such
long
Much
math
It takes three!
It takes three!
It takes three!
It takes three!
It takes three!
It takes three!
It takes three!
Partial
application
Partial
application
Partial
application
Partial
application
Partial
application
Partial
application
Partial
application
Using F# and genetic programming to play computer bridge
Using F# and genetic programming to play computer bridge
Using F# and genetic programming to play computer bridge
Using F# and genetic programming to play computer bridge
Using F# and genetic programming to play computer bridge
www.felienne.com/archives/tag/desiderius
Current state
Current state
Why a DSL?
Why a DSL?
Genetic
programming
Survival of
the fittest
Survival of
the fittest
Survival of
the fittest
Survival of
the fittest
Survival of
the fittest
Using F# and genetic programming to play computer bridge
Using F# and genetic programming to play computer bridge
Using F# and genetic programming to play computer bridge
Using F# and genetic programming to play computer bridge
Using F# and genetic programming to play computer bridge
Using F# and genetic programming to play computer bridge
Survival of
the fittest?
Survival of
the fittest?
Fitness
function
Fitness
function
Fitness
function
Any
ideas??
Fitness
function
Using F# and genetic programming to play computer bridge
Using F# and genetic programming to play computer bridge
Using F# and genetic programming to play computer bridge
Some corners
were cut
Usually we
don’t mutate
text
Usually we
don’t mutate
text
Mutating plain text
not very effective
Mutate ASTs
Mutate ASTs
if
DSL = fewer
option for AST!
Geneticprogrammingon a DSL
Geneticprogrammingon a DSL
Geneticprogrammingon a DSL
Geneticprogrammingon a DSL
Geneticprogrammingon a DSL
Let the machines
do the thinking
Geneticprogrammingon a DSL
Geneticprogrammingon a DSL
Let the machines
do the thinking
Let the machines
do the thinking
Let the machines
do the thinking
Let the machines
do the thinking
Using F# and genetic programming to play computer bridge
Using F# and genetic programming to play computer bridge
Let the machines
do the thinking
Let the machines
do the thinking
Let the machines
do the thinking
Let the machines
do the thinking
Let the machines
do the thinking
Not all rules
are correct!
Not all rules
are correct!
J
Not all rules
are correct!
J
L
Not all rules
are correct!
J
L
J
Not all rules
are useful!
J
L
J
Not all rules
are useful!
J
L
L
Remove
useless rules
Remove
useless rules
Remove
useless rules
So little
effort!
Using
the rules
Using
the rules
Using
the rules
Using
the rules
Using
the rules
Bit more
exciting!
Bit more
exciting!
Bit more
exciting!
Bit more
exciting!
Bit more
exciting!
Bit more
exciting!
Bit more
exciting!
Bit more
exciting!
Using
the rules
Using
the rules
Bit more
exciting!
Bit more
exciting!
Bit more
exciting!
Look mommy,
no thinking!
Look mommy,
no thinking!
Omar Sharif bridge by Nationaal Archief (Ron Kroon) CC-BY-SA-3.0
Next step:
Mutate this!
Women playing bridge in Tallahassee by Florida Memory Project Public Domain
Women playing bridge in Tallahassee by Florida Memory Project Public Domain
Women playing bridge in Tallahassee by Florida Memory Project Public Domain
Women playing bridge in Tallahassee by Florida Memory Project Public Domain
Women playing bridge in Tallahassee by Florida Memory Project Public Domain
Women playing bridge in Tallahassee by Florida Memory Project Public Domain
Computer Bridge with F#:
DSLs and Genetic Programming
@felienne
Women playing bridge in Tallahassee by Florida Memory Project Public Domain
Using F# and genetic programming to play computer bridge
Using F# and genetic programming to play computer bridge
h7p://stackoverflow.com/quesAons/2733415/
fsharp-core-sigdata-not-found-alongside-
fsharp-core

More Related Content

PDF
Fichas lectoescritura boo
PDF
Functional Programming in Excel
PDF
How does code sound?
PDF
Programming is logical reasoning?
PPTX
Small, simple and smelly: What we can learn from examining end-user artifacts?
PPTX
Do Code Smell Hamper Novice Programmers?
PPTX
Programming by Calculation
PPTX
A board game night with geeks: attacking Quarto ties with SAT solvers
Fichas lectoescritura boo
Functional Programming in Excel
How does code sound?
Programming is logical reasoning?
Small, simple and smelly: What we can learn from examining end-user artifacts?
Do Code Smell Hamper Novice Programmers?
Programming by Calculation
A board game night with geeks: attacking Quarto ties with SAT solvers

More from Felienne Hermans (12)

PPTX
Spreadsheets for developers
PPTX
Spreadsheets are code
PPTX
Presenting: structure story and support
PPTX
Improving Spreadsheet Test Practices
PPTX
Putting the science in computer science
PPTX
Spreadsheets are graphs too: Using Neo4J as backend to store spreadsheet info...
PPTX
Social media for the busy scientist
PDF
An overview of my PhD research
PDF
Detecting and Visualizing Inter-worksheet Smells in Spreadsheets
PDF
Spreadsheet Testing
PPTX
TEDxDelft
PPTX
The power of symmetry
Spreadsheets for developers
Spreadsheets are code
Presenting: structure story and support
Improving Spreadsheet Test Practices
Putting the science in computer science
Spreadsheets are graphs too: Using Neo4J as backend to store spreadsheet info...
Social media for the busy scientist
An overview of my PhD research
Detecting and Visualizing Inter-worksheet Smells in Spreadsheets
Spreadsheet Testing
TEDxDelft
The power of symmetry
Ad

Recently uploaded (20)

PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Encapsulation theory and applications.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPT
Teaching material agriculture food technology
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
cuic standard and advanced reporting.pdf
PPTX
A Presentation on Artificial Intelligence
PPTX
Machine Learning_overview_presentation.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Machine learning based COVID-19 study performance prediction
Network Security Unit 5.pdf for BCA BBA.
The Rise and Fall of 3GPP – Time for a Sabbatical?
Encapsulation theory and applications.pdf
Review of recent advances in non-invasive hemoglobin estimation
Teaching material agriculture food technology
Digital-Transformation-Roadmap-for-Companies.pptx
Big Data Technologies - Introduction.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
The AUB Centre for AI in Media Proposal.docx
MYSQL Presentation for SQL database connectivity
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
MIND Revenue Release Quarter 2 2025 Press Release
cuic standard and advanced reporting.pdf
A Presentation on Artificial Intelligence
Machine Learning_overview_presentation.pptx
Encapsulation_ Review paper, used for researhc scholars
Unlocking AI with Model Context Protocol (MCP)
Machine learning based COVID-19 study performance prediction
Ad

Using F# and genetic programming to play computer bridge