Back to index

gcompris  8.2.2
Public Member Functions | Public Attributes
sudoku.Gcompris_sudoku Class Reference

List of all members.

Public Member Functions

def __init__
def start
def end
def ok
def repeat
def config
def key_press
def pause
def set_level
def next_level
def increment_level
def set_sudoku_symbol
def hide_symbol_event
def symbol_item_event
def square_item_event
def set_on_error
def unset_on_error
def is_legal
def is_solved
def display_valid_chars
def get_pixmap_symbol
def display_sudoku
def init_item_list

Public Attributes

 gcomprisBoard
 board_paused
 gamewon
 sudo_square
 sudo_number
 sudo_symbol
 valid_chars
 cursqre
 normal_square_color
 highl_square_color
 focus_square_color
 fixed_square_color
 error_square_color
 lines_color
 fixed_number_color
 user_number_color
 root_sudo
 sudoku
 sudo_size
 sudo_region
 timer
 symbolize_level_max
 symbols
 rootitem

Detailed Description

Sudoku game

Definition at line 30 of file sudoku.py.


Constructor & Destructor Documentation

def sudoku.Gcompris_sudoku.__init__ (   self,
  gcomprisBoard 
)

Definition at line 34 of file sudoku.py.

00034 
00035   def __init__(self, gcomprisBoard):
00036     self.gcomprisBoard = gcomprisBoard
00037 
00038     self.gcomprisBoard.disable_im_context = True
00039 
00040     # These are used to let us restart only after the bonus is displayed.
00041     # When the bonus is displayed, it call us first with pause(1) and then with pause(0)
00042     self.board_paused  = 0;
00043     self.gamewon       = 0;
00044 
00045     # It holds the canvas items for each square
00046     self.sudo_square = []       # The square Rect Item
00047     self.sudo_number = []       # The square Text Item
00048     self.sudo_symbol = []       # The square Symbol Item
00049 
00050     self.valid_chars = []       # The valid chars for the sudoku are calculated from the dataset
00051 
00052     # Holds the coordinate of the current square
00053     self.cursqre = None
00054 
00055     self.normal_square_color = 0xbebbc9ffL
00056     self.highl_square_color  = 0x8b83a7ffL
00057     self.focus_square_color  = 0x555555ffL
00058     self.fixed_square_color  = 0x8bAAa7ffL
00059     self.error_square_color  = 0xff77a7ffL
00060     self.lines_color         = 0xebe745ffL
00061 
00062     # These colors must be different or it won't work
00063     self.fixed_number_color  = 0x000cffffL
00064     self.user_number_color   = 0x000bffffL
00065 
00066     self.root_sudo = None
00067 
00068     self.sudoku = None          # The current sudoku data
00069     self.sudo_size = 0          # the size of the current sudoku
00070     self.sudo_region = None     # the modulo region in the current sudoku
00071 
00072     self.timer = 0              # The timer that highlights errors
00073 
00074     self.symbolize_level_max = 4 # Last level in which we set symbols
00075     self.symbols = [
00076       gcompris.utils.load_pixmap("images/rectangle.png"),
00077       gcompris.utils.load_pixmap("images/circle.png"),
00078       gcompris.utils.load_pixmap("images/rhombus.png"),
00079       gcompris.utils.load_pixmap("images/triangle.png"),
00080       gcompris.utils.load_pixmap("images/star.png")
00081       ]


Member Function Documentation

Definition at line 130 of file sudoku.py.

00130 
00131   def config(self):
00132     print("Gcompris_sudoku config.")
00133 

def sudoku.Gcompris_sudoku.display_sudoku (   self,
  sudoku 
)

Definition at line 545 of file sudoku.py.

00545 
00546   def display_sudoku(self, sudoku):
00547 
00548     # Reinit the sudoku globals
00549     if self.timer:
00550       gtk.timeout_remove(self.timer)
00551 
00552     self.sudo_square = []       # The square Rect Item
00553     self.sudo_number = []       # The square Text Item
00554     self.sudo_symbol = []       # The square Symbol Item
00555 
00556     # The valid chars for the sudoku are calculated from the dataset
00557     self.valid_chars = []
00558 
00559     self.cursqre = None
00560 
00561     self.sudo_size = len(sudoku[0])
00562 
00563     if(self.root_sudo):
00564       self.root_sudo.destroy()
00565 
00566     # Create our rootitem. We put each canvas item in it so at the end we
00567     # only have to kill it. The canvas deletes all the items it contains
00568     # automaticaly.
00569     self.root_sudo = self.rootitem.add(
00570       gnomecanvas.CanvasGroup,
00571       x=0.0,
00572       y=0.0
00573       )
00574 
00575 
00576     # Region is the modulo place to set region (if defined)
00577     region = None
00578     if(self.sudo_region.has_key(self.sudo_size)):
00579       region=self.sudo_region[self.sudo_size]
00580 
00581     square_width = (gcompris.BOARD_HEIGHT-50)/self.sudo_size
00582     square_height = square_width
00583     x_init = (gcompris.BOARD_WIDTH - square_width*self.sudo_size)/2 - 40
00584     y_init = (gcompris.BOARD_HEIGHT - square_height*self.sudo_size)/2
00585 
00586     for x in range(0,self.sudo_size):
00587       line_square = []
00588       line_number = []
00589       line_symbol = []
00590 
00591       for y in range(0,self.sudo_size):
00592 
00593         # Get the data from the dataset
00594         text  = sudoku[y][x]
00595         color = self.fixed_number_color
00596         square_color = self.fixed_square_color
00597         if text == '.':
00598           text  = ""
00599           color = self.user_number_color
00600           square_color = self.normal_square_color
00601         else:
00602           if(not text in self.valid_chars):
00603             self.valid_chars.append(text)
00604 
00605         # The background of the square
00606         item = self.root_sudo.add(
00607           gnomecanvas.CanvasRect,
00608           fill_color_rgba = square_color,
00609           x1= x_init + square_width * x,
00610           y1= y_init + square_height * y,
00611           x2= x_init + square_width * (x+1),
00612           y2= y_init + square_height * (y+1),
00613           width_units=1.0,
00614           outline_color_rgba= 0x144B9DFFL
00615           )
00616         line_square.append(item)
00617         if(self.gcomprisBoard.level>=self.symbolize_level_max):
00618           item.connect("event", self.square_item_event, (x,y))
00619 
00620         # Save it's sudo coord for the drag and drop
00621         item.set_data('sudo_x', str(x))
00622         item.set_data('sudo_y', str(y))
00623 
00624         # For low levels, we symbolize the letters
00625         if(self.gcomprisBoard.level<self.symbolize_level_max):
00626           pixmap = self.get_pixmap_symbol(self.valid_chars, text)
00627           zoom = (square_width*0.8) / pixmap.get_width()
00628           item = self.root_sudo.add(
00629             gnomecanvas.CanvasPixbuf,
00630             pixbuf = pixmap,
00631             x= x_init + square_width * x + square_width/2,
00632             y= y_init + square_height * y + square_height/2,
00633             width= pixmap.get_width() * zoom,
00634             height= pixmap.get_height() * zoom,
00635             width_set=True,
00636             height_set=True,
00637             anchor=gtk.ANCHOR_CENTER
00638             )
00639           line_symbol.append(item)
00640 
00641           # Save it's sudo coord for the drag and drop
00642           item.set_data('sudo_x', str(x))
00643           item.set_data('sudo_y', str(y))
00644 
00645           if(not text):
00646             item.hide()
00647             # This item is clickeable and it must be seen
00648             #item.connect("event", gcompris.utils.item_event_focus)
00649             item.connect("event", self.hide_symbol_event, (x, y))
00650 
00651         #
00652         #
00653         #
00654 
00655         item = self.root_sudo.add(
00656           gnomecanvas.CanvasText,
00657           x= x_init + square_width * x + square_width/2,
00658           y= y_init + square_height * y + square_height/2,
00659           text= text,
00660           fill_color_rgba= color,
00661           font=gcompris.skin.get_font("gcompris/content"),
00662           )
00663         if(self.gcomprisBoard.level<self.symbolize_level_max):
00664           item.hide()
00665 
00666         line_number.append(item)
00667 
00668         if(region):
00669           if(y>0 and y%region==0):
00670             self.root_sudo.add (
00671               gnomecanvas.CanvasLine,
00672               points=(x_init - 5,
00673                       y_init + square_height * y,
00674                       x_init + (square_width * self.sudo_size) + 5,
00675                       y_init + square_height * y),
00676               fill_color_rgba=self.lines_color,
00677               width_units=2.5,
00678               )
00679 
00680       self.sudo_square.append(line_square)
00681       self.sudo_number.append(line_number)
00682       self.sudo_symbol.append(line_symbol)
00683 
00684       if(region):
00685         if(x>0 and x%region==0):
00686           self.root_sudo.add (
00687             gnomecanvas.CanvasLine,
00688             points=(x_init + square_width * x,
00689                     y_init - 5,
00690                     x_init + square_width * x,
00691                     y_init + square_height * self.sudo_size + 5),
00692             fill_color_rgba=self.lines_color,
00693             width_units=2.5,
00694             )
00695 
00696     if(self.gcomprisBoard.level>=self.symbolize_level_max):
00697       self.valid_chars.sort()
00698     self.display_valid_chars(self.sudo_size, self.valid_chars)

Here is the call graph for this function:

Here is the caller graph for this function:

def sudoku.Gcompris_sudoku.display_valid_chars (   self,
  sudo_size,
  valid_chars 
)

Definition at line 477 of file sudoku.py.

00477 
00478   def display_valid_chars(self, sudo_size, valid_chars):
00479 
00480     square_width = (gcompris.BOARD_HEIGHT-50)/sudo_size
00481     square_height = square_width
00482 
00483     x_init = 20
00484     y_init = (gcompris.BOARD_HEIGHT - square_height*sudo_size)/2
00485 
00486     for y in range(0,sudo_size):
00487 
00488       # For low levels, we symbolize the letters
00489       if(self.gcomprisBoard.level<self.symbolize_level_max):
00490         pixmap = self.get_pixmap_symbol(valid_chars, valid_chars[y])
00491         zoom = (square_width*0.5) / pixmap.get_width()
00492 
00493         cx = int(x_init + (pixmap.get_width() * zoom)/2)
00494         cy = int(y_init + square_height * y + square_height/2)
00495 
00496         item = self.root_sudo.add(
00497           gnomecanvas.CanvasPixbuf,
00498           pixbuf = pixmap,
00499           x= cx,
00500           y= cy,
00501           width= pixmap.get_width() * zoom,
00502           height= pixmap.get_height() * zoom,
00503           width_set=True,
00504           height_set=True,
00505           anchor=gtk.ANCHOR_CENTER
00506           )
00507         item.connect("event", self.symbol_item_event, valid_chars[y])
00508         # This item is clickeable and it must be seen
00509         item.connect("event", gcompris.utils.item_event_focus)
00510 
00511         # Save it's coordinate origines for the drag and drop
00512         item.set_data('orig_x', str(cx))
00513         item.set_data('orig_y', str(cy))
00514 
00515       else:
00516         # Shadow
00517         self.root_sudo.add(
00518           gnomecanvas.CanvasText,
00519           x= x_init+1.5,
00520           y= y_init + square_height * y + square_height/2 + 1.5,
00521           text= valid_chars[y],
00522           font=gcompris.skin.get_font("gcompris/title"),
00523           fill_color="black"
00524           )
00525         # Text
00526         self.root_sudo.add(
00527           gnomecanvas.CanvasText,
00528           x= x_init,
00529           y= y_init + square_height * y + square_height/2,
00530           text= valid_chars[y],
00531           font=gcompris.skin.get_font("gcompris/title"),
00532           fill_color="white"
00533           )

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 116 of file sudoku.py.

00116 
00117   def end(self):
00118 
00119     # Remove the root item removes all the others inside it
00120     self.rootitem.destroy()
00121     self.rootitem = None
00122     gcompris.score.end()

def sudoku.Gcompris_sudoku.get_pixmap_symbol (   self,
  valid_chars,
  text 
)

Definition at line 535 of file sudoku.py.

00535 
00536   def get_pixmap_symbol(self, valid_chars, text):
00537     if (not text in valid_chars):
00538       # Return our first item. It will be hidden anyway.
00539       return self.symbols[0]
00540 
00541     return self.symbols[valid_chars.index(text)]

Here is the caller graph for this function:

def sudoku.Gcompris_sudoku.hide_symbol_event (   self,
  item,
  event,
  data 
)

Definition at line 257 of file sudoku.py.

00257 
00258   def hide_symbol_event(self, item, event, data):
00259 
00260     if(self.gamewon):
00261       return False
00262 
00263     if event.type == gtk.gdk.BUTTON_PRESS:
00264       item.hide()
00265       self.sudo_number[data[0]][data[1]].set(
00266         text = ""
00267         )

Here is the caller graph for this function:

Definition at line 221 of file sudoku.py.

00221 
00222   def increment_level(self):
00223     self.gcomprisBoard.sublevel += 1
00224 
00225     if(self.gcomprisBoard.sublevel > len(self.sudoku[self.gcomprisBoard.level-1])):
00226       # Try the next level
00227       self.gcomprisBoard.sublevel=1
00228       self.gcomprisBoard.level += 1
00229       # Set the level in the control bar
00230       gcompris.bar_set_level(self.gcomprisBoard);
00231 
00232       if(self.gcomprisBoard.level>self.gcomprisBoard.maxlevel):
00233         # the last board is finished : bail out
00234         gcompris.bonus.board_finished(gcompris.bonus.FINISHED_RANDOM)
00235         return False
00236 
00237     return True

Here is the caller graph for this function:

Definition at line 700 of file sudoku.py.

00700 
00701   def init_item_list(self):
00702 
00703     # It's hard coded that sudoku of size x have y region.
00704     # If not defined there, it means no region
00705     #
00706     # Sudoku size : Number of region
00707     #
00708     self.sudo_region = {
00709       9: 3,
00710       4: 2
00711       }
00712 
00713     # It's a list of level which is a list of sudoku data
00714     sudoku_list = \
00715       [
00716        [ # Level 1
00717         [
00718          ['A','C','.'],
00719          ['.','B','A'],
00720          ['B','.','.']
00721         ],
00722         [
00723          ['C','A','.'],
00724          ['.','.','C'],
00725          ['B','.','.']
00726         ],
00727         [
00728          ['A','B','.'],
00729          ['C','.','B'],
00730          ['B','.','A']
00731         ],
00732         [
00733          ['.','B','.'],
00734          ['.','C','.'],
00735          ['.','A','.']
00736         ],
00737        ],
00738        [ # Level 2
00739         [
00740          ['C','.','.','D'],
00741          ['.','.','B','.'],
00742          ['A','.','.','.'],
00743          ['.','.','D','.']
00744         ],
00745         [
00746          ['.','B','.','A'],
00747          ['.','.','B','.'],
00748          ['C','.','D','.'],
00749          ['.','.','.','C']
00750         ],
00751         [
00752          ['A','.','B','.'],
00753          ['.','C','.','A'],
00754          ['.','.','.','D'],
00755          ['D','.','C','.']
00756         ],
00757         [
00758          ['.','A','.','.'],
00759          ['C','.','A','B'],
00760          ['.','.','C','.'],
00761          ['D','.','.','A']
00762         ],
00763         [
00764          ['C','.','.','D'],
00765          ['B','.','A','.'],
00766          ['.','B','.','A'],
00767          ['.','.','.','.']
00768         ],
00769         [
00770          ['.','A','C','.'],
00771          ['.','.','.','D'],
00772          ['C','.','.','A'],
00773          ['.','B','.','.']
00774         ],
00775         [
00776          ['.','C','.','D'],
00777          ['B','.','.','.'],
00778          ['.','.','.','.'],
00779          ['C','A','.','B']
00780         ],
00781         [
00782          ['B','.','.','C'],
00783          ['.','A','.','.'],
00784          ['.','.','D','.'],
00785          ['.','B','.','.']
00786         ],
00787        ],
00788        [ # Level 3
00789         [
00790          ['A','B','C','D','E'],
00791          ['.','A','B','C','D'],
00792          ['.','.','A','B','C'],
00793          ['.','.','.','A','B'],
00794          ['.','.','.','.','A']
00795         ],
00796         [
00797          ['A','B','.','D','.'],
00798          ['.','.','D','E','A'],
00799          ['C','.','.','A','.'],
00800          ['D','E','.','.','C'],
00801          ['.','A','B','.','D']
00802         ],
00803         [
00804          ['.','C','.','A','.'],
00805          ['A','.','B','.','C'],
00806          ['.','B','.','C','.'],
00807          ['D','.','C','.','A'],
00808          ['.','A','E','.','B']
00809         ],
00810         [
00811          ['C','B','.','.','D'],
00812          ['.','.','D','C','.'],
00813          ['D','.','B','.','E'],
00814          ['.','A','.','D','C'],
00815          ['E','.','.','B','.']
00816         ],
00817         [
00818          ['D','.','.','B','E'],
00819          ['.','E','A','.','.'],
00820          ['A','C','.','.','B'],
00821          ['.','.','B','C','.'],
00822          ['C','B','.','A','.']
00823         ],
00824         [
00825          ['.','.','C','D','.'],
00826          ['B','.','.','.','C'],
00827          ['.','C','.','B','D'],
00828          ['C','.','D','A','.'],
00829          ['D','E','.','.','A']
00830         ],
00831        ],
00832        [ # Level 4
00833         [
00834          ['1','2','3','4','5'],
00835          ['.','1','2','3','4'],
00836          ['.','.','1','2','3'],
00837          ['.','.','.','1','2'],
00838          ['.','.','.','.','1']
00839         ],
00840         [
00841          ['1','2','.','4','.'],
00842          ['.','.','4','5','1'],
00843          ['3','.','.','1','.'],
00844          ['4','5','.','.','3'],
00845          ['.','1','2','.','4']
00846         ],
00847         [
00848          ['.','3','.','1','.'],
00849          ['1','.','2','.','3'],
00850          ['.','2','.','3','.'],
00851          ['4','.','3','.','1'],
00852          ['.','1','5','.','2']
00853         ],
00854         [
00855          ['3','2','.','.','4'],
00856          ['.','.','4','3','.'],
00857          ['4','.','2','.','5'],
00858          ['.','1','.','4','3'],
00859          ['5','.','.','2','.']
00860         ],
00861         [
00862          ['4','.','.','2','5'],
00863          ['.','5','1','.','.'],
00864          ['1','3','.','.','2'],
00865          ['.','.','2','3','.'],
00866          ['3','2','.','1','.']
00867         ],
00868         [
00869          ['.','.','3','4','.'],
00870          ['2','.','.','.','3'],
00871          ['.','3','.','2','4'],
00872          ['3','.','4','1','.'],
00873          ['4','5','.','.','1']
00874         ],
00875        ],
00876        [ # Level 5
00877         [
00878          ['3','.','.','.','.','5','6','.','2'],
00879          ['.','6','2','7','1','.','.','4','.'],
00880          ['1','.','.','9','.','.','.','5','.'],
00881          ['8','.','.','.','.','.','2','6','.'],
00882          ['.','3','.','.','8','.','.','7','.'],
00883          ['.','9','7','.','.','.','.','.','1'],
00884          ['.','5','.','.','.','.','.','.','6'],
00885          ['.','8','.','.','6','7','4','2','.'],
00886          ['6','.','3','1','.','.','.','.','8']
00887         ],
00888         [
00889          ['9','3','1','.','.','7','.','2','8'],
00890          ['.','.','.','.','3','6','.','.','.'],
00891          ['4','.','6','.','.','2','.','.','.'],
00892          ['6','2','.','.','.','.','9','1','.'],
00893          ['1','.','.','.','2','.','.','.','4'],
00894          ['.','4','8','.','.','.','.','6','5'],
00895          ['.','.','.','9','.','.','3','.','2'],
00896          ['.','.','.','2','7','.','.','.','.'],
00897          ['3','7','.','4','.','.','5','9','1']
00898         ],
00899         [
00900          ['.','.','9','.','6','.','.','.','.'],
00901          ['2','.','6','4','.','.','1','.','.'],
00902          ['.','.','3','1','8','.','5','.','.'],
00903          ['.','.','2','.','.','.','.','.','1'],
00904          ['7','9','.','.','.','.','.','6','8'],
00905          ['1','.','.','.','.','.','3','.','.'],
00906          ['.','.','7','.','9','2','8','.','.'],
00907          ['.','.','1','.','.','8','6','.','5'],
00908          ['.','.','.','.','3','.','4','.','.']
00909          ],
00910         [
00911          ['.','7','6','.','.','5','.','.','8'],
00912          ['.','8','.','.','.','.','.','5','.'],
00913          ['.','.','2','.','6','1','4','3','.'],
00914          ['8','.','.','.','1','.','.','.','.'],
00915          ['.','.','.','6','.','3','.','.','.'],
00916          ['.','.','.','.','7','.','.','.','1'],
00917          ['.','9','5','4','8','.','3','.','.'],
00918          ['.','2','.','.','.','.','.','8','.'],
00919          ['7','.','.','9','.','.','1','6','.']
00920         ],
00921         [
00922          ['.','7','6','3','.','.','9','.','.'],
00923          ['3','8','.','7','4','.','.','5','.'],
00924          ['9','.','2','.','.','.','.','.','.'],
00925          ['.','.','9','.','.','.','.','.','.'],
00926          ['.','1','.','6','.','3','.','4','.'],
00927          ['.','.','.','.','.','.','6','.','.'],
00928          ['.','.','.','.','.','.','3','.','2'],
00929          ['.','2','.','.','3','7','.','8','9'],
00930          ['.','.','8','.','.','2','1','6','.']
00931         ],
00932         [
00933          ['.','7','6','.','.','5','.','1','.'],
00934          ['.','8','.','.','4','.','.','.','6'],
00935          ['9','.','2','.','.','.','4','.','.'],
00936          ['.','.','.','5','.','.','.','2','.'],
00937          ['.','1','7','.','.','.','8','4','.'],
00938          ['.','4','.','.','.','8','.','.','.'],
00939          ['.','.','5','.','.','.','3','.','2'],
00940          ['6','.','.','.','3','.','.','8','.'],
00941          ['.','3','.','9','.','.','1','6','.']
00942         ],
00943         [
00944          ['.','7','.','.','2','5','.','1','8'],
00945          ['3','.','.','.','.','9','2','.','.'],
00946          ['.','.','.','.','6','.','4','3','.'],
00947          ['.','.','.','.','.','4','7','2','.'],
00948          ['.','.','.','.','.','.','.','.','.'],
00949          ['.','4','3','2','.','.','.','.','.'],
00950          ['.','9','5','.','8','.','.','.','.'],
00951          ['.','.','4','1','.','.','.','.','9'],
00952          ['7','3','.','9','5','.','.','6','.']
00953         ],
00954         [
00955          ['.','.','.','3','.','5','9','.','.'],
00956          ['3','8','.','.','.','.','2','.','6'],
00957          ['9','5','.','.','6','.','.','.','.'],
00958          ['.','.','9','.','1','4','.','.','3'],
00959          ['.','.','.','.','.','.','.','.','.'],
00960          ['5','.','.','2','7','.','6','.','.'],
00961          ['.','.','.','.','8','.','.','7','2'],
00962          ['6','.','4','.','.','.','.','8','9'],
00963          ['.','.','8','9','.','2','.','.','.']
00964         ],
00965         [
00966          ['.','.','6','.','2','5','.','.','8'],
00967          ['.','8','.','.','.','9','.','.','6'],
00968          ['9','.','.','.','.','.','4','.','.'],
00969          ['.','6','.','.','1','.','.','2','3'],
00970          ['.','.','.','6','.','3','.','.','.'],
00971          ['5','4','.','.','7','.','.','9','.'],
00972          ['.','.','5','.','.','.','.','.','2'],
00973          ['6','.','.','1','.','.','.','8','.'],
00974          ['7','.','.','9','5','.','1','.','.']
00975         ],
00976         [
00977          ['.','.','6','.','.','5','9','1','8'],
00978          ['.','.','.','7','4','.','.','5','.'],
00979          ['9','.','.','.','6','.','.','3','.'],
00980          ['.','.','.','5','.','.','7','.','.'],
00981          ['2','.','.','.','.','.','.','.','5'],
00982          ['.','.','3','.','.','8','.','.','.'],
00983          ['.','9','.','.','8','.','.','.','2'],
00984          ['.','2','.','.','3','7','.','.','.'],
00985          ['7','3','8','9','.','.','1','.','.']
00986         ],
00987         [
00988          ['.','.','.','5','.','4','.','.','.'],
00989          ['2','3','4','8','.','.','.','1','.'],
00990          ['.','.','.','.','1','3','8','.','2'],
00991          ['.','5','.','4','7','2','.','.','1'],
00992          ['.','7','.','.','.','.','.','6','.'],
00993          ['4','.','.','6','9','5','.','2','.'],
00994          ['7','.','1','3','5','.','.','.','.'],
00995          ['.','9','.','.','.','1','4','5','7'],
00996          ['.','.','.','7','.','9','.','.','.']
00997         ],
00998         [
00999          ['.','.','.','.','.','.','6','.','.'],
01000          ['2','.','.','8','6','.','9','.','5'],
01001          ['5','.','7','.','1','3','8','.','2'],
01002          ['6','.','8','.','7','.','.','.','1'],
01003          ['.','7','.','.','3','.','.','6','.'],
01004          ['4','.','.','.','9','.','7','.','8'],
01005          ['7','.','1','3','5','.','2','.','9'],
01006          ['3','.','6','.','8','1','.','.','7'],
01007          ['.','.','5','.','.','.','.','.','.']
01008         ],
01009         [
01010          ['.','8','9','5','.','4','.','7','3'],
01011          ['2','.','.','.','6','7','.','.','5'],
01012          ['.','.','.','9','.','.','.','4','2'],
01013          ['6','5','.','.','.','.','.','.','.'],
01014          ['.','7','2','1','3','8','5','6','.'],
01015          ['.','.','.','.','.','.','.','2','8'],
01016          ['7','4','.','.','.','6','.','.','.'],
01017          ['3','.','.','2','8','.','.','.','7'],
01018          ['8','2','.','7','.','9','1','3','.']
01019         ],
01020         [
01021          ['.','8','9','.','2','4','.','.','3'],
01022          ['.','.','.','.','.','.','.','1','.'],
01023          ['5','.','.','.','1','3','8','.','2'],
01024          ['6','.','.','4','.','2','.','.','.'],
01025          ['.','7','2','1','.','8','5','6','.'],
01026          ['.','.','.','6','.','5','.','.','8'],
01027          ['7','.','1','3','5','.','.','.','9'],
01028          ['.','9','.','.','.','.','.','.','.'],
01029          ['8','.','.','7','4','.','1','3','.']
01030         ],
01031         [
01032          ['.','.','.','.','.','.','.','9','8'],
01033          ['.','.','.','.','.','4','1','.','.'],
01034          ['8','4','3','6','.','.','2','.','.'],
01035          ['9','.','5','.','.','3','.','.','.'],
01036          ['3','2','.','.','.','.','.','8','7'],
01037          ['.','.','.','9','.','.','3','.','1'],
01038          ['.','.','2','.','.','5','7','3','6'],
01039          ['.','.','7','1','.','.','.','.','.'],
01040          ['5','9','.','.','.','.','.','.','.']
01041         ],
01042         [
01043          ['2','.','.','3','5','7','.','.','.'],
01044          ['7','.','9','2','.','.','.','6','.'],
01045          ['.','.','.','.','.','.','.','.','.'],
01046          ['9','.','.','.','.','.','.','2','4'],
01047          ['.','.','6','5','4','1','9','.','.'],
01048          ['4','7','.','.','.','.','.','.','1'],
01049          ['.','.','.','.','.','.','.','.','.'],
01050          ['.','3','.','.','.','8','5','.','9'],
01051          ['.','.','.','7','3','6','.','.','2']
01052         ],
01053         [
01054          ['.','.','1','.','5','7','4','.','.'],
01055          ['.','.','9','2','.','.','.','.','.'],
01056          ['8','4','.','6','.','.','.','7','.'],
01057          ['.','.','5','.','.','3','.','2','.'],
01058          ['3','.','.','.','.','.','.','.','7'],
01059          ['.','7','.','9','.','.','3','.','.'],
01060          ['.','8','.','.','.','5','.','3','6'],
01061          ['.','.','.','.','.','8','5','.','.'],
01062          ['.','.','4','7','3','.','8','.','.']
01063         ],
01064         [
01065          ['2','6','.','3','.','.','.','9','.'],
01066          ['7','.','.','2','.','4','.','6','.'],
01067          ['.','.','.','.','.','9','.','.','.'],
01068          ['9','.','5','.','7','.','6','.','4'],
01069          ['.','.','.','.','.','.','.','.','.'],
01070          ['4','.','8','.','6','.','3','.','1'],
01071          ['.','.','.','4','.','.','.','.','.'],
01072          ['.','3','.','1','.','8','.','.','9'],
01073          ['.','9','.','.','.','6','.','1','2']
01074         ],
01075         [
01076          ['4','9','.','.','.','.','.','1','.'],
01077          ['.','8','.','.','.','2','5','.','.'],
01078          ['1','.','5','.','.','.','6','.','.'],
01079          ['7','.','.','6','4','.','.','.','.'],
01080          ['5','.','.','7','.','3','.','.','8'],
01081          ['.','.','.','.','2','1','.','.','4'],
01082          ['.','.','8','.','.','.','3','.','1'],
01083          ['.','.','1','9','.','.','.','7','.'],
01084          ['.','7','.','.','.','.','.','2','5']
01085         ],
01086         [
01087          ['9','6','.','4','1','7','.','2','3'],
01088          ['.','.','8','.','9','5','6','.','1'],
01089          ['.','.','.','6','.','.','.','.','9'],
01090          ['.','.','.','.','2','.','9','.','.'],
01091          ['4','7','.','.','5','.','.','8','6'],
01092          ['.','.','6','.','4','.','.','.','.'],
01093          ['8','.','.','.','.','3','.','.','.'],
01094          ['6','.','3','1','7','.','5','.','.'],
01095          ['1','9','.','5','8','4','.','6','2']
01096         ],
01097         [
01098          ['.','.','.','4','.','7','8','.','.'],
01099          ['7','3','.','.','.','5','6','.','.'],
01100          ['.','1','4','.','3','.','7','.','.'],
01101          ['5','8','.','.','.','6','.','.','.'],
01102          ['4','.','.','3','.','1','.','.','6'],
01103          ['.','.','.','8','.','.','.','7','5'],
01104          ['.','.','2','.','6','.','4','1','.'],
01105          ['.','.','3','1','.','.','.','9','8'],
01106          ['.','.','7','5','.','4','.','.','.']
01107         ],
01108         [
01109          ['9','.','5','.','.','7','8','2','.'],
01110          ['7','.','.','2','.','.','.','4','.'],
01111          ['.','1','.','6','3','.','.','.','9'],
01112          ['.','.','1','7','2','.','9','.','.'],
01113          ['.','.','.','3','.','1','.','.','.'],
01114          ['.','.','6','.','4','9','1','.','.'],
01115          ['8','.','.','.','6','3','.','1','.'],
01116          ['.','4','.','.','.','2','.','.','8'],
01117          ['.','9','7','5','.','.','3','.','2']
01118         ],
01119         [
01120          ['9','6','.','4','1','7','8','.','3'],
01121          ['.','.','8','2','9','5','.','.','.'],
01122          ['2','.','.','6','3','.','.','.','9'],
01123          ['.','.','.','7','.','.','.','3','4'],
01124          ['4','.','.','.','5','.','.','.','6'],
01125          ['3','2','.','.','.','9','.','.','.'],
01126          ['8','.','.','.','6','3','.','.','7'],
01127          ['.','.','.','1','7','2','5','.','.'],
01128          ['1','.','7','5','8','4','.','6','2']
01129         ],
01130         [
01131          ['.','.','1','.','.','4','7','.','3'],
01132          ['7','.','.','.','6','.','.','5','.'],
01133          ['.','.','2','7','.','8','.','.','6'],
01134          ['.','9','.','.','4','.','.','.','.'],
01135          ['.','.','.','3','.','9','.','.','.'],
01136          ['.','.','.','.','5','.','.','2','.'],
01137          ['6','.','.','9','.','7','4','.','.'],
01138          ['.','7','.','.','8','.','.','.','1'],
01139          ['4','.','8','6','.','.','3','.','.']
01140         ],
01141         [
01142          ['.','.','1','.','.','.','.','9','.'],
01143          ['7','.','.','1','.','3','.','5','.'],
01144          ['.','.','.','.','9','8','1','.','6'],
01145          ['.','9','.','.','4','.','.','.','.'],
01146          ['.','8','4','.','.','.','6','1','.'],
01147          ['.','.','.','.','5','.','.','2','.'],
01148          ['6','.','5','9','3','.','.','.','.'],
01149          ['.','7','.','4','.','2','.','.','1'],
01150          ['.','2','.','.','.','.','3','.','.']
01151         ],
01152         [
01153          ['8','.','.','.','2','4','.','.','.'],
01154          ['7','.','9','1','.','.','.','.','.'],
01155          ['.','5','.','.','9','.','.','4','.'],
01156          ['.','.','6','.','.','.','8','3','.'],
01157          ['2','.','4','.','.','.','6','.','5'],
01158          ['.','3','7','.','.','.','9','.','.'],
01159          ['.','1','.','.','3','.','.','8','.'],
01160          ['.','.','.','.','.','2','5','.','1'],
01161          ['.','.','.','6','1','.','.','.','9']
01162         ],
01163         [
01164          ['.','.','1','.','2','.','.','.','.'],
01165          ['.','.','9','.','6','3','.','.','.'],
01166          ['3','.','.','.','.','8','1','4','.'],
01167          ['.','9','.','.','.','.','8','3','.'],
01168          ['.','.','4','.','7','.','6','.','.'],
01169          ['.','3','7','.','.','.','.','2','.'],
01170          ['.','1','5','9','.','.','.','.','2'],
01171          ['.','.','.','4','8','.','5','.','.'],
01172          ['.','.','.','.','1','.','3','.','.']
01173         ],
01174         [
01175          ['.','6','.','5','.','4','7','.','3'],
01176          ['.','.','9','.','.','.','.','5','.'],
01177          ['3','.','2','.','9','.','.','.','.'],
01178          ['5','.','6','.','.','.','8','.','.'],
01179          ['.','8','.','.','.','.','.','1','.'],
01180          ['.','.','7','.','.','.','9','.','4'],
01181          ['.','.','.','.','3','.','4','.','2'],
01182          ['.','7','.','.','.','.','5','.','.'],
01183          ['4','.','8','6','.','5','.','7','.']
01184         ],
01185         [
01186          ['.','.','.','.','2','.','.','9','.'],
01187          ['.','.','.','.','6','3','.','.','8'],
01188          ['3','.','.','.','.','8','1','4','.'],
01189          ['.','.','.','.','4','.','8','.','7'],
01190          ['.','8','4','.','.','.','6','1','.'],
01191          ['1','.','7','.','5','.','.','.','.'],
01192          ['.','1','5','9','.','.','.','.','2'],
01193          ['9','.','.','4','8','.','.','.','.'],
01194          ['.','2','.','.','1','.','.','.','.']
01195         ],
01196         [
01197          ['8','.','1','.','.','4','.','.','.'],
01198          ['.','.','.','.','6','.','.','5','.'],
01199          ['3','.','2','7','.','.','.','.','6'],
01200          ['.','9','.','.','4','.','.','.','7'],
01201          ['2','.','.','3','.','9','.','.','5'],
01202          ['1','.','.','.','5','.','.','2','.'],
01203          ['6','.','.','.','.','7','4','.','2'],
01204          ['.','7','.','.','8','.','.','.','.'],
01205          ['.','.','.','6','.','.','3','.','9']
01206         ],
01207         [
01208          ['.','.','.','.','2','.','9','4','3'],
01209          ['5','3','.','9','.','.','.','8','.'],
01210          ['.','.','.','.','.','1','6','.','7'],
01211          ['.','.','.','3','.','.','8','.','4'],
01212          ['.','.','.','2','7','9','.','.','.'],
01213          ['9','.','3','.','.','5','.','.','.'],
01214          ['7','.','9','6','.','.','.','.','.'],
01215          ['.','6','.','.','.','4','.','7','5'],
01216          ['1','4','5','.','8','.','.','.','.']
01217         ],
01218         [
01219          ['.','7','1','5','.','.','9','4','.'],
01220          ['5','.','.','9','6','.','.','8','2'],
01221          ['.','9','.','.','.','.','.','.','.'],
01222          ['2','5','.','3','.','.','8','9','.'],
01223          ['.','.','.','2','7','9','.','.','.'],
01224          ['.','1','3','.','.','5','.','2','6'],
01225          ['.','.','.','.','.','.','.','1','.'],
01226          ['3','6','.','.','9','4','.','.','5'],
01227          ['.','4','5','.','.','2','3','6','.']
01228         ],
01229         [
01230          ['6','7','1','5','2','.','.','.','.'],
01231          ['5','.','.','9','6','7','.','.','2'],
01232          ['.','.','.','.','.','.','6','.','.'],
01233          ['.','.','7','3','.','6','8','9','.'],
01234          ['4','.','6','2','.','9','5','.','1'],
01235          ['.','1','3','8','.','5','7','.','.'],
01236          ['.','.','9','.','.','.','.','.','.'],
01237          ['3','.','.','1','9','4','.','.','5'],
01238          ['.','.','.','.','8','2','3','6','9']
01239         ],
01240         [
01241          ['.','7','.','5','2','.','.','4','3'],
01242          ['5','.','.','.','.','7','1','8','2'],
01243          ['.','9','.','.','.','1','6','.','.'],
01244          ['.','5','.','3','1','6','8','9','.'],
01245          ['.','.','.','.','.','.','.','.','.'],
01246          ['.','1','3','8','4','5','.','2','.'],
01247          ['.','.','9','6','.','.','.','1','.'],
01248          ['3','6','8','1','.','.','.','.','5'],
01249          ['1','4','.','.','8','2','.','6','.']
01250         ],
01251         [
01252          ['.','.','.','1','6','.','.','2','7'],
01253          ['.','.','7','.','8','9','.','6','.'],
01254          ['1','.','6','.','5','.','.','8','9'],
01255          ['.','.','.','5','.','.','2','3','8'],
01256          ['.','.','.','8','2','3','.','.','.'],
01257          ['8','2','3','.','.','1','.','.','.'],
01258          ['5','1','.','.','3','.','9','.','2'],
01259          ['.','8','.','7','1','.','4','.','.'],
01260          ['6','7','.','.','9','5','.','.','.']
01261         ],
01262         [
01263          ['.','.','8','1','.','.','.','2','7'],
01264          ['.','.','7','.','8','9','.','.','.'],
01265          ['.','.','6','2','.','.','3','8','.'],
01266          ['7','.','1','5','.','6','.','3','8'],
01267          ['.','.','.','.','.','.','.','.','.'],
01268          ['8','2','.','9','.','1','6','.','5'],
01269          ['.','1','4','.','.','8','9','.','.'],
01270          ['.','.','.','7','1','.','4','.','.'],
01271          ['6','7','.','.','.','5','8','.','.']
01272         ],
01273         [
01274          ['.','3','.','.','.','4','.','2','.'],
01275          ['2','.','.','.','8','9','1','.','4'],
01276          ['1','.','.','2','.','.','3','8','.'],
01277          ['7','.','1','.','.','6','.','.','8'],
01278          ['.','6','.','.','.','.','.','9','.'],
01279          ['8','.','.','9','.','.','6','.','5'],
01280          ['.','1','4','.','.','8','.','.','2'],
01281          ['3','.','9','7','1','.','.','.','6'],
01282          ['.','7','.','4','.','.','.','1','.']
01283         ],
01284         [
01285          ['9','.','8','.','.','.','5','2','.'],
01286          ['.','.','7','3','.','.','.','6','.'],
01287          ['.','4','.','.','.','.','.','8','9'],
01288          ['7','.','.','5','.','6','2','3','.'],
01289          ['.','.','5','.','2','.','7','.','.'],
01290          ['.','2','3','9','.','1','.','.','5'],
01291          ['5','1','.','.','.','.','.','7','.'],
01292          ['.','8','.','.','.','2','4','.','.'],
01293          ['.','7','2','.','.','.','8','.','3']
01294         ],
01295         [
01296          ['8','.','.','2','4','.','.','.','.'],
01297          ['7','.','.','.','1','3','.','8','2'],
01298          ['6','5','.','.','8','9','1','.','4'],
01299          ['.','.','.','.','.','7','2','1','6'],
01300          ['.','1','7','.','3','.','4','5','.'],
01301          ['5','9','6','1','.','.','.','.','.'],
01302          ['3','.','5','8','9','.','.','4','1'],
01303          ['1','7','.','3','6','.','.','.','8'],
01304          ['.','.','.','.','7','1','.','.','5']
01305         ],
01306         [
01307          ['8','.','.','2','.','6','.','.','.'],
01308          ['.','.','9','.','1','3','.','.','2'],
01309          ['6','.','2','7','8','.','.','3','.'],
01310          ['.','.','3','.','.','.','.','1','6'],
01311          ['.','.','7','6','.','8','4','.','.'],
01312          ['5','9','.','.','.','.','8','.','.'],
01313          ['.','6','.','.','9','2','7','.','1'],
01314          ['1','.','.','3','6','.','9','.','.'],
01315          ['.','.','.','4','.','1','.','.','5']
01316         ],
01317         [
01318          ['8','3','.','2','.','.','.','9','.'],
01319          ['.','4','.','.','.','3','.','8','.'],
01320          ['.','.','.','.','8','9','1','.','4'],
01321          ['.','8','.','9','.','.','2','.','.'],
01322          ['2','.','.','6','.','8','.','.','9'],
01323          ['.','.','6','.','.','4','.','7','.'],
01324          ['3','.','5','8','9','.','.','.','.'],
01325          ['.','7','.','3','.','.','.','2','.'],
01326          ['.','2','.','.','.','1','.','6','5']
01327         ],
01328         [
01329          ['.','3','1','2','4','.','.','.','.'],
01330          ['.','.','9','5','1','.','6','8','.'],
01331          ['6','.','.','.','.','.','.','3','.'],
01332          ['.','8','.','9','.','7','2','.','.'],
01333          ['2','.','7','.','.','.','4','.','9'],
01334          ['.','.','6','1','.','4','.','7','.'],
01335          ['.','6','.','.','.','.','.','.','1'],
01336          ['.','7','4','.','6','5','9','.','.'],
01337          ['.','.','.','.','7','1','3','6','.']
01338         ],
01339         [
01340          ['.','.','7','.','.','.','.','5','.'],
01341          ['1','.','4','.','.','3','7','.','6'],
01342          ['.','6','5','7','4','2','9','.','3'],
01343          ['2','.','.','4','.','5','6','3','9'],
01344          ['.','.','.','3','.','7','.','.','.'],
01345          ['4','8','3','9','.','6','.','.','5'],
01346          ['9','.','8','2','5','4','1','6','.'],
01347          ['5','.','2','6','.','.','3','.','8'],
01348          ['.','1','.','.','.','.','5','.','.']
01349         ],
01350         [
01351          ['.','.','7','.','.','.','.','.','2'],
01352          ['.','2','.','.','.','3','.','8','6'],
01353          ['.','6','5','7','4','.','9','.','3'],
01354          ['.','.','.','4','.','.','6','.','.'],
01355          ['.','5','9','.','.','.','8','4','.'],
01356          ['.','.','3','.','.','6','.','.','.'],
01357          ['9','.','8','.','5','4','1','6','.'],
01358          ['5','4','.','6','.','.','.','9','.'],
01359          ['7','.','.','.','.','.','5','.','.']
01360         ],
01361         [
01362          ['.','.','7','1','.','8','4','5','2'],
01363          ['1','.','4','.','.','3','.','.','6'],
01364          ['.','.','5','.','.','2','9','.','3'],
01365          ['.','.','.','.','.','5','.','3','.'],
01366          ['.','.','9','3','.','7','8','.','.'],
01367          ['.','8','.','9','.','.','.','.','.'],
01368          ['9','.','8','2','.','.','1','.','.'],
01369          ['5','.','.','6','.','.','3','.','8'],
01370          ['7','1','6','8','.','9','5','.','.']
01371         ],
01372         [
01373          ['3','.','7','.','.','.','.','5','.'],
01374          ['.','2','.','5','9','.','.','.','.'],
01375          ['8','6','.','.','.','2','.','1','.'],
01376          ['2','.','.','.','8','5','.','.','9'],
01377          ['.','5','.','.','2','.','.','4','.'],
01378          ['4','.','.','9','1','.','.','.','5'],
01379          ['.','3','.','2','.','.','.','6','7'],
01380          ['.','.','.','.','7','1','.','9','.'],
01381          ['.','1','.','.','.','.','5','.','4']
01382         ],
01383         [
01384          ['6','8','.','2','.','7','.','3','.'],
01385          ['.','2','9','.','.','6','8','7','.'],
01386          ['5','.','.','.','8','4','.','.','.'],
01387          ['3','.','5','.','.','.','.','8','.'],
01388          ['.','.','.','7','.','8','.','.','.'],
01389          ['.','7','.','.','.','.','4','.','3'],
01390          ['.','.','.','8','4','.','.','.','7'],
01391          ['.','5','8','1','.','.','9','4','.'],
01392          ['.','6','.','5','.','9','.','1','8']
01393         ],
01394         [
01395          ['6','.','4','2','1','7','.','.','.'],
01396          ['.','2','.','.','.','6','.','.','.'],
01397          ['5','3','7','9','.','.','2','.','1'],
01398          ['3','.','.','.','.','.','7','8','6'],
01399          ['.','4','6','.','.','.','1','9','.'],
01400          ['8','7','1','.','.','.','.','.','3'],
01401          ['9','.','3','.','.','2','6','5','7'],
01402          ['.','.','.','1','.','.','.','4','.'],
01403          ['.','.','.','5','7','9','3','.','8']
01404         ],
01405         [
01406          ['6','8','.','.','1','.','.','3','.'],
01407          ['1','.','.','3','.','6','.','7','4'],
01408          ['.','.','7','9','.','4','2','.','1'],
01409          ['3','.','5','4','.','.','.','.','6'],
01410          ['.','.','.','.','.','.','.','.','.'],
01411          ['8','.','.','.','.','5','4','.','3'],
01412          ['9','.','3','8','.','2','6','.','.'],
01413          ['7','5','.','1','.','3','.','.','2'],
01414          ['.','6','.','.','7','.','.','1','8']
01415         ],
01416         [
01417          ['6','.','4','.','.','.','5','.','9'],
01418          ['1','.','.','.','.','.','8','7','.'],
01419          ['5','3','.','9','8','.','.','.','1'],
01420          ['.','.','5','.','.','1','.','8','.'],
01421          ['.','4','.','7','3','8','.','9','.'],
01422          ['.','7','.','6','.','.','4','.','.'],
01423          ['9','.','.','.','4','2','.','5','7'],
01424          ['.','5','8','.','.','.','.','.','2'],
01425          ['4','.','2','.','.','.','3','.','8']
01426         ],
01427         [
01428          ['.','.','.','.','5','6','1','.','.'],
01429          ['.','.','.','8','1','.','.','6','4'],
01430          ['6','4','.','7','9','.','.','5','.'],
01431          ['9','.','7','.','8','.','5','4','.'],
01432          ['4','.','.','.','.','.','.','.','8'],
01433          ['.','5','6','.','2','.','7','.','3'],
01434          ['.','6','.','.','3','7','.','8','5'],
01435          ['3','9','.','.','4','8','.','.','.'],
01436          ['.','.','2','5','6','.','.','.','.']
01437         ],
01438         [
01439          ['.','.','.','.','.','.','1','.','9'],
01440          ['5','.','9','.','.','2','.','6','.'],
01441          ['6','.','.','7','9','.','8','5','.'],
01442          ['9','.','7','3','8','.','5','.','6'],
01443          ['.','.','.','6','.','5','.','.','.'],
01444          ['8','.','6','.','2','4','7','.','3'],
01445          ['.','6','4','.','3','7','.','.','5'],
01446          ['.','9','.','1','.','.','6','.','7'],
01447          ['7','.','2','.','.','.','.','.','.']
01448         ],
01449         [
01450          ['2','.','8','4','.','.','.','.','9'],
01451          ['5','.','9','8','1','2','.','.','.'],
01452          ['.','.','1','.','9','.','.','5','.'],
01453          ['.','.','7','.','.','.','5','4','6'],
01454          ['.','1','3','6','.','5','2','9','.'],
01455          ['8','5','6','.','.','.','7','.','.'],
01456          ['.','6','.','.','3','.','9','.','.'],
01457          ['.','.','.','1','4','8','6','.','7'],
01458          ['7','.','.','.','.','9','4','.','1']
01459         ],
01460         [
01461          ['2','.','8','4','5','.','.','7','.'],
01462          ['.','.','9','.','1','2','3','.','4'],
01463          ['6','.','.','7','.','.','8','5','.'],
01464          ['.','.','.','.','8','.','5','4','6'],
01465          ['4','1','.','.','.','.','.','9','8'],
01466          ['8','5','6','.','2','.','.','.','.'],
01467          ['.','6','4','.','.','7','.','.','5'],
01468          ['3','.','5','1','4','.','6','.','.'],
01469          ['.','8','.','.','6','9','4','.','1']
01470         ],
01471         [
01472          ['7','9','.','5','.','1','.','.','.'],
01473          ['.','5','1','.','.','.','.','.','6'],
01474          ['.','8','.','.','.','9','.','.','2'],
01475          ['.','.','.','2','5','.','.','8','1'],
01476          ['.','.','.','.','.','.','.','.','.'],
01477          ['8','4','.','.','7','3','.','.','.'],
01478          ['1','.','.','6','.','.','.','7','.'],
01479          ['5','.','.','.','.','.','8','1','.'],
01480          ['.','.','.','3','.','2','.','6','5']
01481         ],
01482         [
01483          ['.','.','.','.','6','.','.','.','.'],
01484          ['.','.','1','.','.','.','.','9','6'],
01485          ['.','.','4','.','3','9','.','.','.'],
01486          ['.','6','7','.','.','4','3','8','.'],
01487          ['2','.','.','8','.','6','.','.','7'],
01488          ['.','4','5','1','.','.','6','2','.'],
01489          ['.','.','.','6','8','.','2','.','.'],
01490          ['5','2','.','.','.','.','8','.','.'],
01491          ['.','.','.','.','1','.','.','.','.']
01492         ],
01493         [
01494          ['.','.','.','.','6','1','.','3','.'],
01495          ['.','.','.','.','.','.','7','9','.'],
01496          ['.','.','4','7','3','.','.','.','2'],
01497          ['.','6','.','.','5','.','.','8','.'],
01498          ['2','.','3','.','.','.','5','.','7'],
01499          ['.','4','.','.','7','.','.','2','.'],
01500          ['1','.','.','.','8','5','2','.','.'],
01501          ['.','2','6','.','.','.','.','.','.'],
01502          ['.','7','.','3','1','.','.','.','.']
01503         ],
01504         [
01505          ['.','.','.','.','.','1','4','3','8'],
01506          ['.','.','.','.','.','.','.','9','6'],
01507          ['.','.','.','.','.','9','1','.','2'],
01508          ['.','.','.','.','.','4','3','.','1'],
01509          ['2','.','.','8','.','6','.','.','7'],
01510          ['8','.','5','1','.','.','.','.','.'],
01511          ['1','.','9','6','.','.','.','.','.'],
01512          ['5','2','.','.','.','.','.','.','.'],
01513          ['4','7','8','3','.','.','.','.','.']
01514         ],
01515         [
01516          ['.','7','1','6','.','.','9','.','.'],
01517          ['4','.','.','.','.','.','3','.','1'],
01518          ['.','.','.','8','.','2','.','7','.'],
01519          ['.','5','.','.','.','.','4','.','.'],
01520          ['2','.','.','1','.','5','.','.','3'],
01521          ['.','.','3','.','.','.','.','9','.'],
01522          ['.','1','.','2','.','4','.','.','.'],
01523          ['6','.','8','.','.','.','.','.','2'],
01524          ['.','.','4','.','.','9','1','5','.']
01525         ],
01526         [
01527          ['2','.','7','.','6','.','.','.','.'],
01528          ['4','3','.','.','.','9','2','.','.'],
01529          ['.','6','5','4','.','.','.','.','.'],
01530          ['.','7','.','.','.','.','1','.','2'],
01531          ['.','.','6','8','1','7','5','.','.'],
01532          ['5','.','3','.','.','.','.','9','.'],
01533          ['.','.','.','.','.','8','3','5','.'],
01534          ['.','.','1','9','.','.','.','2','7'],
01535          ['.','.','.','.','3','.','6','.','1']
01536         ],
01537         [
01538          ['.','9','.','.','.','1','4','8','5'],
01539          ['.','.','8','7','.','.','2','.','6'],
01540          ['.','6','.','.','.','2','9','.','3'],
01541          ['8','7','.','.','9','.','1','.','.'],
01542          ['.','2','.','8','.','7','.','3','.'],
01543          ['.','.','3','.','2','.','.','9','8'],
01544          ['6','.','2','1','.','.','.','5','.'],
01545          ['3','.','1','.','.','6','8','.','.'],
01546          ['7','8','9','2','.','.','.','4','.']
01547         ],
01548         [
01549          ['2','.','.','3','.','.','.','8','.'],
01550          ['.','.','.','7','.','.','2','.','6'],
01551          ['.','6','.','4','8','.','9','7','3'],
01552          ['8','.','.','.','9','.','1','.','2'],
01553          ['9','.','.','8','1','7','.','.','4'],
01554          ['5','.','3','.','2','.','.','.','8'],
01555          ['6','4','2','.','7','8','.','5','.'],
01556          ['3','.','1','.','.','6','.','.','.'],
01557          ['.','8','.','.','.','5','.','.','1']
01558         ],
01559         [
01560          ['.','.','.','.','.','1','.','8','.'],
01561          ['4','.','.','.','.','.','2','1','6'],
01562          ['.','6','.','4','8','.','.','.','3'],
01563          ['.','.','4','5','9','.','.','6','.'],
01564          ['9','.','6','.','1','.','5','.','4'],
01565          ['.','1','.','.','2','4','7','.','.'],
01566          ['6','.','.','.','7','8','.','5','.'],
01567          ['3','5','1','.','.','.','.','.','7'],
01568          ['.','8','.','2','.','.','.','.','.']
01569         ],
01570         [
01571          ['.','.','9','2','.','.','.','.','4'],
01572          ['.','.','6','.','.','3','1','.','.'],
01573          ['4','.','.','1','.','.','5','.','.'],
01574          ['.','3','.','8','.','.','9','.','1'],
01575          ['.','.','.','3','.','4','.','.','.'],
01576          ['1','.','4','.','.','6','.','5','.'],
01577          ['.','.','7','.','.','2','.','.','3'],
01578          ['.','.','1','7','.','.','6','.','.'],
01579          ['9','.','.','.','.','1','4','.','.']
01580         ],
01581         [
01582          ['.','.','9','.','6','.','.','.','.'],
01583          ['2','.','6','4','.','.','1','.','.'],
01584          ['.','.','3','1','8','.','5','.','.'],
01585          ['.','.','2','.','.','.','.','.','1'],
01586          ['7','9','.','.','.','.','.','6','8'],
01587          ['1','.','.','.','.','.','3','.','.'],
01588          ['.','.','7','.','9','2','8','.','.'],
01589          ['.','.','1','.','.','8','6','.','5'],
01590          ['.','.','.','.','3','.','4','.','.']
01591         ],
01592        ]
01593       ]
01594 
01595 
01596     # Randomize each level in the list
01597     for l in range(0, len(sudoku_list)):
01598       for j in range(0, len(sudoku_list[l])):
01599         # Select a random new position to set the J sudoku
01600         old_sudo = sudoku_list[l][j]
01601         new_pos = random.randint(0,len(sudoku_list[l])-1)
01602         sudoku_list[l][j] = sudoku_list[l][new_pos]
01603         sudoku_list[l][new_pos] = old_sudo
01604 
01605 
01606 
01607     return sudoku_list
01608 

Here is the caller graph for this function:

def sudoku.Gcompris_sudoku.is_legal (   self,
  number 
)

Definition at line 389 of file sudoku.py.

00389 
00390   def is_legal(self, number):
00391 
00392     if((self.cursqre[0] == None) or
00393        (self.cursqre[1] == None)):
00394       return
00395 
00396     possible = True
00397     bad_square = []
00398 
00399     if(self.cursqre == None):
00400       return possible
00401 
00402     # Check this number is not already in a row
00403     for x in range(0,self.sudo_size):
00404 
00405       if x == self.cursqre[0]:
00406          continue
00407 
00408       item = self.sudo_number[x][self.cursqre[1]]
00409       othernumber = item.get_property('text').decode('UTF-8')
00410 
00411       if(number == othernumber):
00412         bad_square.append(self.sudo_square[x][self.cursqre[1]])
00413         possible = False
00414 
00415     # Check this number is not already in a column
00416     for y in range(0,self.sudo_size):
00417 
00418       if y == self.cursqre[1]:
00419         continue
00420 
00421       item = self.sudo_number[self.cursqre[0]][y]
00422       othernumber = item.get_property('text').decode('UTF-8')
00423 
00424       if(number == othernumber):
00425         bad_square.append(self.sudo_square[self.cursqre[0]][y])
00426         possible = False
00427 
00428     #
00429     # Check this number is in a region
00430     #
00431 
00432     # Region is the modulo place to set region if defined
00433     region = None
00434     if(self.sudo_region.has_key(self.sudo_size)):
00435       region=self.sudo_region[self.sudo_size]
00436 
00437     if(region):
00438       # First, find the top-left square of the region
00439       top_left=[self.cursqre[0]/region*region, self.cursqre[1]/region*region]
00440       for x in range(0,region):
00441         for y in range(0,region):
00442           # Do not check the current square
00443           if (top_left[0] + x == self.cursqre[0] and
00444           top_left[1] + y == self.cursqre[1]):
00445             continue
00446 
00447           item = self.sudo_number[top_left[0] + x][top_left[1] + y]
00448           othernumber = item.get_property('text').decode('UTF-8')
00449 
00450           if(number == othernumber):
00451             bad_square.append(self.sudo_square[top_left[0] + x][top_left[1] + y])
00452             possible = False
00453 
00454     if not possible:
00455       self.set_on_error(bad_square)
00456 
00457     return possible

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 463 of file sudoku.py.

00463 
00464   def is_solved(self):
00465 
00466     for x in range(0,self.sudo_size):
00467       for y in range(0,self.sudo_size):
00468         item = self.sudo_number[x][y]
00469         number = item.get_property('text').decode('UTF-8')
00470         if(number == ""):
00471           return False
00472 
00473     return True

Here is the caller graph for this function:

def sudoku.Gcompris_sudoku.key_press (   self,
  keyval,
  commit_str,
  preedit_str 
)

Definition at line 134 of file sudoku.py.

00134 
00135   def key_press(self, keyval, commit_str, preedit_str):
00136 
00137     if(self.cursqre == None):
00138       return False
00139 
00140     utf8char = gtk.gdk.keyval_to_unicode(keyval)
00141     strn = u'%c' % utf8char
00142 
00143     if(strn in self.valid_chars):
00144 
00145       if self.is_legal(strn):
00146         self.sudo_number[self.cursqre[0]][self.cursqre[1]].set(
00147           text = strn.encode('UTF-8'),
00148           )
00149 
00150         # Maybe it's all done
00151         if self.is_solved():
00152           self.cursqre = None
00153           self.gamewon = 1
00154           gcompris.bonus.display(gcompris.bonus.WIN, gcompris.bonus.FLOWER)
00155 
00156     else:
00157       # Erase the old number there
00158       if ((keyval == gtk.keysyms.BackSpace) or
00159           (keyval == gtk.keysyms.Delete) or
00160           (keyval == gtk.keysyms.space)):
00161         self.sudo_number[self.cursqre[0]][self.cursqre[1]].set(
00162           text = "",
00163           )
00164 
00165       else:
00166         # No key processing done
00167         return False
00168 
00169     # Return  True  if you did process a key
00170     # Return  False if you did not processed a key
00171     #         (gtk need to send it to next widget)
00172     return True

Here is the call graph for this function:

Definition at line 200 of file sudoku.py.

00200 
00201   def next_level(self):
00202 
00203     # Randomize symbols
00204     for j in range(0, len(self.symbols)):
00205         # Select a random new position to set the J symbol
00206         old_symbol = self.symbols[j]
00207         new_pos = random.randint(0,len(self.symbols)-1)
00208         self.symbols[j] = self.symbols[new_pos]
00209         self.symbols[new_pos] = old_symbol
00210 
00211     self.display_sudoku(self.sudoku[self.gcomprisBoard.level-1][self.gcomprisBoard.sublevel-1])
00212 
00213     gcompris.score.start(gcompris.score.STYLE_NOTE, 610, 485,
00214                          len(self.sudoku[self.gcomprisBoard.level-1]))
00215     gcompris.score.set(self.gcomprisBoard.sublevel)
00216 
00217     return True

Here is the call graph for this function:

Here is the caller graph for this function:

def sudoku.Gcompris_sudoku.ok (   self)

Definition at line 123 of file sudoku.py.

00123 
00124   def ok(self):
00125     print("Gcompris_sudoku ok.")
00126 

def sudoku.Gcompris_sudoku.pause (   self,
  pause 
)

Definition at line 173 of file sudoku.py.

00173 
00174   def pause(self, pause):
00175 
00176     self.board_paused = pause
00177 
00178     # When the bonus is displayed, it call us first
00179     # with pause(1) and then with pause(0)
00180     # the game is won
00181     if(self.gamewon == 1 and pause == 0):
00182       self.gamewon = 0
00183       if(self.increment_level()):
00184         self.next_level()
00185 
00186     return
00187 
00188 

Here is the call graph for this function:

Definition at line 127 of file sudoku.py.

00127 
00128   def repeat(self):
00129     self.display_sudoku(self.sudoku[self.gcomprisBoard.level-1][self.gcomprisBoard.sublevel-1])

Here is the call graph for this function:

def sudoku.Gcompris_sudoku.set_level (   self,
  level 
)

Definition at line 189 of file sudoku.py.

00189 
00190   def set_level(self, level):
00191     self.gcomprisBoard.level = level;
00192     self.gcomprisBoard.sublevel = 1;
00193     gcompris.bar_set_level(self.gcomprisBoard)
00194     self.next_level()
00195 
00196 # ---- End of Initialisation

Here is the call graph for this function:

def sudoku.Gcompris_sudoku.set_on_error (   self,
  items 
)

Definition at line 371 of file sudoku.py.

00371 
00372   def set_on_error(self, items):
00373     for item in items:
00374       item.set(
00375         fill_color_rgba= self.error_square_color
00376         )
00377 
00378     self.timer = gtk.timeout_add(3000, self.unset_on_error, items)

Here is the call graph for this function:

Here is the caller graph for this function:

def sudoku.Gcompris_sudoku.set_sudoku_symbol (   self,
  text,
  x,
  y 
)

Definition at line 241 of file sudoku.py.

00241 
00242   def set_sudoku_symbol(self, text, x, y):
00243     pixmap = self.get_pixmap_symbol(self.valid_chars, text)
00244 
00245     self.sudo_symbol[x][y].set(
00246       pixbuf = pixmap
00247       )
00248     self.sudo_symbol[x][y].show()
00249 
00250     self.sudo_number[x][y].set(
00251       text = text
00252       )
00253 

Here is the call graph for this function:

Here is the caller graph for this function:

def sudoku.Gcompris_sudoku.square_item_event (   self,
  widget,
  event,
  square 
)

Definition at line 332 of file sudoku.py.

00332 
00333   def square_item_event(self, widget, event, square):
00334 
00335     if(self.gamewon):
00336       return False
00337 
00338     # Check it's a user editable square
00339     oldcolor = self.sudo_number[square[0]][square[1]].get_property('fill_color_rgba')
00340     if oldcolor == self.fixed_number_color:
00341       return False
00342 
00343     if event.type == gtk.gdk.ENTER_NOTIFY:
00344       if self.cursqre != square:
00345         self.sudo_square[square[0]][square[1]].set(
00346           fill_color_rgba = self.highl_square_color,
00347           )
00348     elif event.type == gtk.gdk.LEAVE_NOTIFY:
00349       if self.cursqre == square:
00350         self.sudo_square[square[0]][square[1]].set(
00351           fill_color_rgba = self.focus_square_color,
00352           )
00353       else:
00354         self.sudo_square[square[0]][square[1]].set(
00355           fill_color_rgba = self.normal_square_color,
00356           )
00357     elif event.type == gtk.gdk.BUTTON_PRESS:
00358       if(self.cursqre):
00359         self.sudo_square[self.cursqre[0]][self.cursqre[1]].set(
00360           fill_color_rgba = self.normal_square_color,
00361           )
00362       self.cursqre = square
00363       self.sudo_square[square[0]][square[1]].set(
00364         fill_color_rgba = self.focus_square_color,
00365         )
00366       return True
00367 
00368     return False

Here is the caller graph for this function:

Definition at line 82 of file sudoku.py.

00082 
00083   def start(self):
00084 
00085     # Init the sudoku dataset
00086     self.sudoku = self.init_item_list()
00087 
00088     self.gcomprisBoard.level=1
00089     self.gcomprisBoard.maxlevel=len(self.sudoku)
00090     self.gcomprisBoard.sublevel=1
00091 
00092     pixmap = gcompris.utils.load_pixmap(gcompris.skin.image_to_skin("button_reload.png"))
00093     if(pixmap):
00094       gcompris.bar_set_repeat_icon(pixmap)
00095       gcompris.bar_set(gcompris.BAR_LEVEL|gcompris.BAR_REPEAT_ICON)
00096     else:
00097       gcompris.bar_set(gcompris.BAR_LEVEL|gcompris.BAR_REPEAT)
00098 
00099     gcompris.set_background(self.gcomprisBoard.canvas.root(),
00100                             gcompris.skin.image_to_skin("gcompris-bg.jpg"))
00101     gcompris.bar_set_level(self.gcomprisBoard)
00102 
00103     # Create our rootitem. We put each canvas item in it so at the end we
00104     # only have to kill it. The canvas deletes all the items it contains automaticaly.
00105     self.rootitem = self.gcomprisBoard.canvas.root().add(
00106       gnomecanvas.CanvasGroup,
00107       x=0.0,
00108       y=0.0
00109       )
00110 
00111     self.next_level()
00112 
00113     self.pause(0);
00114 
00115 

Here is the call graph for this function:

def sudoku.Gcompris_sudoku.symbol_item_event (   self,
  item,
  event,
  text 
)

Definition at line 272 of file sudoku.py.

00272 
00273   def symbol_item_event(self, item, event, text):
00274 
00275     if(self.gamewon):
00276       return False
00277     #
00278     # MOTION EVENT
00279     # ------------
00280     if event.type == gtk.gdk.MOTION_NOTIFY:
00281       if event.state & gtk.gdk.BUTTON1_MASK:
00282         x=event.x
00283         y=event.y
00284 
00285         item.set(
00286           x= x,
00287           y= y)
00288 
00289         return True
00290     #
00291     # MOUSE DRAG STOP
00292     # ---------------
00293     if event.type == gtk.gdk.BUTTON_RELEASE:
00294       if event.button == 1:
00295         x=event.x
00296         y=event.y
00297 
00298         cx = float(item.get_data("orig_x"))
00299         cy = float(item.get_data("orig_y"))
00300         item.set(
00301           x= cx,
00302           y= cy)
00303 
00304         target_item = self.gcomprisBoard.canvas.get_item_at(x, y)
00305 
00306         if target_item:
00307           # Get it's sudo coord
00308           x = target_item.get_data("sudo_x")
00309           if x:
00310             x = int(x)
00311 
00312           y = target_item.get_data("sudo_y")
00313           if y:
00314             y = int(y)
00315 
00316           self.cursqre = (x, y)
00317           if self.is_legal(text):
00318             self.set_sudoku_symbol(text, x, y)
00319 
00320             # Maybe it's all done
00321             if self.is_solved():
00322               self.gamewon = 1
00323               gcompris.bonus.display(gcompris.bonus.WIN,
00324                                      gcompris.bonus.FLOWER)
00325 
00326         return True
00327 
00328     return False

Here is the call graph for this function:

Here is the caller graph for this function:

def sudoku.Gcompris_sudoku.unset_on_error (   self,
  items 
)

Definition at line 379 of file sudoku.py.

00379 
00380   def unset_on_error(self, items):
00381     if(self.rootitem):
00382       for item in items:
00383         item.set(
00384           fill_color_rgba= self.fixed_square_color
00385           )
00386 

Here is the caller graph for this function:


Member Data Documentation

Definition at line 41 of file sudoku.py.

Definition at line 52 of file sudoku.py.

Definition at line 58 of file sudoku.py.

Definition at line 62 of file sudoku.py.

Definition at line 57 of file sudoku.py.

Definition at line 56 of file sudoku.py.

Definition at line 42 of file sudoku.py.

Definition at line 35 of file sudoku.py.

Definition at line 55 of file sudoku.py.

Definition at line 59 of file sudoku.py.

Definition at line 54 of file sudoku.py.

Definition at line 65 of file sudoku.py.

Definition at line 104 of file sudoku.py.

Definition at line 46 of file sudoku.py.

Definition at line 69 of file sudoku.py.

Definition at line 68 of file sudoku.py.

Definition at line 45 of file sudoku.py.

Definition at line 47 of file sudoku.py.

Definition at line 67 of file sudoku.py.

Definition at line 73 of file sudoku.py.

Definition at line 74 of file sudoku.py.

Definition at line 71 of file sudoku.py.

Definition at line 63 of file sudoku.py.

Definition at line 49 of file sudoku.py.


The documentation for this class was generated from the following file: