Click here to load reader
Upload
dmitri-nesteruk
View
190
Download
2
Embed Size (px)
DESCRIPTION
Slides from my MC talk at the C++ User Group, St.Petersburg, Russia, June 2014
Citation preview
Hi!
• My name is Dmitri
• Quant finance
• Developer Evangelist @ JetBrains (2010-…)
• Visiting Researcher @ University of Southampton (2002-…)
• MVP Visual C# (2009-…)
Calculation of 𝜋𝜋
• Generate lots of points in square
• Area of circle𝜋𝜋𝑟𝑟2
• Area of square4𝑟𝑟2
• ∴ 𝜋𝜋 = 4 𝑆𝑆𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑆𝑆𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑐𝑐𝑐𝑐
• Area ~ number of points
r
�𝑒𝑒𝑥𝑥2
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
2
4
6
8
10
12
14
16
18
Poker (is largely bots )
AH 7S
? ?
AS KH TC
try every single combination6C
6D win
win
loss
loss
loss
AH 7S40% to win
Challenging (&geeky) games for heavy MC
HearthStone
• ~400 different cards
• Player pick a deck of 30
• Each card has stationary and transient behaviors• May affect 0, 1 or several other cards
Rules
• Stored in an XML file
• Parsed via boost::regex
• Result in creation of std::function objects
Everything affects everything
• This card gives bonus to other card
• When card enters play, …
• When card leaves play, …
• This interaction method does not map well to OOP
Properties
• Properties are built-in in C#, not available in C++ or Java
• __declspec(property) compiler extension• Supported on at least Intel and MSVC compilers
• A person structure keeps the person’s age• Age (read/write)
• Only people older than 16 can vote• CanVote (readonly)• This is a derivative property (at runtime you need an std::function)
Change notifications
• We want to be informed when properties change
• Use boost::signals
• Let’s borrow .NET ideology!
Event Bus
• Global communication pipeline
• Entity signs up when enters game, disconnects on exit
• Also uses signal/slot paradigm
Realtime Analysis
• The game uses Unity
• Decompiled .NET libs
• Reverse-engineer Protocol Buffer definitions
• …
• PROFIT!!!
Packet Capture
• Winpcap
• Capture game state
• Reanalyze at each significant change
Architecture
• Intel C++
• >10k Xeon cores
• 24x Intel Xeon Phi
That’s it!
• Monte-Carlo Methods in Financial Engineering, Paul Glasserman, Springer
• Boosthttp://boost.org
• Course on Boost at http://pluralsight.com
• Send feedback to:@[email protected]