playSudoku              package:sudoku              R Documentation

_I_n_t_e_r_a_c_t_i_v_e_l_y _p_l_a_y _a _g_a_m_e _o_f _S_u_d_o_k_u

_D_e_s_c_r_i_p_t_i_o_n:

     Interactively play a game of 9x9 Sudoku with hints and undo

_U_s_a_g_e:

       playSudoku(z=NULL, hist.len=100, solve=TRUE,
                   display=c("guess","windows","tk"),
                   hscale=1.25, vscale=1.25, ...)

_A_r_g_u_m_e_n_t_s:

       z: Either a 9x9 numeric matrix representing the Sudoku grid
          (with '0' representing a blank cell), or 0 (zero) for an
          empty matrix, or a filename (passed to 'readSudoku'), or NULL
          to generate a puzzle randomly.

hist.len: Integer representing the number of history steps to remember
          (number of undo's possible).

   solve: Logical indicating if the solution should be computed (used
          for checking current answer or cheating).

 display: Type of display.  The default 'guess' uses a windows graphics
          device if getOption('device')=='windows', otherwise it uses
          tk (requiring the 'tkrplot' package).

  hscale: Passed to tkrplot

  vscale: Passed to tkrplot

     ...: Arguments passed to 'generateSudoku'

_D_e_t_a_i_l_s:

     To play, move the mouse arrow over an empty cell and press the
     number key to enter the number in the cell.  Typing '?' brings up
     a menu of additional commands:


         ?     -- a short help message
         1-9   -- insert digit
         0,' ' -- clear cell
         r     -- replot the puzzle
         q     -- quit
         h     -- hint/help
         c     -- correct wrong entries (show in red)
         u     -- undo last entry
         s     -- show number in cell
         a     -- show all (solve the puzzle)


_V_a_l_u_e:

     An invisible matrix with the solution or current state of the
     puzzle. Save this if you stop part way through, and use it as the
     input for the function to start again where you left off (undo
     info is lost so make sure that everything is correct).

_N_o_t_e:

     display='windows' makes use of the 'getGraphicsEvent' function,
     which currently only works on Windows.

_A_u_t_h_o_r(_s):

     Greg Snow greg.snow@intermountainmail.org and David E. Brahm
     <brahm@alum.mit.edu>

_S_e_e _A_l_s_o:

     'solveSudoku'

_E_x_a_m_p_l_e_s:

     ## Not run: 
     puz1 <- playSudoku(0)        # Use as an editor to create a puzzle, then quit
     sol1 <- playSudoku(puz1)     # now play the puzzle

     puz2 <- edit(matrix(0,9,9))  # Or use this editor
     sol2 <- playSudoku(puz2)     # now play the puzzle

     playSudoku()                 # Play a randomly generated game

     playSudoku(fetchSudokuUK())  # Play today's game
     ## End(Not run)

