Archive for March 29, 2010

Version 1 of Sudoku App for the Microsoft Surface is Working!!!

This past two weeks I have been writing the necessary computer programs implementing Sudoku solving algorithms (constraint, human logic, depth-first search*). Depth-first search should be completed by tomorrow hopefully and then the timing data starts.

Decided to finally start on the Sudoku Surface App, and finally was able to implement a 9×9 grid structure.

To implement this, enter the xaml code and type a few lines:
<Grid Name=”Sudoku” Height=”450″ Width=”450″  ShowGridLines=”True”>
<Grid.RowDefinitions>
<RowDefinition Name=”row1″ Height=”50″ />
<RowDefinition Name=”row2″ Height=”50″ />
<RowDefinition Name=”row3″ Height=”50″ />
<RowDefinition Name=”row4″ Height=”50″ />
<RowDefinition Name=”row5″ Height=”50″ />
<RowDefinition Name=”row6″ Height=”50″ />
<RowDefinition Name=”row7″ Height=”50″ />
<RowDefinition Name=”row8″ Height=”50″ />
<RowDefinition Name=”row9″ Height=”50″ />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Name=”col1″ Width=”50″ />
<ColumnDefinition Name=”col2″ Width=”50″ />
<ColumnDefinition Name=”col3″ Width=”50″ />
<ColumnDefinition Name=”col4″ Width=”50″ />
<ColumnDefinition Name=”col5″ Width=”50″ />
<ColumnDefinition Name=”col6″ Width=”50″ />
<ColumnDefinition Name=”col7″ Width=”50″ />
<ColumnDefinition Name=”col8″ Width=”50″ />
<ColumnDefinition Name=”col9″ Width=”50″ />
</Grid.ColumnDefinitions>
</Grid>

Splash Page

Splash Page

I also included a new feature on the recently released update of the Surface SP1. However, it does not work on the school’s surface unit since we will need to order a usb drive from Microsoft to get the upgrade (lame).

However, this new control called the ElementMenu is pretty cool. To implement this, I included some xaml code to get started.

<s:ElementMenu
Name=”MainMenu”
ActivationMode=”HostInteraction”
ActivationHost=”{Binding ElementName=TouchLabel}”>

<s:ElementMenuItem Header=”Open Game”/>
<s:ElementMenuItem Header=”Save Game”/>
<s:ElementMenuItem Header=”New Game”>
<!– Sub menu items –>
<s:ElementMenuItem Header=”Easy”
Click=”ElementMenuItem_Click”
ContactTapGesture=”ElementMenuItemEasy_ContactTapGesture”/>
<s:ElementMenuItem Header=”Medium”/>
<s:ElementMenuItem Header=”Hard”/>
</s:ElementMenuItem>
</s:ElementMenu>

ElementMenu Control

ElementMenu Control

Since the ElementMenu does not work on the surface unit, I might need to trash this idea and go with the Menu Control, which is not nearly as cool as the ElementMenu control.

From the ElementMenu control, the user can choose New Game >> ‘Diff” and a new game of the difficulty will appear.

Visual of a Sudoku Puzzle

Visual of an Easy Sudoku Puzzle

Later on the right hand side will display the techniques used to solve the puzzle. If the user is unable to solve the game or quits, the user can select the Solve It button and the solution to the grid will appear.

Solution to Easy Sudoku Puzzle

Solution to Easy Sudoku Puzzle

The current status of the Sudoku Game for the Surface is this:

  • Able to read from file to populate a Sudoku grid
  • Solve easy puzzles using constraint propagation techniques
  • ElementMenu allows to create a new puzzle by selected difficulty level
  • Also included is a save and open menu, which I will write the functionality for later

What needs to be done:

  • Write functionality for save/open menu
  • Write human logic solver (lone rangers, twins, triplets)
  • Write depth first search solver for most difficult puzzles
  • Eventually write a Sudoku Generator (but right now that is a future work)
  • Write text block to see track changes in grid and display what techniques were used to solve a cell
  • Create a few buttons (redo, undo, clear)