NBattleship Coding Contest
Learning by example
Rainer Stropek | @rstropek | time cockpit

Workshop Rules
- Make it interactive
- Make it practically relevant
- Ask questions relevant to your projects
- Follow along if you are an experienced C# dev
Use Case
- Build a runtime for classical Battleship game
- Practical relevance: Extensible runtime for business software
- Example: ERP, machine configuration, CAD
- Other developers contribute computer players through well-defined API
- Practical relevance: Plugins developed by a distributed team of devs
- Players must run in an isolated sandbox (e.g. process, container)
- Practical relevance: Semi-trusted plugins, protection from crashes
- Easy to use CLI for controlling processes
- Well suited for Docker
- Later: Web-based UI (HTTP, Websockets) for controlling the games
- Practical relevance: Web UI for business software
Technical Requirements
-
Latest version of .NET
- .NET 5 Preview
- Make shipping and installing simple
- Single executable for entire backend
- Solid unit test coverage
- Cross-platform
-
High performance for communicating with players
- Avoid run-time reflection in custom code
- Fast communication protocol to players
Out of Scope
-
UI
- CLI
- HTTP-based web API
-
Complex tournament logic
- For today, enough if two players can play against each other
-
Harden software against player crashes
- Architecture has to make that possible in the future
Manager
Battle Host
Architecture
Manager
Battle Host
Player
Player
Architecture
Manager
Battle Host
Player
Player
Separate process
or container
Architecture
Manager
Battle Host
Player
Player
gRPC duplex streaming
Separate process
or container
Architecture
Manager
Battle Host
Player
Player
gRPC duplex streaming
Separate process
or container
UI
HTTP
Architecture
Manager
Battle Host
Player
Player
gRPC duplex streaming
Separate process
or container
UI
HTTP
SignalR
Architecture
Communication Protocol
Manager
Battle Host
Player
Request Shot
Shoot
Shot
Shot
Shot Result
Shot Result
Learning Goals
- Work with .NET 5
- Web APIs (HTTP, gRPC)
- Class libraries
- Unit tests
- Generic host
- Use new C# features
- C# 8 and most importantly 9
- See also C# 9 presentation
- Interop between .NET Standard libs and .NET 5
- Learn about Roslyn's C# Code Generator
Prerequisites to Follow Along
- Latest Visual Studio 2019 Preview
- 16.8.0 Preview 3.0
- Latest .NET 5 Preview
- .NET Runtime 5.0.0-rc.1.20451.14
- ASP.NET Core Runtime 5.0.0-rc.1.20451.14
- Part of SDK 5.0.100-rc.1
- Clone GitHub Repo
Have Fun, Learn a Lot!
Battleship Workshop
By Rainer Stropek
Battleship Workshop
- 823