After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 685601 - only games in DATA directory are returned
only games in DATA directory are returned
Status: RESOLVED DUPLICATE of bug 580055
Product: gnome-sudoku
Classification: Applications
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: gnome-sudoku-maint
gnome-sudoku-maint
Depends on:
Blocks:
 
 
Reported: 2012-10-06 07:18 UTC by Ηλίας Ηλιάδης
Modified: 2014-05-20 01:05 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Ηλίας Ηλιάδης 2012-10-06 07:18:45 UTC
When playing or printing multiple games,there are no new games. Only games found in DATA directory. Which means for "hard" there are only 150 games. Printing multiple games and mark them as solved does not produce any new games (even "reversed" as "game_selector.py" lpuz.reverse() function should do).
Reproduce:
Select "print multiple games"
Select number=100
Select only "hard" difficulty
Select "mark as solved"

Print.
Redo this several times. (in my pc only 3 times can be done, probably because I unselect "include played games"?)
Only the ones that are in puzzles directory (/usr/share/gnome-sudoku/puzzles) in file hard, are printed.

Suggestion: Automatically create random permutations of the existing.

code written by me and checked (as standalone, not inside sudoku)

#!/usr/bin/python
# -*- coding: utf-8 -*-
import random

#Can be used in "game_selector.py" instead of:
#"lpuz.reverse() # we reverse the puzzle so it at least looks different :-)"
#Always check if permutated puzzle exists.

#Can be used to generate new games from files in data directory. 
#(But number of difficulty which lays at the end will be scrumbled,
#although it will not change the real difficulty. So be carefull!)

def create_random_permutation():
	"""creates a random permutation of (123456789)
	
		Possible permutations (9!-1)=362.879"""
	
	newP=''
	oldP='123456789'
	#find a random number
	for x in range(8):
		#random number from remaining
		rnd_digit=random.sample(oldP,len(oldP))
		#add random number to new
		newP= newP + rnd_digit[0]
		#remove from old
		oldP=oldP.replace(rnd_digit[0],'')
		#debug
		#print newP
		
	#debug
	#print '----(8 digits above)'
	
	#add remaining
	newP=newP + oldP
	#debug
	#print 'New Permutation: ' + newP
	return newP
	
def create_random_puzzle_from_existing(puzzlestring):
	"""Creates a ramdom "permutated" puzzle from a given one.
	
		Difficulty will not change."""
	
	#can add optional parameter to use a specific permutation
	#in case we add permutations to another file
	#and check if already some permutations have been used
	
	new_permutation=create_random_permutation()
	#replace numbers with letters
	#this can be done by some for next loop maybe
	puzzlestring=puzzlestring.replace('1','A')
	puzzlestring=puzzlestring.replace('2','B')
	puzzlestring=puzzlestring.replace('3','C')
	puzzlestring=puzzlestring.replace('4','D')
	puzzlestring=puzzlestring.replace('5','E')
	puzzlestring=puzzlestring.replace('6','F')
	puzzlestring=puzzlestring.replace('7','G')
	puzzlestring=puzzlestring.replace('8','H')
	puzzlestring=puzzlestring.replace('9','I')
	#replace letters with new numbers
	puzzlestring=puzzlestring.replace('A',new_permutation[0])
	puzzlestring=puzzlestring.replace('B',new_permutation[1])
	puzzlestring=puzzlestring.replace('C',new_permutation[2])
	puzzlestring=puzzlestring.replace('D',new_permutation[3])
	puzzlestring=puzzlestring.replace('E',new_permutation[4])
	puzzlestring=puzzlestring.replace('F',new_permutation[5])
	puzzlestring=puzzlestring.replace('G',new_permutation[6])
	puzzlestring=puzzlestring.replace('H',new_permutation[7])
	puzzlestring=puzzlestring.replace('I',new_permutation[8])
	
	#debug	
	#print puzzlestring
	return puzzlestring
	#add this to data file of puzzles or it will confuse future algorithm generators?
	
    
if __name__ == '__main__':
	#test if it is working
	test=create_random_puzzle_from_existing(' 01 02 03 04 05 06 07 08 09,123456789,987654321')
	print test
	
	
	#test=create_random_puzzle_from_existing('3 5 0 0 0 9 4 0 0 0 9 0 4 0 0 0 0 3 0 4 0 8 6 0 0 9 0 4 7 0 0 1 0 9 0 0 0 3 0 6 0 4 0 2 0 0 0 2 0 3 0 0 7 4 0 6 0 0 8 2 0 4 0 7 0 0 0 0 1 0 5 0 0 0 4 7 0 0 0 8 1')
	#print test
Comment 1 Michael Catanzaro 2014-05-20 01:05:30 UTC
Thanks for the bug report. This particular bug has already been reported into our bug tracking system, but please feel free to report any further bugs you find.

*** This bug has been marked as a duplicate of bug 580055 ***