Develop Reversi, a Windows Store game in C# and XAML

11 out of 16 rated this helpful - Rate this topic

The Reversi board game app is an end-to-end sample that shows some common features of Windows Store apps in a real-world setting. It also shows the use of XAML and C# features to create a layered app structure (using the Model-View-ViewModel or MVVM pattern) that is helpful as an app becomes more complex. This topic introduces the sample and provides links to additional documentation.

For a short intro to MVVM, see Using the Model-View-ViewModel pattern.

To learn how this sample uses particular features without having to understand the whole sample, see Reversi feature scenarios.

To learn how the overall sample works, see Reversi app structure, which describes the layers of the app and the parts in each layer.

Note  This documentation reflects the current state of the sample at the time of writing. See the following links for the latest code and info about any updates. Also, for Windows Store apps requiring high performance graphics, such as computationally intensive games, consider using DirectX with C++ to provide the best user experience on the widest possible array of devices. For more info, see Creating a DirectX game.

Download the Reversi sample app or browse the source code.

Screen shot of the Reversi sample app

Introducing the Reversi sample

Reversi is one of the most common board games implemented on computers. This is because the rules and artificial intelligence (AI) are relatively easy to implement, and the rules are over a hundred years old and are thus not under copyright. It also represents a programming problem that is not too hard but also not too easy.

The Reversi sample app includes features that let a player:

  • Read the rules of the game.
  • Play against other humans or against an AI at several difficulty levels.
  • Pause the clock when the game isn't active.
  • Show and hide the clock.
  • Show and hide visual indications of the legal moves and the spaces affected by the previous move.
  • Undo and redo moves to explore alternate plays.
  • Play the game on different board sizes.

This set of features provides enough complexity to represent a truly "real world" app, but with enough simplicity to keep the app relatively small for learning purposes.

When an app reaches this level of complexity, making changes and adding new features can cause unexpected problems. The Reversi sample manages increasing complexity by using a structure that separates different kinds of code into different layers. These layers can interact only in very specific ways, which helps reduce accidental side effects that can occur even with seemingly small code changes. The main goal of this structure, in fact, is to make it easy to change code and to add features without causing problems. That way, you can figure out the right code design in an environment where mistakes have less impact and are more easily fixed. For more info, see Using the Model-View-ViewModel pattern.

Resources

To get the full benefit of the Reversi sample and documentation, you should first understand XAML, C#, and the basics of Windows Store app development. The following topics provide some of the necessary background info:

For general info on designing and developing Windows Store apps, see:

Game technologies and app performance

The Reversi sample targets the popular Games category in the Windows Store and provides some reusable code and ideas for others to build on. It implements a familiar, casual board game in order to focus on the basics of real-world, end-to-end app development.

Real-time, arcade-style games often require more advanced techniques than turn-based board games to achieve good performance. Performance is important for every app, and in general you should understand your performance requirements early to make the right technology choices. You should also confirm your choices by testing your app during development on a variety of devices.

Both XAML and JavaScript are appropriate for many types of casual games, including puzzle and board-game apps. Puzzles and board games are good first "real" apps for those who are new to coding or to the platform, and who are moving beyond the "getting started" level.

If you plan to create a performance-intensive game (such as a graphics-heavy, arcade-style game), consider using Microsoft DirectX, which is considerably more complex and powerful than XAML or JavaScript. For more info, see Creating a DirectX game and DirectX and XAML interop. You can also improve performance in XAML and JavaScript apps by implementing specific modules in C++ or by using third-party, performance-optimized libraries. For more info, see Creating Windows Runtime Components and Using a Windows Runtime Component in Reversi feature scenarios. To improve the performance of your XAML-based code, see Performance best practices for Windows Store apps using C++, C#, and Visual Basic.

Related topics

Developing games
Reversi sample app
Using the Model-View-ViewModel pattern
Reversi feature scenarios
Reversi app structure
Designing great games for Windows
Create your first Windows Store app using C# or Visual Basic
Roadmap for Windows Store apps using C# or Visual Basic
Data binding

 

 

Build date: 3/22/2013

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.