FORUM DE DISCUSSION SUR LE LANGAGE PANORAMIC
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
FORUM DE DISCUSSION SUR LE LANGAGE PANORAMIC

Développement d'applications avec le langage Panoramic
 
AccueilAccueil  RechercherRechercher  Dernières imagesDernières images  S'enregistrerS'enregistrer  MembresMembres  Connexion  
Derniers sujets
» Petit passage furtif
un p'tit sudoku a resoudre Emptypar Froggy One Hier à 14:26

» demande explication KGF pour imprimer en mm
un p'tit sudoku a resoudre Emptypar JL35 Mar 26 Mar 2024 - 10:06

» SPIN et aide langage (résolu)
un p'tit sudoku a resoudre Emptypar leclode Sam 23 Mar 2024 - 15:20

» Aide-mémoire des mots-clés Panoramic
un p'tit sudoku a resoudre Emptypar papydall Mer 20 Mar 2024 - 21:23

» Je ne comprend pas pourquoi la largeur de la scene 3d change
un p'tit sudoku a resoudre Emptypar Marc Mar 12 Mar 2024 - 20:06

» Comment télécharger panoramic?
un p'tit sudoku a resoudre Emptypar lepetitmarocain Sam 9 Mar 2024 - 13:31

» @lepetitmarocain <==> KGFGrid
un p'tit sudoku a resoudre Emptypar Klaus Dim 3 Mar 2024 - 9:59

» Tangram-Toukaré
un p'tit sudoku a resoudre Emptypar jjn4 Mer 28 Fév 2024 - 18:12

» Editeur EliP 6 : Le Tiny éditeur avec 25 onglets de travail
un p'tit sudoku a resoudre Emptypar jjn4 Mer 28 Fév 2024 - 18:09

» KGF_dll - nouvelles versions
un p'tit sudoku a resoudre Emptypar Klaus Mer 28 Fév 2024 - 17:01

» Mes souhaits d'amélioration de Panoramic.
un p'tit sudoku a resoudre Emptypar Pedro Lun 26 Fév 2024 - 18:12

» Testez-votre-QI
un p'tit sudoku a resoudre Emptypar jjn4 Dim 25 Fév 2024 - 17:12

» Utilisation d'Élip
un p'tit sudoku a resoudre Emptypar jjn4 Sam 24 Fév 2024 - 18:33

» Récapitulatif ludothèque panoramic jjn4
un p'tit sudoku a resoudre Emptypar jjn4 Sam 24 Fév 2024 - 18:11

» Générateur de mots de passe
un p'tit sudoku a resoudre Emptypar mindstorm Mar 20 Fév 2024 - 20:09

Navigation
 Portail
 Index
 Membres
 Profil
 FAQ
 Rechercher
Rechercher
 
 

Résultats par :
 
Rechercher Recherche avancée
Mars 2024
LunMarMerJeuVenSamDim
    123
45678910
11121314151617
18192021222324
25262728293031
CalendrierCalendrier
Le Deal du moment : -15%
(Adhérents Fnac) LEGO® Star Wars™ ...
Voir le deal
552.49 €

 

 un p'tit sudoku a resoudre

Aller en bas 
+3
Jicehel
Klaus
pascal10000
7 participants
Aller à la page : 1, 2  Suivant
AuteurMessage
pascal10000

pascal10000


Nombre de messages : 812
Localisation : Troyes
Date d'inscription : 05/02/2011

un p'tit sudoku a resoudre Empty
MessageSujet: un p'tit sudoku a resoudre   un p'tit sudoku a resoudre EmptyLun 19 Oct 2015 - 0:08

bsr
une petite nouveauté dans les jeux un sudoku a résoudre
encore quelque p'tit truc a finir. différencié les couleurs
annuler la derniere saisie. sinon il est jouable et je n'ai pas rencontré
de bug lors mes test
les numéros sont triés et placé au hasard dans la grille
dans jeu()

Code:
dim key,jeux$,num$
dim a1$,a2$,a3$,a4$,a5$,a6$,a7$,a8$,a9$,x,y,posx%,posy%
dim num1%,num2%,num3%,num4%,num5%,num6%,num7%,num8%,num9%
dim suite$(1,9),gride1$,gride2$,gride3$,gride4$,gride5$,gride6$,gride7$,gride8$,gride9$,
dim  RGB% ,B%,R%,G%,FRGB%,res%
label tri,trie,choix
label choix1,choix2,choix3,choix4,choix5,choix6,choix7,choix8,jeu

num$=""
num1%=0: num2%=0: num3%=0: num4%=0: num5%=0: num6%=0: num7%=0: num8%=0: num9%=0

left 0,520
top 0,235
width 0,590
height 0,492
caption 0,"Sodoku"
font_size 0,10
font_bold 0

grid 1
left 1,10
top 1,10
width 1,428
height 1,428
grid_row 1,10: grid_column 1,10
grid_column_width 1,(465/10): grid_one_column_width 1,1,0.01
grid_row_height 1,(465/10): grid_one_row_height 1,1,0.01
font_size 1,20
font_bold 1
on_click 1,jeu
' ooooooooooooooooooooooooooooooooooooooooooooooo
' instalation des séparation pour la grille
for x=1 to 2
scene2d 11+x
top 11+x,top(1):height 11+x,height(1)-1
width 11+x,3: left 11+x,left(1)+(141*x)+1
next x
for x=1 to 2
scene2d 15+x
left 15+x,left(1): width 15+x,width(1)-1
height 15+x,3: top 15+x,top(1)+(141*x)+1
next x
' ooooooooooooooooooooooooooooooooooooooooooooooo

button 2          :alpha 22
left 2,460        :left 22,500
top 2,20          :top 22,20
width 2,31        :width 22,10
caption 2,"1"
on_click 2,choix

button 3          :alpha 23
left 3,460        :left 23,500
top 3,60          :top 23,60
width 3,30        :width 23,10
caption 3,"2"
on_click 3,choix1

button 4          :alpha 24
left 4,460        :left 24,500
top 4,100          :top 24,103
width 4,30        :width 24,10
caption 4,"3"
on_click 4,choix2

button 5          :alpha 25
left 5,460        :left 25,500
top 5,140          :top 25,143
width 5,30        :width 25,10
caption 5,"4"
on_click 5,choix3

button 6          :alpha 26
left 6,460        :left 26,500
top 6,180          :top 26,183
width 6,30        :width 26,10
caption 6,"5"
on_click 6,choix4

button 7          :alpha 27
left 7,460        :left 27,500
top 7,220          :top 27,223
width 7,30        :width 27,10
caption 7,"6"
on_click 7,choix5

button 8          :alpha 28
left 8,460        :left 28,500
top 8,260          :top 28,263
width 8,30        :width 28,10
caption 8,"7"
on_click 8,choix6

button 9          :alpha 29
left 9,460        :left 29,500
top 9,300          :top 29,303
width 9,30        :width 29,10
caption 9,"8"
on_click 9,choix7

button 10          :alpha 30
left 10,460        :left 30,500
top 10,340        :top 30,343
width 10,30        :width 30,10
caption 10,"9"
on_click 10,choix8

gosub tri
end

' triage des chiffres
tri:
for x=1 to 9
trie:
y=int(rnd(9))+1
if suite$(1,y)=""
suite$(1,y)=str$(x)
else
goto trie
end_if
next x
 a1$=suite$(1,1)
 a2$=suite$(1,2)
 a3$=suite$(1,3)
 a4$=suite$(1,4)
 a5$=suite$(1,5)
 a6$=suite$(1,6)
 a7$=suite$(1,7)
 a8$=suite$(1,8)
 a9$=suite$(1,9)
' ooooooooooooooooooooooooooooooo
jeux() :' initialisation de la grille
return

' jeu en lui même
choix:
 num$=caption$(2)
return
choix1:
 num$=caption$(3)
return
choix2:
 num$=caption$(4)
return
choix3:
 num$=caption$(5)
return
choix4:
 num$=caption$(6)
return
choix5:
 num$=caption$(7)
return
choix6:
 num$=caption$(8)
return
choix7:
 num$=caption$(9)
return
choix8:
 num$=caption$(10)
return

jeu:
posx%=grid_x_to_column(1,mouse_x_position(1))
posy%=grid_y_to_row(1,mouse_y_position(1))

' section des recherche des doublons par ligne, colones et section 3X3
if clicked(1)=1
 if grid_read$(1,posy%,posx%)<>"" then return
 if num$="" then return
' doubon dans la ligne
 for x=2 to 10
  if grid_read$(1,posy%,x)="  "+num$
  message "DOUBLON "+num$+"  C"+str$(posy%)+"  L"+str$(x)
  return
  end_if
 next x
' Doublon dans la colone
 for y=2 to 10
  if grid_read$(1,y,posx%)="  "+num$
  message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(posx%)
  return
  end_if
 next y

 if posx%>1 and posx%<5
 if posy%>1 and posy%<5
    for x=2 to 4
    for y=2 to 4
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>4 and posx%<8
 if posy%>1 and posy%<5
    for x=5 to 7
    for y=2 to 4
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>7 and posx%<11
 if posy%>1 and posy%<5
    for x=8 to 10
    for y=2 to 4
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>1 and posx%<5
 if posy%>4 and posy%<8
    for x=2 to 4
    for y=5 to 7
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>4 and posx%<8
 if posy%>4 and posy%<8
    for x=5 to 7
    for y=5 to 7
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>7 and posx%<11
 if posy%>4 and posy%<8
    for x=8 to 10
    for y=5 to 7
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>1 and posx%<5
 if posy%>7 and posy%<11
    for x=2 to 4
    for y=8 to 10
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>4 and posx%<8
 if posy%>7 and posy%<11
    for x=5 to 7
    for y=8 to 10
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>7 and posx%<11
 if posy%>7 and posy%<11
    for x=8 to 10
    for y=8 to 10
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

end_if
grid_write 1,posy%,posx%,"  "+num$

 ' mise a jour des compteur
if num$="1" then num1%=num1%+1 : caption 22,str$(num1%)
if num$="2" then num2%=num2%+1 : caption 23,str$(num2%)
if num$="3" then num3%=num3%+1 : caption 24,str$(num3%)
if num$="4" then num4%=num4%+1 : caption 25,str$(num4%)
if num$="5" then num5%=num5%+1 : caption 26,str$(num5%)
if num$="6" then num6%=num6%+1 : caption 27,str$(num6%)
if num$="7" then num7%=num7%+1 : caption 28,str$(num7%)
if num$="8" then num8%=num8%+1 : caption 29,str$(num8%)
if num$="9" then num9%=num9%+1 : caption 30,str$(num9%)

' neutralise si une des séries est complétées
if caption$(22)="9"
inactive 2
inactive 22
end_if
if caption$(23)="9"
inactive 3
inactive 23
end_if
if caption$(24)="9"
inactive 4
inactive 24
end_if
if caption$(25)="9"
inactive 5
inactive 25
end_if
if caption$(26)="9"
inactive 6
inactive 26
end_if
if caption$(27)="9"
inactive 7
inactive 27
end_if
if caption$(28)="9"
inactive 8
inactive 28
end_if
if caption$(29)="9"
inactive 9
inactive 29
end_if
if caption$(30)="9"
inactive 10
inactive 30
end_if

return
' ooooooooooooooooooooooooooooooooooooooooooooo

' initialisation de la grille
sub jeux()
gride1$ =a1$+a2$+a3$+a4$+a5$+a6$+a7$+a8$+a9$
gride2$ =a7$+a6$+a9$+a3$+a8$+a1$+a2$+a5$+a4$
gride3$ =a4$+a5$+a8$+a9$+a7$+a2$+a3$+a1$+a6$
gride4$ =a9$+a3$+a4$+a5$+a1$+a7$+a6$+a2$+a8$
gride5$ =a2$+a1$+a6$+a8$+a9$+a3$+a4$+a7$+a5$
gride6$ =a8$+a7$+a5$+a6$+a2$+a4$+a1$+a9$+a3$
gride7$ =a6$+a9$+a7$+a1$+a4$+a5$+a8$+a3$+a2$
gride8$ =a3$+a8$+a1$+a2$+a6$+a9$+a5$+a4$+a7$
gride9$ =a5$+a4$+a2$+a7$+a3$+a8$+a9$+a6$+a1$

for x=1 to 9
grid_write 1,2,x+1,"  "+mid$(gride1$,x,1)
y=int(rnd(2)):if y=0 then grid_write 1,2,x+1,""

grid_write 1,3,x+1,"  "+mid$(gride2$,x,1)
y=int(rnd(2)):if y=0 then grid_write 1,3,x+1,""

grid_write 1,4,x+1,"  "+mid$(gride3$,x,1)
y=int(rnd(1)):if y=0 then grid_write 1,4,x+1,""

grid_write 1,5,x+1,"  "+mid$(gride4$,x,1)
y=int(rnd(2)):if y=0 then grid_write 1,5,x+1,""

grid_write 1,6,x+1,"  "+mid$(gride5$,x,1)
y=int(rnd(2)):if y=0 then grid_write 1,6,x+1,""

grid_write 1,7,x+1,"  "+mid$(gride6$,x,1)
y=int(rnd(1)):if y=0 then grid_write 1,7,x+1,""

grid_write 1,8,x+1,"  "+mid$(gride7$,x,1)
y=int(rnd(2)):if y=0 then grid_write 1,8,x+1,""

grid_write 1,9,x+1,"  "+mid$(gride8$,x,1)
y=int(rnd(2)):if y=0 then grid_write 1,9,x+1,""

grid_write 1,10,x+1,"  "+mid$(gride9$,x,1)
y=int(rnd(1)):if y=0 then grid_write 1,10,x+1,""

next x
comptage()
end_sub

sub comptage()
for x=2 to 10
for y=2 to 10
if grid_read$(1,y,x)="  1" then num1%=num1%+1 : caption 22,str$(num1%)
if grid_read$(1,y,x)="  2" then num2%=num2%+1 : caption 23,str$(num2%)
if grid_read$(1,y,x)="  3" then num3%=num3%+1 : caption 24,str$(num3%)
if grid_read$(1,y,x)="  4" then num4%=num4%+1 : caption 25,str$(num4%)
if grid_read$(1,y,x)="  5" then num5%=num5%+1 : caption 26,str$(num5%)
if grid_read$(1,y,x)="  6" then num6%=num6%+1 : caption 27,str$(num6%)
if grid_read$(1,y,x)="  7" then num7%=num7%+1 : caption 28,str$(num7%)
if grid_read$(1,y,x)="  8" then num8%=num8%+1 : caption 29,str$(num8%)
if grid_read$(1,y,x)="  9" then num9%=num9%+1 : caption 30,str$(num9%)
next y
next x
end_sub

bon jeu
klaus j'ai tenté a mettre différente couleur avec kgf impossible d'y arrivé
merci si tu peut aporté de l'aide
a+
Revenir en haut Aller en bas
Klaus

Klaus


Nombre de messages : 12274
Age : 74
Localisation : Ile de France
Date d'inscription : 29/12/2009

un p'tit sudoku a resoudre Empty
MessageSujet: Re: un p'tit sudoku a resoudre   un p'tit sudoku a resoudre EmptyLun 19 Oct 2015 - 0:53

J'ai introduit une procedure test() qui colorie une ligne, une colonne et une cellule, juste pour la démo:
Code:
dim key,jeux$,num$
dim a1$,a2$,a3$,a4$,a5$,a6$,a7$,a8$,a9$,x,y,posx%,posy%
dim num1%,num2%,num3%,num4%,num5%,num6%,num7%,num8%,num9%
dim suite$(1,9),gride1$,gride2$,gride3$,gride4$,gride5$,gride6$,gride7$,gride8$,gride9$,
dim  RGB% ,B%,R%,G%,FRGB%,res%
label tri,trie,choix
label choix1,choix2,choix3,choix4,choix5,choix6,choix7,choix8,jeu

num$=""
num1%=0: num2%=0: num3%=0: num4%=0: num5%=0: num6%=0: num7%=0: num8%=0: num9%=0

left 0,520
top 0,235
width 0,590
height 0,492
caption 0,"Sodoku"
font_size 0,10
font_bold 0

grid 1
left 1,10
top 1,10
width 1,428
height 1,428
grid_row 1,10: grid_column 1,10
grid_column_width 1,(465/10): grid_one_column_width 1,1,0.01
grid_row_height 1,(465/10): grid_one_row_height 1,1,0.01
font_size 1,20
font_bold 1
on_click 1,jeu
' **********************
dll_on "KGF.dll"
test(1)      : ' <============= colorie une ligne, une colonne et une cellule
' ***********************
' ooooooooooooooooooooooooooooooooooooooooooooooo
' instalation des séparation pour la grille
for x=1 to 2
scene2d 11+x
top 11+x,top(1):height 11+x,height(1)-1
width 11+x,3: left 11+x,left(1)+(141*x)+1
next x
for x=1 to 2
scene2d 15+x
left 15+x,left(1): width 15+x,width(1)-1
height 15+x,3: top 15+x,top(1)+(141*x)+1
next x
' ooooooooooooooooooooooooooooooooooooooooooooooo

button 2          :alpha 22
left 2,460        :left 22,500
top 2,20          :top 22,20
width 2,31        :width 22,10
caption 2,"1"
on_click 2,choix

button 3          :alpha 23
left 3,460        :left 23,500
top 3,60          :top 23,60
width 3,30        :width 23,10
caption 3,"2"
on_click 3,choix1

button 4          :alpha 24
left 4,460        :left 24,500
top 4,100          :top 24,103
width 4,30        :width 24,10
caption 4,"3"
on_click 4,choix2

button 5          :alpha 25
left 5,460        :left 25,500
top 5,140          :top 25,143
width 5,30        :width 25,10
caption 5,"4"
on_click 5,choix3

button 6          :alpha 26
left 6,460        :left 26,500
top 6,180          :top 26,183
width 6,30        :width 26,10
caption 6,"5"
on_click 6,choix4

button 7          :alpha 27
left 7,460        :left 27,500
top 7,220          :top 27,223
width 7,30        :width 27,10
caption 7,"6"
on_click 7,choix5

button 8          :alpha 28
left 8,460        :left 28,500
top 8,260          :top 28,263
width 8,30        :width 28,10
caption 8,"7"
on_click 8,choix6

button 9          :alpha 29
left 9,460        :left 29,500
top 9,300          :top 29,303
width 9,30        :width 29,10
caption 9,"8"
on_click 9,choix7

button 10          :alpha 30
left 10,460        :left 30,500
top 10,340        :top 30,343
width 10,30        :width 30,10
caption 10,"9"
on_click 10,choix8

gosub tri
end

' triage des chiffres
tri:
for x=1 to 9
trie:
y=int(rnd(9))+1
if suite$(1,y)=""
suite$(1,y)=str$(x)
else
goto trie
end_if
next x
 a1$=suite$(1,1)
 a2$=suite$(1,2)
 a3$=suite$(1,3)
 a4$=suite$(1,4)
 a5$=suite$(1,5)
 a6$=suite$(1,6)
 a7$=suite$(1,7)
 a8$=suite$(1,8)
 a9$=suite$(1,9)
' ooooooooooooooooooooooooooooooo
jeux() :' initialisation de la grille
return

' jeu en lui même
choix:
 num$=caption$(2)
return
choix1:
 num$=caption$(3)
return
choix2:
 num$=caption$(4)
return
choix3:
 num$=caption$(5)
return
choix4:
 num$=caption$(6)
return
choix5:
 num$=caption$(7)
return
choix6:
 num$=caption$(8)
return
choix7:
 num$=caption$(9)
return
choix8:
 num$=caption$(10)
return

jeu:
posx%=grid_x_to_column(1,mouse_x_position(1))
posy%=grid_y_to_row(1,mouse_y_position(1))

' section des recherche des doublons par ligne, colones et section 3X3
if clicked(1)=1
 if grid_read$(1,posy%,posx%)<>"" then return
 if num$="" then return
' doubon dans la ligne
 for x=2 to 10
  if grid_read$(1,posy%,x)="  "+num$
  message "DOUBLON "+num$+"  C"+str$(posy%)+"  L"+str$(x)
  return
  end_if
 next x
' Doublon dans la colone
 for y=2 to 10
  if grid_read$(1,y,posx%)="  "+num$
  message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(posx%)
  return
  end_if
 next y

 if posx%>1 and posx%<5
 if posy%>1 and posy%<5
    for x=2 to 4
    for y=2 to 4
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>4 and posx%<8
 if posy%>1 and posy%<5
    for x=5 to 7
    for y=2 to 4
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>7 and posx%<11
 if posy%>1 and posy%<5
    for x=8 to 10
    for y=2 to 4
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>1 and posx%<5
 if posy%>4 and posy%<8
    for x=2 to 4
    for y=5 to 7
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>4 and posx%<8
 if posy%>4 and posy%<8
    for x=5 to 7
    for y=5 to 7
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>7 and posx%<11
 if posy%>4 and posy%<8
    for x=8 to 10
    for y=5 to 7
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>1 and posx%<5
 if posy%>7 and posy%<11
    for x=2 to 4
    for y=8 to 10
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>4 and posx%<8
 if posy%>7 and posy%<11
    for x=5 to 7
    for y=8 to 10
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>7 and posx%<11
 if posy%>7 and posy%<11
    for x=8 to 10
    for y=8 to 10
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

end_if
grid_write 1,posy%,posx%,"  "+num$

 ' mise a jour des compteur
if num$="1" then num1%=num1%+1 : caption 22,str$(num1%)
if num$="2" then num2%=num2%+1 : caption 23,str$(num2%)
if num$="3" then num3%=num3%+1 : caption 24,str$(num3%)
if num$="4" then num4%=num4%+1 : caption 25,str$(num4%)
if num$="5" then num5%=num5%+1 : caption 26,str$(num5%)
if num$="6" then num6%=num6%+1 : caption 27,str$(num6%)
if num$="7" then num7%=num7%+1 : caption 28,str$(num7%)
if num$="8" then num8%=num8%+1 : caption 29,str$(num8%)
if num$="9" then num9%=num9%+1 : caption 30,str$(num9%)

' neutralise si une des séries est complétées
if caption$(22)="9"
inactive 2
inactive 22
end_if
if caption$(23)="9"
inactive 3
inactive 23
end_if
if caption$(24)="9"
inactive 4
inactive 24
end_if
if caption$(25)="9"
inactive 5
inactive 25
end_if
if caption$(26)="9"
inactive 6
inactive 26
end_if
if caption$(27)="9"
inactive 7
inactive 27
end_if
if caption$(28)="9"
inactive 8
inactive 28
end_if
if caption$(29)="9"
inactive 9
inactive 29
end_if
if caption$(30)="9"
inactive 10
inactive 30
end_if

return
' ooooooooooooooooooooooooooooooooooooooooooooo

' initialisation de la grille
sub jeux()
gride1$ =a1$+a2$+a3$+a4$+a5$+a6$+a7$+a8$+a9$
gride2$ =a7$+a6$+a9$+a3$+a8$+a1$+a2$+a5$+a4$
gride3$ =a4$+a5$+a8$+a9$+a7$+a2$+a3$+a1$+a6$
gride4$ =a9$+a3$+a4$+a5$+a1$+a7$+a6$+a2$+a8$
gride5$ =a2$+a1$+a6$+a8$+a9$+a3$+a4$+a7$+a5$
gride6$ =a8$+a7$+a5$+a6$+a2$+a4$+a1$+a9$+a3$
gride7$ =a6$+a9$+a7$+a1$+a4$+a5$+a8$+a3$+a2$
gride8$ =a3$+a8$+a1$+a2$+a6$+a9$+a5$+a4$+a7$
gride9$ =a5$+a4$+a2$+a7$+a3$+a8$+a9$+a6$+a1$

for x=1 to 9
grid_write 1,2,x+1,"  "+mid$(gride1$,x,1)
y=int(rnd(2)):if y=0 then grid_write 1,2,x+1,""

grid_write 1,3,x+1,"  "+mid$(gride2$,x,1)
y=int(rnd(2)):if y=0 then grid_write 1,3,x+1,""

grid_write 1,4,x+1,"  "+mid$(gride3$,x,1)
y=int(rnd(1)):if y=0 then grid_write 1,4,x+1,""

grid_write 1,5,x+1,"  "+mid$(gride4$,x,1)
y=int(rnd(2)):if y=0 then grid_write 1,5,x+1,""

grid_write 1,6,x+1,"  "+mid$(gride5$,x,1)
y=int(rnd(2)):if y=0 then grid_write 1,6,x+1,""

grid_write 1,7,x+1,"  "+mid$(gride6$,x,1)
y=int(rnd(1)):if y=0 then grid_write 1,7,x+1,""

grid_write 1,8,x+1,"  "+mid$(gride7$,x,1)
y=int(rnd(2)):if y=0 then grid_write 1,8,x+1,""

grid_write 1,9,x+1,"  "+mid$(gride8$,x,1)
y=int(rnd(2)):if y=0 then grid_write 1,9,x+1,""

grid_write 1,10,x+1,"  "+mid$(gride9$,x,1)
y=int(rnd(1)):if y=0 then grid_write 1,10,x+1,""

next x
comptage()
end_sub

sub comptage()
for x=2 to 10
for y=2 to 10
if grid_read$(1,y,x)="  1" then num1%=num1%+1 : caption 22,str$(num1%)
if grid_read$(1,y,x)="  2" then num2%=num2%+1 : caption 23,str$(num2%)
if grid_read$(1,y,x)="  3" then num3%=num3%+1 : caption 24,str$(num3%)
if grid_read$(1,y,x)="  4" then num4%=num4%+1 : caption 25,str$(num4%)
if grid_read$(1,y,x)="  5" then num5%=num5%+1 : caption 26,str$(num5%)
if grid_read$(1,y,x)="  6" then num6%=num6%+1 : caption 27,str$(num6%)
if grid_read$(1,y,x)="  7" then num7%=num7%+1 : caption 28,str$(num7%)
if grid_read$(1,y,x)="  8" then num8%=num8%+1 : caption 29,str$(num8%)
if grid_read$(1,y,x)="  9" then num9%=num9%+1 : caption 30,str$(num9%)
next y
next x
end_sub

sub test(ng%)
  ' remplacer ONDRAWCELL
  res% = dll_call6("GridFunction",object_internal(1),8,1,0,0,0)

  ' changer la couleur d'une colonne
  RGB(255,255,255)  : ' écriture blanche
  FRGB% = RGB%
  RGB(255,0,0)    : ' fond rouge
  res% = dll_call6("GridFunction",object_internal(1),4,2,0,RGB%,FRGB%)

  ' changer la couleur d'une ligne
  RGB(255,255,0)  : ' écriture jaune
  FRGB% = RGB%
  RGB(0,0,255)    : ' fond bleu
  res% = dll_call6("GridFunction",object_internal(1),3,0,3,RGB%,FRGB%)

  ' changer la couleur d'une cellule
  RGB(0,0,255)  : ' écriture bleue
  FRGB% = RGB%
  RGB(255,255,0)  : ' fond jaune
  res% = dll_call6("GridFunction",object_internal(1),2,2,3,RGB%,FRGB%)

end_sub

sub RGB(R%,G%,B%) : ' produire une valeur RGB valide
 RGB% = (B%*256+R%)*256+G%
end_sub
A toi de voir ce que tu peux en faire, en choisissant tes zones à colorier, et les couleurs appropriées.
Revenir en haut Aller en bas
http://klauspanoramic.comxa.com/index.html
pascal10000

pascal10000


Nombre de messages : 812
Localisation : Troyes
Date d'inscription : 05/02/2011

un p'tit sudoku a resoudre Empty
MessageSujet: Re: un p'tit sudoku a resoudre   un p'tit sudoku a resoudre EmptyLun 19 Oct 2015 - 0:56

merci klaus je vais testé ça
Revenir en haut Aller en bas
pascal10000

pascal10000


Nombre de messages : 812
Localisation : Troyes
Date d'inscription : 05/02/2011

un p'tit sudoku a resoudre Empty
MessageSujet: Re: un p'tit sudoku a resoudre   un p'tit sudoku a resoudre EmptyLun 19 Oct 2015 - 7:23

klaus
Sa ne va pas lorsque je clic sur une case le caractère
se réduit et lorsque je change de case, la case se met par
défaut

un p'tit sudoku a resoudre Captur18
Revenir en haut Aller en bas
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

un p'tit sudoku a resoudre Empty
MessageSujet: Re: un p'tit sudoku a resoudre   un p'tit sudoku a resoudre EmptyLun 19 Oct 2015 - 9:03

Tu peux aussi piocher des idées dans les Sudoku qui avaient était fait au préalable entre autre pour résoudre les Sudoku: voir le post Lien qui contient au début les liens vers les sujets.

Bonne journée et j'ai hâte de tester ta version qui réactualisera un peu le sujet et une nouvelle approche est toujours intéressante Wink
Revenir en haut Aller en bas
pascal10000

pascal10000


Nombre de messages : 812
Localisation : Troyes
Date d'inscription : 05/02/2011

un p'tit sudoku a resoudre Empty
MessageSujet: Re: un p'tit sudoku a resoudre   un p'tit sudoku a resoudre EmptyLun 19 Oct 2015 - 10:27

bjr a tous
le p'tit bug est résolu comme je
le voulais

un p'tit sudoku a resoudre Captur19


Revenir en haut Aller en bas
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

un p'tit sudoku a resoudre Empty
MessageSujet: Re: un p'tit sudoku a resoudre   un p'tit sudoku a resoudre EmptyLun 19 Oct 2015 - 10:53

J'espère que je n'ai pas répondu à côté de la plaque comme je lis vite fait depuis le bureau, mais je testerais ce soir.
Revenir en haut Aller en bas
Jean Claude

Jean Claude


Nombre de messages : 5948
Age : 69
Localisation : 83 Var
Date d'inscription : 07/05/2009

un p'tit sudoku a resoudre Empty
MessageSujet: Re: un p'tit sudoku a resoudre   un p'tit sudoku a resoudre EmptyLun 19 Oct 2015 - 11:38

Bonjour à tous,

@Pascal1000,
Pourrais-tu donner le code à jour SVP ?

Heu... il vaudrait mieux que tu corriges l'erreur de frappe caption 0,"Sodoku" par caption 0,"Sudoku" Wink

A+
Revenir en haut Aller en bas
pascal10000

pascal10000


Nombre de messages : 812
Localisation : Troyes
Date d'inscription : 05/02/2011

un p'tit sudoku a resoudre Empty
MessageSujet: Re: un p'tit sudoku a resoudre   un p'tit sudoku a resoudre EmptyLun 19 Oct 2015 - 18:54

ok j claude caption est modifié

j claude croit tu que ça vaut le coup de continuer
a exposé le source du jeu tu est le seul avec Jicehel
qui c'est manifesté et aucune autre réaction à part
l'aimable klaus qui propose ses conseils et qui est tjr
présent pour aidé chacun de nous
moi perso c'est pour m'occupé que je programme  sinon
je peut prendre une autre distraction ça ne me dérangera
pas, avoue que c'est un peu vexant de consacré du temps
et a donner des astuces découverte par mes soins et de proposé
mes idées
enfin c'est comme ça allez bonne soirée
ps: je remerci a klaus pour sont aide
Revenir en haut Aller en bas
Minibug

Minibug


Nombre de messages : 4566
Age : 57
Localisation : Vienne (86)
Date d'inscription : 09/02/2012

un p'tit sudoku a resoudre Empty
MessageSujet: Re: un p'tit sudoku a resoudre   un p'tit sudoku a resoudre EmptyLun 19 Oct 2015 - 20:27

Salut Pascal !

Comme on l'a déjà dit a plusieurs reprises, c'est pas parce qu'on n'intervient pas qu'on n'est pas intéressé !

Je sais comme tu dit c'est parfois frustrant de ne pas avoir de réponse mais sache qu'il y a toujours quelqu'un que ça intéresse !

Et puis peu importe si tu fais cela pour le plaisir, alors tu n'a besoin de rien d'autre... Wink
Revenir en haut Aller en bas
http://gpp.panoramic.free.fr
Jean Claude

Jean Claude


Nombre de messages : 5948
Age : 69
Localisation : 83 Var
Date d'inscription : 07/05/2009

un p'tit sudoku a resoudre Empty
MessageSujet: Re: un p'tit sudoku a resoudre   un p'tit sudoku a resoudre EmptyLun 19 Oct 2015 - 20:29

@Pascal10000,

tu dis:
Citation :
j claude croit tu que ça vaut le coup de continuer
a exposé le source du jeu tu est le seul avec Jicehel
qui c'est manifesté et aucune autre réaction à part
l'aimable klaus qui propose ses conseils et qui est tjr
présent pour aidé chacun de nous

çà vaut toujours le coup, J'ai publié récemment des trucs auxquels je n'ai pas eu de retour mais je suis certain qu'ils ont été vus et que des Panoramiciens en ont profité.
EX: https://panoramic.1fr1.net/t4471-indexer-une-saisie-en-vue-d-un-classement

De toutes façons, ce n'est pas facile de répondre à tous pour plein de raisons valables (ou pas)

Ne soit pas bougon, reste optimiste.... Very Happy

A+
Revenir en haut Aller en bas
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

un p'tit sudoku a resoudre Empty
MessageSujet: Re: un p'tit sudoku a resoudre   un p'tit sudoku a resoudre EmptyLun 19 Oct 2015 - 22:05

oui et moi, j'ai environ une heure pour tester le soir et j'aurais voulu tester ta version terminée, mais comme tu ne l'a pas publier, je reste sur ma faim. Ça aurait certainement était intéressant et probablement amusant (ça fait quelques temps déjà que je ne me suis pas refait un Sudoku).
Après on aurait peut être réagit, proposé une amélioration (ou pas) ou fait des commentaire, conspué le programme ou le loué, mais tout cela reste des conjectures tant que tu ne postes pas le source Wink

Bon, j'en fais un peu beaucoup là, je dramatise un peu le débat, mais le plus important c'est que tu es envie de programmer et de créer des programmes (la différence est un peu subtile). Si tu souhaites les partager, tu peux demander à avoir des commentaires ou au contraire à ne pas en avoir. C'est toi qui choisit. Have fun, programmes et partages si tu en as envie.
Revenir en haut Aller en bas
pascal10000

pascal10000


Nombre de messages : 812
Localisation : Troyes
Date d'inscription : 05/02/2011

un p'tit sudoku a resoudre Empty
MessageSujet: Re: un p'tit sudoku a resoudre   un p'tit sudoku a resoudre EmptyMar 20 Oct 2015 - 8:42

voici la version finale du sudoku comme vous me l'avez demandé

une chose que je comprend pas c'est la commande rnd()
je trouve quelle chahute
z%=int(rnd(1)):if z%=0 then grid_write 1,6,x+1,""
cette ligne envoies toujours une ligne vide et ce n'est pas logique
elle devrais au moin donné une réponse 1 pour donné une case pleine
et j'ai tout essayé et rien n'y fait
je trouve ça bizarre mais bon je n'ai pas reçu de bug a cette version
bon jeu

ps: ne chercher pas d’algorithme pour le triage, les nombres
sont prédéfini j'aurai bien voulu en trouver un mais c'est
pas évident

Code:
dim key,jeux$,num$
dim a1$,a2$,a3$,a4$,a5$,a6$,a7$,a8$,a9$,x,y,z%,posx%,posy%
dim num1%,num2%,num3%,num4%,num5%,num6%,num7%,num8%,num9%,num%
dim suite$(1,9),gride1$,gride2$,gride3$,gride4$,gride5$,gride6$,gride7$,gride8$,gride9$
dim  RGB% ,B%,R%,G%,FRGB%,res%,font$

label tri,trie,choix,nouveau,quitter
label choix1,choix2,choix3,choix4,choix5,choix6,choix7,choix8,jeu

num%=0
num$=""
num1%=0: num2%=0: num3%=0: num4%=0: num5%=0: num6%=0: num7%=0: num8%=0: num9%=0

font$="arial.ttf"
num$=""
left 0,520
top 0,235
width 0,590
height 0,492
caption 0,"Sudoku"
font_name 0,"arial"
font_size 0,10

grid 1
left 1,10
top 1,10
width 1,428
height 1,428
grid_row 1,10: grid_column 1,10
grid_column_width 1,(465/10): grid_one_column_width 1,1,0.01
grid_row_height 1,(465/10): grid_one_row_height 1,1,0.01
font_color 1,255,0,0
font_size 1,20
on_click 1,jeu
' ooooooooooooooooooooooooooooooooooooooooooooooo
' instalation des séparation pour la grille
for x=1 to 2
scene2d 11+x
top 11+x,top(1):height 11+x,height(1)-1
width 11+x,3: left 11+x,left(1)+(141*x)+1
next x
for x=1 to 2
scene2d 15+x
left 15+x,left(1): width 15+x,width(1)-1
height 15+x,3: top 15+x,top(1)+(141*x)+1
next x
' ooooooooooooooooooooooooooooooooooooooooooooooo

button 2          :alpha 22
left 2,460        :left 22,500
top 2,20          :top 22,20
width 2,31        :width 22,10
caption 2,"1"      :caption 22,"0"
on_click 2,choix

button 3          :alpha 23
left 3,460        :left 23,500
top 3,60          :top 23,60
width 3,30        :width 23,10
caption 3,"2"      :caption 23,"0"
on_click 3,choix1

button 4          :alpha 24
left 4,460        :left 24,500
top 4,100          :top 24,103
width 4,30        :width 24,10
caption 4,"3"      :caption 24,"0"
on_click 4,choix2

button 5          :alpha 25
left 5,460        :left 25,500
top 5,140          :top 25,143
width 5,30        :width 25,10
caption 5,"4"      :caption 25,"0"
on_click 5,choix3

button 6          :alpha 26
left 6,460        :left 26,500
top 6,180          :top 26,183
width 6,30        :width 26,10
caption 6,"5"      :caption 26,"0"
on_click 6,choix4

button 7          :alpha 27
left 7,460        :left 27,500
top 7,220          :top 27,223
width 7,30        :width 27,10
caption 7,"6"      :caption 27,"0"
on_click 7,choix5

button 8          :alpha 28
left 8,460        :left 28,500
top 8,260          :top 28,263
width 8,30        :width 28,10
caption 8,"7"      :caption 28,"0"
on_click 8,choix6

button 9          :alpha 29
left 9,460        :left 29,500
top 9,300          :top 29,303
width 9,30        :width 29,10
caption 9,"8"      :caption 29,"0"
on_click 9,choix7

button 10          :alpha 30
left 10,460        :left 30,500
top 10,340        :top 30,343
width 10,30        :width 30,10
caption 10,"9"    :caption 30,"0"
on_click 10,choix8

button 31
left 31,460
top 31,380
caption 31,"Annuler"
label Annuler : on_click 31,Annuler

button 33
left 33,460
top 33,410
caption 33,"Option v"
label optio : on_click 33,optio

form 40
border_hide 40
width 40,75 :height 40,38
left 40,470+left(0):top 40,465+top(0)
to_foreground 40
hide 40
command_target_is 40
main_menu 41
sub_menu 42:parent 42,41:caption 42,"nouveau jeu"
on_click 42,nouveau
sub_menu 43:parent 43,41:caption 43,"Quitter          "
on_click 43,quitter

dll_on "KGF.dll"
  res% = dll_call6("GridFunction",object_internal(1),5,1,0,0,0)
gosub tri
end

' triage des chiffres
tri:
for x=1 to 9
trie:
y=int(rnd(9))+1
if suite$(1,y)=""
suite$(1,y)=str$(x)
else
goto trie
end_if
next x
 a1$=suite$(1,1)
 a2$=suite$(1,2)
 a3$=suite$(1,3)
 a4$=suite$(1,4)
 a5$=suite$(1,5)
 a6$=suite$(1,6)
 a7$=suite$(1,7)
 a8$=suite$(1,8)
 a9$=suite$(1,9)
' ooooooooooooooooooooooooooooooo
jeux() :' initialisation de la grille
return

' jeu en lui même
choix:
 num$=caption$(2)
return
choix1:
 num$=caption$(3)
return
choix2:
 num$=caption$(4)
return
choix3:
 num$=caption$(5)
return
choix4:
 num$=caption$(6)
return
choix5:
 num$=caption$(7)
return
choix6:
 num$=caption$(8)
return
choix7:
 num$=caption$(9)
return
choix8:
 num$=caption$(10)
return

jeu:
posx%=grid_x_to_column(1,mouse_x_position(1))
posy%=grid_y_to_row(1,mouse_y_position(1))

' section des recherche des doublons par ligne, colones et section 3X3
if clicked(1)=1
 if grid_read$(1,posy%,posx%)<>"" then return
 if num$="" then return
' doubon dans la ligne
 for x=2 to 10
  if grid_read$(1,posy%,x)="  "+num$
  message "DOUBLON "+num$+"  C"+str$(posy%)+"  L"+str$(x)
  return
  end_if
 next x
' Doublon dans la colone
 for y=2 to 10
  if grid_read$(1,y,posx%)="  "+num$
  message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(posx%)
  return
  end_if
 next y
' Doublon dans les section 3X3
 if posx%>1 and posx%<5
 if posy%>1 and posy%<5
    for x=2 to 4
    for y=2 to 4
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>4 and posx%<8
 if posy%>1 and posy%<5
    for x=5 to 7
    for y=2 to 4
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>7 and posx%<11
 if posy%>1 and posy%<5
    for x=8 to 10
    for y=2 to 4
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>1 and posx%<5
 if posy%>4 and posy%<8
    for x=2 to 4
    for y=5 to 7
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>4 and posx%<8
 if posy%>4 and posy%<8
    for x=5 to 7
    for y=5 to 7
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>7 and posx%<11
 if posy%>4 and posy%<8
    for x=8 to 10
    for y=5 to 7
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>1 and posx%<5
 if posy%>7 and posy%<11
    for x=2 to 4
    for y=8 to 10
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>4 and posx%<8
 if posy%>7 and posy%<11
    for x=5 to 7
    for y=8 to 10
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>7 and posx%<11
 if posy%>7 and posy%<11
    for x=8 to 10
    for y=8 to 10
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

end_if
test()
grid_write 1,posy%,posx%,num$

 ' mise a jour des compteur
if num$="1" then num1%=num1%+1 : caption 22,str$(num1%)
if num$="2" then num2%=num2%+1 : caption 23,str$(num2%)
if num$="3" then num3%=num3%+1 : caption 24,str$(num3%)
if num$="4" then num4%=num4%+1 : caption 25,str$(num4%)
if num$="5" then num5%=num5%+1 : caption 26,str$(num5%)
if num$="6" then num6%=num6%+1 : caption 27,str$(num6%)
if num$="7" then num7%=num7%+1 : caption 28,str$(num7%)
if num$="8" then num8%=num8%+1 : caption 29,str$(num8%)
if num$="9" then num9%=num9%+1 : caption 30,str$(num9%)

' neutralise si une des séries est complétées
if caption$(22)="9"
inactive 2
inactive 22
num%=num%+1
end_if
if caption$(23)="9"
inactive 3
inactive 23
num%=num%+1
end_if
if caption$(24)="9"
inactive 4
inactive 24
num%=num%+1
end_if
if caption$(25)="9"
inactive 5
inactive 25
num%=num%+1
end_if
if caption$(26)="9"
inactive 6
inactive 26
num%=num%+1
end_if
if caption$(27)="9"
inactive 7
inactive 27
num%=num%+1
end_if
if caption$(28)="9"
inactive 8
inactive 28
num%=num%+1
end_if
if caption$(29)="9"
inactive 9
inactive 29
num%=num%+1
end_if
if caption$(30)="9"
inactive 10
inactive 30
num%=num%+1
end_if
if num%=9 then message "Grille résolu bravo"+chr$(10)+"Vous avez gagné"
num%=0
return

quitter:
res% = dll_call1("KillProcessByHandle",handle(0))
dll_off
return

Annuler:
if grid_read$(1,posy%,posx%)="1"
 num1%=num1%-1 : caption 22,str$(num1%)
end_if
if grid_read$(1,posy%,posx%)="2"
 num2%=num2%-1 : caption 23,str$(num2%)
end_if
if grid_read$(1,posy%,posx%)="3"
 num3%=num3%-1 : caption 24,str$(num3%)
end_if
if grid_read$(1,posy%,posx%)="4"
 num4%=num4%-1 : caption 25,str$(num4%)
end_if
if grid_read$(1,posy%,posx%)="5"
 num5%=num5%-1 : caption 26,str$(num5%)
end_if
if grid_read$(1,posy%,posx%)="6"
 num6%=num6%-1 : caption 27,str$(num6%)
end_if
if grid_read$(1,posy%,posx%)="7"
 num7%=num7%-1 : caption 28,str$(num7%)
end_if
if grid_read$(1,posy%,posx%)="8"
 num8%=num8%-1 : caption 29,str$(num8%)
end_if
if grid_read$(1,posy%,posx%)="9"
 num9%=num9%-1 : caption 30,str$(num9%)
end_if
  grid_write 1,posy%,posx%,""
return

optio:
show 40
return

nouveau:
' obligé de faire cette commande pour éffacer la grille
hide 40
for x=2 to 10
for y=2 to 10
  grid_write 1,x,y,""
next y
next x
wait 1000
free suite$(1,9)
dim suite$(1,9)
gosub tri
return

' ooooooooooooooooooooooooooooooooooooooooooooo

' initialisation de la grille
sub jeux()
gride1$ =a1$+a2$+a3$+a4$+a5$+a6$+a7$+a8$+a9$
gride2$ =a7$+a6$+a9$+a3$+a8$+a1$+a2$+a5$+a4$
gride3$ =a4$+a5$+a8$+a9$+a7$+a2$+a3$+a1$+a6$
gride4$ =a9$+a3$+a4$+a5$+a1$+a7$+a6$+a2$+a8$
gride5$ =a2$+a1$+a6$+a8$+a9$+a3$+a4$+a7$+a5$
gride6$ =a8$+a7$+a5$+a6$+a2$+a4$+a1$+a9$+a3$
gride7$ =a6$+a9$+a7$+a1$+a4$+a5$+a8$+a3$+a2$
gride8$ =a3$+a8$+a1$+a2$+a6$+a9$+a5$+a4$+a7$
gride9$ =a5$+a4$+a2$+a7$+a3$+a8$+a9$+a6$+a1$

for x=1 to 9
z%=int(rnd(1))
grid_write 1,2,x+1,"  "+mid$(gride1$,x,1)
z%=int(rnd(2)):if z%=0 then grid_write 1,2,x+1,""

grid_write 1,3,x+1,"  "+mid$(gride2$,x,1)
z%=int(rnd(2)):if z%=0 then grid_write 1,3,x+1,""

grid_write 1,4,x+1,"  "+mid$(gride3$,x,1)
z%=int(rnd(2)):if z%=0 then grid_write 1,4,x+1,""

grid_write 1,5,x+1,"  "+mid$(gride4$,x,1)
z%=int(rnd(2)):if z%=0 then grid_write 1,5,x+1,""

grid_write 1,6,x+1,"  "+mid$(gride5$,x,1)
z%=int(rnd(1)):if z%=0 then grid_write 1,6,x+1,""

grid_write 1,7,x+1,"  "+mid$(gride6$,x,1)
z%=int(rnd(2)):if z%=0 then grid_write 1,7,x+1,""

grid_write 1,8,x+1,"  "+mid$(gride7$,x,1)
z%=int(rnd(2)):if z%=0 then grid_write 1,8,x+1,""

grid_write 1,9,x+1,"  "+mid$(gride8$,x,1)
z%=int(rnd(2)):if z%=0 then grid_write 1,9,x+1,""

grid_write 1,10,x+1,"  "+mid$(gride9$,x,1)
z%=int(rnd(2)):if z%=0 then grid_write 1,10,x+1,""
next x
comptage()
end_sub

sub comptage()
for x=2 to 10
for y=2 to 10
if grid_read$(1,y,x)="  1" then num1%=num1%+1 : caption 22,str$(num1%)
if grid_read$(1,y,x)="  2" then num2%=num2%+1 : caption 23,str$(num2%)
if grid_read$(1,y,x)="  3" then num3%=num3%+1 : caption 24,str$(num3%)
if grid_read$(1,y,x)="  4" then num4%=num4%+1 : caption 25,str$(num4%)
if grid_read$(1,y,x)="  5" then num5%=num5%+1 : caption 26,str$(num5%)
if grid_read$(1,y,x)="  6" then num6%=num6%+1 : caption 27,str$(num6%)
if grid_read$(1,y,x)="  7" then num7%=num7%+1 : caption 28,str$(num7%)
if grid_read$(1,y,x)="  8" then num8%=num8%+1 : caption 29,str$(num8%)
if grid_read$(1,y,x)="  9" then num9%=num9%+1 : caption 30,str$(num9%)
next y
next x
end_sub

sub test()
  ' Atribut du texte
  res% = dll_call6("GridFunction",object_internal(1),9,1,20,adr(font$),0)
  ' changer la couleur d'une cellule
  RGB(0,0,0)  : ' écriture noir
  FRGB% = RGB%
  RGB(255,255,255)  : ' fond blanc
  res% = dll_call6("GridFunction",object_internal(1),2,posx%-1,posy%-1,RGB%,FRGB%)
end_sub

sub RGB(R%,G%,B%) : ' produire une valeur RGB valide
 RGB% = (B%*256+R%)*256+G%
end_sub
Revenir en haut Aller en bas
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

un p'tit sudoku a resoudre Empty
MessageSujet: Re: un p'tit sudoku a resoudre   un p'tit sudoku a resoudre EmptyMar 20 Oct 2015 - 8:58

rnd(1) te donne une valeur entre 0 et 1
si tu prendsla partie entière du résultat, tu as forcément 0 (ou presque car tu peux avoir exceptionnellement 1)
si tu fais rnd(1.99), tu auras un résultat entre 0 et 1.99 par conséquent, si tu en prend la partie entière tu aura 0 ou 1
Revenir en haut Aller en bas
pascal10000

pascal10000


Nombre de messages : 812
Localisation : Troyes
Date d'inscription : 05/02/2011

un p'tit sudoku a resoudre Empty
MessageSujet: Re: un p'tit sudoku a resoudre   un p'tit sudoku a resoudre EmptyMar 20 Oct 2015 - 9:26

justement si! la commande int(rnd(1)) doit me donner la partie
entière 0 ou 1 tu comprend mais là elle m'envoie toujours 0
même sur 10 résulta il devrai prendre au moin une fois 1
puisque il prend de 0 a 1 tout en passant de 0 jusqu'a 0.99999999 et 1
quand je prend ma calculatrice les résultats sont complètement différent
la prise 0 et 1 est plus régulier elle prend au moin quatre 1 sur dix
Revenir en haut Aller en bas
Minibug

Minibug


Nombre de messages : 4566
Age : 57
Localisation : Vienne (86)
Date d'inscription : 09/02/2012

un p'tit sudoku a resoudre Empty
MessageSujet: Re: un p'tit sudoku a resoudre   un p'tit sudoku a resoudre EmptyMar 20 Oct 2015 - 10:35

Salut Pascal !

J'ai testé ton programme et j'aime beaucoup... J'ai juste quelques petites remarques a faire :

Comment se fait il que l'on peut effacer les chiffres en rouge, je pense qu'il y a un problème...
D'autre part, lorsque tous les '2' (par exemples) sont supprimés et que l'on 'annule' un '2' dans la grille, il n'est pas possible de la rajouter car le bouton est grisé !

Je sais, je suis un 'clickeur fou' !!
Mais j'aime ça, je peut pas m'empécher de cliquer partout.
Laughing Laughing Laughing Laughing
Revenir en haut Aller en bas
http://gpp.panoramic.free.fr
pascal10000

pascal10000


Nombre de messages : 812
Localisation : Troyes
Date d'inscription : 05/02/2011

un p'tit sudoku a resoudre Empty
MessageSujet: Re: un p'tit sudoku a resoudre   un p'tit sudoku a resoudre EmptyMar 20 Oct 2015 - 11:11

ok je vais regarder ça je n'ai pas pensé a réactivé
au cas ou le nombre ne revenais en dessous 9
c vrai tu as raison
Revenir en haut Aller en bas
pascal10000

pascal10000


Nombre de messages : 812
Localisation : Troyes
Date d'inscription : 05/02/2011

un p'tit sudoku a resoudre Empty
MessageSujet: Re: un p'tit sudoku a resoudre   un p'tit sudoku a resoudre EmptyMar 20 Oct 2015 - 11:25

Ah j'ai oublié minibug tu me dira comment tu a fait pour effacer une
case avec un chiffre rouge normalement les cases occupées sont neutralisé
à part d'utiliser annuler dans ce cas ça devrais supprimer la dernière saisie
et mettre sa quantités à jour
Revenir en haut Aller en bas
papydall

papydall


Nombre de messages : 6985
Age : 73
Localisation : Moknine (Tunisie) Entre la chaise et le clavier
Date d'inscription : 03/03/2012

un p'tit sudoku a resoudre Empty
MessageSujet: Re: un p'tit sudoku a resoudre   un p'tit sudoku a resoudre EmptyMar 20 Oct 2015 - 12:00

Salut tout le monde
pascal10000 a écrit:
z%=int(rnd(1)):if z%=0 then grid_write 1,6,x+1,""
cette ligne envoies toujours une ligne vide et ce n'est pas logique
elle devrais au moin donné une réponse 1 pour donné une case pleine
et j'ai tout essayé et rien n'y fait

Non,Pascal :
Int(rnd(1)) doit obligatoirement renvoyer toujours 0, sinon je crierais au bug !
Pourquoi ?
C’est parce que rnd(1) fournit un nombre pseudo-aléatoire compris entre 0 (zéro) inclus et 1 EXCLU.
Autrement dit dans l’intervalle semi-ouvert à droite : [0,1[
Le plus grand nombre obtenu est 0.99999999….
Or la fonction INT(n) fournit la partie entière de n
INT(0.99999999) c’est bien 0 et non 1

Pour obtenir un nombre aléatoire 0 ou 1, tu fais
Code:

z%=int(rnd(2)):if z%=0 then grid_write 1,6,x+1,""



Pour le code je n'ai pas encore testé.
Je le ferai tout à l'heure et je te dirai ce que j'en pense.
Revenir en haut Aller en bas
http://papydall-panoramic.forumarabia.com/
pascal10000

pascal10000


Nombre de messages : 812
Localisation : Troyes
Date d'inscription : 05/02/2011

un p'tit sudoku a resoudre Empty
MessageSujet: Re: un p'tit sudoku a resoudre   un p'tit sudoku a resoudre EmptyMar 20 Oct 2015 - 13:29

résolution de la remarque de minbug

Code:
dim key,jeux$,num$
dim a1$,a2$,a3$,a4$,a5$,a6$,a7$,a8$,a9$,x,y,z%,posx%,posy%
dim num1%,num2%,num3%,num4%,num5%,num6%,num7%,num8%,num9%,num%
dim suite$(1,9),gride1$,gride2$,gride3$,gride4$,gride5$,gride6$,gride7$,gride8$,gride9$
dim  RGB% ,B%,R%,G%,FRGB%,res%,font$

label tri,trie,choix,nouveau,quitter
label choix1,choix2,choix3,choix4,choix5,choix6,choix7,choix8,jeu

num%=0
num$=""
num1%=0: num2%=0: num3%=0: num4%=0: num5%=0: num6%=0: num7%=0: num8%=0: num9%=0

font$="arial.ttf"
num$=""
left 0,520
top 0,235
width 0,590
height 0,492
caption 0,"Sudoku"
font_name 0,"arial"
font_size 0,10

grid 1
left 1,10
top 1,10
width 1,428
height 1,428
grid_row 1,10: grid_column 1,10
grid_column_width 1,(465/10): grid_one_column_width 1,1,0.01
grid_row_height 1,(465/10): grid_one_row_height 1,1,0.01
font_color 1,255,0,0
font_size 1,20
on_click 1,jeu
' ooooooooooooooooooooooooooooooooooooooooooooooo
' instalation des séparation pour la grille
for x=1 to 2
scene2d 11+x
top 11+x,top(1):height 11+x,height(1)-1
width 11+x,3: left 11+x,left(1)+(141*x)+1
next x
for x=1 to 2
scene2d 15+x
left 15+x,left(1): width 15+x,width(1)-1
height 15+x,3: top 15+x,top(1)+(141*x)+1
next x
' ooooooooooooooooooooooooooooooooooooooooooooooo

button 2          :alpha 22
left 2,460        :left 22,500
top 2,20          :top 22,20
width 2,31        :width 22,10
caption 2,"1"      :caption 22,"0"
on_click 2,choix

button 3          :alpha 23
left 3,460        :left 23,500
top 3,60          :top 23,60
width 3,30        :width 23,10
caption 3,"2"      :caption 23,"0"
on_click 3,choix1

button 4          :alpha 24
left 4,460        :left 24,500
top 4,100          :top 24,103
width 4,30        :width 24,10
caption 4,"3"      :caption 24,"0"
on_click 4,choix2

button 5          :alpha 25
left 5,460        :left 25,500
top 5,140          :top 25,143
width 5,30        :width 25,10
caption 5,"4"      :caption 25,"0"
on_click 5,choix3

button 6          :alpha 26
left 6,460        :left 26,500
top 6,180          :top 26,183
width 6,30        :width 26,10
caption 6,"5"      :caption 26,"0"
on_click 6,choix4

button 7          :alpha 27
left 7,460        :left 27,500
top 7,220          :top 27,223
width 7,30        :width 27,10
caption 7,"6"      :caption 27,"0"
on_click 7,choix5

button 8          :alpha 28
left 8,460        :left 28,500
top 8,260          :top 28,263
width 8,30        :width 28,10
caption 8,"7"      :caption 28,"0"
on_click 8,choix6

button 9          :alpha 29
left 9,460        :left 29,500
top 9,300          :top 29,303
width 9,30        :width 29,10
caption 9,"8"      :caption 29,"0"
on_click 9,choix7

button 10          :alpha 30
left 10,460        :left 30,500
top 10,340        :top 30,343
width 10,30        :width 30,10
caption 10,"9"    :caption 30,"0"
on_click 10,choix8

button 31
left 31,460
top 31,380
caption 31,"Annuler"
label Annuler : on_click 31,Annuler

button 33
left 33,460
top 33,410
caption 33,"Option v"
label optio : on_click 33,optio

form 40
border_hide 40
width 40,75 :height 40,38
left 40,470+left(0):top 40,465+top(0)
to_foreground 40
hide 40
command_target_is 40
main_menu 41
sub_menu 42:parent 42,41:caption 42,"nouveau jeu"
on_click 42,nouveau
sub_menu 43:parent 43,41:caption 43,"Quitter          "
on_click 43,quitter

dll_on "KGF.dll"
  res% = dll_call6("GridFunction",object_internal(1),5,1,0,0,0)
gosub tri
end

' triage des chiffres
tri:
for x=1 to 9
trie:
y=int(rnd(9))+1
if suite$(1,y)=""
suite$(1,y)=str$(x)
else
goto trie
end_if
next x
 a1$=suite$(1,1)
 a2$=suite$(1,2)
 a3$=suite$(1,3)
 a4$=suite$(1,4)
 a5$=suite$(1,5)
 a6$=suite$(1,6)
 a7$=suite$(1,7)
 a8$=suite$(1,8)
 a9$=suite$(1,9)
' ooooooooooooooooooooooooooooooo
jeux() :' initialisation de la grille
return

' jeu en lui même
choix:
 num$=caption$(2)
return
choix1:
 num$=caption$(3)
return
choix2:
 num$=caption$(4)
return
choix3:
 num$=caption$(5)
return
choix4:
 num$=caption$(6)
return
choix5:
 num$=caption$(7)
return
choix6:
 num$=caption$(8)
return
choix7:
 num$=caption$(9)
return
choix8:
 num$=caption$(10)
return

jeu:
posx%=grid_x_to_column(1,mouse_x_position(1))
posy%=grid_y_to_row(1,mouse_y_position(1))

' section des recherche des doublons par ligne, colones et section 3X3
if clicked(1)=1
 if grid_read$(1,posy%,posx%)<>"" then return
 if num$="" then return
' doubon dans la ligne
 for x=2 to 10
  if grid_read$(1,posy%,x)="  "+num$
  message "DOUBLON "+num$+"  C"+str$(posy%)+"  L"+str$(x)
  return
  end_if
 next x
' Doublon dans la colone
 for y=2 to 10
  if grid_read$(1,y,posx%)="  "+num$
  message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(posx%)
  return
  end_if
 next y
' Doublon dans les section 3X3
 if posx%>1 and posx%<5
 if posy%>1 and posy%<5
    for x=2 to 4
    for y=2 to 4
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>4 and posx%<8
 if posy%>1 and posy%<5
    for x=5 to 7
    for y=2 to 4
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>7 and posx%<11
 if posy%>1 and posy%<5
    for x=8 to 10
    for y=2 to 4
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>1 and posx%<5
 if posy%>4 and posy%<8
    for x=2 to 4
    for y=5 to 7
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>4 and posx%<8
 if posy%>4 and posy%<8
    for x=5 to 7
    for y=5 to 7
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>7 and posx%<11
 if posy%>4 and posy%<8
    for x=8 to 10
    for y=5 to 7
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>1 and posx%<5
 if posy%>7 and posy%<11
    for x=2 to 4
    for y=8 to 10
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>4 and posx%<8
 if posy%>7 and posy%<11
    for x=5 to 7
    for y=8 to 10
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

 if posx%>7 and posx%<11
 if posy%>7 and posy%<11
    for x=8 to 10
    for y=8 to 10
      if grid_read$(1,y,x)="  "+num$
        message "DOUBLON "+num$+"  C"+str$(y)+"  L"+str$(x)
        return
      end_if
    next y
    next x
 end_if
 end_if

end_if
test()
grid_write 1,posy%,posx%,num$

 ' mise a jour des compteur
if num$="1" then num1%=num1%+1 : caption 22,str$(num1%)
if num$="2" then num2%=num2%+1 : caption 23,str$(num2%)
if num$="3" then num3%=num3%+1 : caption 24,str$(num3%)
if num$="4" then num4%=num4%+1 : caption 25,str$(num4%)
if num$="5" then num5%=num5%+1 : caption 26,str$(num5%)
if num$="6" then num6%=num6%+1 : caption 27,str$(num6%)
if num$="7" then num7%=num7%+1 : caption 28,str$(num7%)
if num$="8" then num8%=num8%+1 : caption 29,str$(num8%)
if num$="9" then num9%=num9%+1 : caption 30,str$(num9%)

' neutralise si une des séries est complétées
if caption$(22)="9"
inactive 2
inactive 22
num%=num%+1
end_if
if caption$(23)="9"
inactive 3
inactive 23
num%=num%+1
end_if
if caption$(24)="9"
inactive 4
inactive 24
num%=num%+1
end_if
if caption$(25)="9"
inactive 5
inactive 25
num%=num%+1
end_if
if caption$(26)="9"
inactive 6
inactive 26
num%=num%+1
end_if
if caption$(27)="9"
inactive 7
inactive 27
num%=num%+1
end_if
if caption$(28)="9"
inactive 8
inactive 28
num%=num%+1
end_if
if caption$(29)="9"
inactive 9
inactive 29
num%=num%+1
end_if
if caption$(30)="9"
inactive 10
inactive 30
num%=num%+1
end_if
if num%=9 then message "Grille résolu bravo"+chr$(10)+"Vous avez gagné"
num%=0
return

quitter:
res% = dll_call1("KillProcessByHandle",handle(0))
dll_off
return

Annuler:
if grid_read$(1,posy%,posx%)="1"
 num1%=num1%-1 : caption 22,str$(num1%)
 if num1%<9 then active 2
 if num1%<9 then active 22
end_if
if grid_read$(1,posy%,posx%)="2"
 num2%=num2%-1 : caption 23,str$(num2%)
 if num2%<9 then active 3
 if num2%<9 then active 23
end_if
if grid_read$(1,posy%,posx%)="3"
 num3%=num3%-1 : caption 24,str$(num3%)
 if num3%<9 then active 4
 if num3%<9 then active 24
end_if
if grid_read$(1,posy%,posx%)="4"
 num4%=num4%-1 : caption 25,str$(num4%)
 if num4%<9 then active 5
 if num4%<9 then active 25
end_if
if grid_read$(1,posy%,posx%)="5"
 num5%=num5%-1 : caption 26,str$(num5%)
 if num5%<9 then active 6
 if num5%<9 then active 26
end_if
if grid_read$(1,posy%,posx%)="6"
 num6%=num6%-1 : caption 27,str$(num6%)
 if num6%<9 then active 7
 if num6%<9 then active 27
end_if
if grid_read$(1,posy%,posx%)="7"
 num7%=num7%-1 : caption 28,str$(num7%)
 if num7%<9 then active 8
 if num7%<9 then active 28
end_if
if grid_read$(1,posy%,posx%)="8"
 num8%=num8%-1 : caption 29,str$(num8%)
 if num8%<9 then active 9
 if num8%<9 then active 29
end_if
if grid_read$(1,posy%,posx%)="9"
 num9%=num9%-1 : caption 30,str$(num9%)
 if num9%<9 then active 10
 if num9%<9 then active 30
end_if
  grid_write 1,posy%,posx%,""

return

optio:
show 40
return

nouveau:
' obligé de faire cette commande pour éffacer la grille
hide 40
for x=2 to 10
for y=2 to 10
  grid_write 1,x,y,""
next y
next x
wait 1000
free suite$(1,9)
dim suite$(1,9)
gosub tri
return

' ooooooooooooooooooooooooooooooooooooooooooooo

' initialisation de la grille
sub jeux()
gride1$ =a1$+a2$+a3$+a4$+a5$+a6$+a7$+a8$+a9$
gride2$ =a7$+a6$+a9$+a3$+a8$+a1$+a2$+a5$+a4$
gride3$ =a4$+a5$+a8$+a9$+a7$+a2$+a3$+a1$+a6$
gride4$ =a9$+a3$+a4$+a5$+a1$+a7$+a6$+a2$+a8$
gride5$ =a2$+a1$+a6$+a8$+a9$+a3$+a4$+a7$+a5$
gride6$ =a8$+a7$+a5$+a6$+a2$+a4$+a1$+a9$+a3$
gride7$ =a6$+a9$+a7$+a1$+a4$+a5$+a8$+a3$+a2$
gride8$ =a3$+a8$+a1$+a2$+a6$+a9$+a5$+a4$+a7$
gride9$ =a5$+a4$+a2$+a7$+a3$+a8$+a9$+a6$+a1$

for x=1 to 9
z%=int(rnd(1))
grid_write 1,2,x+1,"  "+mid$(gride1$,x,1)
z%=int(rnd(2)):if z%=0 then grid_write 1,2,x+1,""

grid_write 1,3,x+1,"  "+mid$(gride2$,x,1)
z%=int(rnd(2)):if z%=0 then grid_write 1,3,x+1,""

grid_write 1,4,x+1,"  "+mid$(gride3$,x,1)
z%=int(rnd(2)):if z%=0 then grid_write 1,4,x+1,""

grid_write 1,5,x+1,"  "+mid$(gride4$,x,1)
z%=int(rnd(2)):if z%=0 then grid_write 1,5,x+1,""

grid_write 1,6,x+1,"  "+mid$(gride5$,x,1)
z%=int(rnd(1)):if z%=0 then grid_write 1,6,x+1,""

grid_write 1,7,x+1,"  "+mid$(gride6$,x,1)
z%=int(rnd(2)):if z%=0 then grid_write 1,7,x+1,""

grid_write 1,8,x+1,"  "+mid$(gride7$,x,1)
z%=int(rnd(2)):if z%=0 then grid_write 1,8,x+1,""

grid_write 1,9,x+1,"  "+mid$(gride8$,x,1)
z%=int(rnd(2)):if z%=0 then grid_write 1,9,x+1,""

grid_write 1,10,x+1,"  "+mid$(gride9$,x,1)
z%=int(rnd(2)):if z%=0 then grid_write 1,10,x+1,""
next x
comptage()
end_sub

sub comptage()
for x=2 to 10
for y=2 to 10
if grid_read$(1,y,x)="  1" then num1%=num1%+1 : caption 22,str$(num1%)
if grid_read$(1,y,x)="  2" then num2%=num2%+1 : caption 23,str$(num2%)
if grid_read$(1,y,x)="  3" then num3%=num3%+1 : caption 24,str$(num3%)
if grid_read$(1,y,x)="  4" then num4%=num4%+1 : caption 25,str$(num4%)
if grid_read$(1,y,x)="  5" then num5%=num5%+1 : caption 26,str$(num5%)
if grid_read$(1,y,x)="  6" then num6%=num6%+1 : caption 27,str$(num6%)
if grid_read$(1,y,x)="  7" then num7%=num7%+1 : caption 28,str$(num7%)
if grid_read$(1,y,x)="  8" then num8%=num8%+1 : caption 29,str$(num8%)
if grid_read$(1,y,x)="  9" then num9%=num9%+1 : caption 30,str$(num9%)
next y
next x
end_sub

sub test()
  ' Atribut du texte
  res% = dll_call6("GridFunction",object_internal(1),9,1,20,adr(font$),0)
  ' changer la couleur d'une cellule
  RGB(0,0,0)  : ' écriture noir
  FRGB% = RGB%
  RGB(255,255,255)  : ' fond blanc
  res% = dll_call6("GridFunction",object_internal(1),2,posx%-1,posy%-1,RGB%,FRGB%)
end_sub

sub RGB(R%,G%,B%) : ' produire une valeur RGB valide
 RGB% = (B%*256+R%)*256+G%
end_sub

papydall
c sur qu'il a une chance sur un million de trouver 1
n'oublie pas qu'un ordinateur c'est c.. et que sur 10
il est obligatoire a ce qu'il le trouve ne serai ce deux foix sur dix tirage
Revenir en haut Aller en bas
Minibug

Minibug


Nombre de messages : 4566
Age : 57
Localisation : Vienne (86)
Date d'inscription : 09/02/2012

un p'tit sudoku a resoudre Empty
MessageSujet: Re: un p'tit sudoku a resoudre   un p'tit sudoku a resoudre EmptyMar 20 Oct 2015 - 14:05

Pascal, j'ai refais un test et j'ai toujours quelques soucis :

Les chiffres rouges peuvent toujours être supprimés par la touche 'annuler'
Je pense que tu devrai remplir une variables du style case(x,y) et mettre a 0 ou 1 selon si le chiffre est sélectionnable ou pas. puis faire un test lorsque l'on clic sur la case pour savoir si tu efface ou non le nombre.

Seconde remarque, j'ai réussi a avoir 2 fois le même chiffre dans un carré, c'est pas normal ! No drunken scratch

j'utilise juste la souris, le bouton 'annuler', je clic sur le numéro que je souhaite positionner, puis je clique sur la case a saisir. rien de bizarre dans ma façon de faire pourtant ? !!
Revenir en haut Aller en bas
http://gpp.panoramic.free.fr
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

un p'tit sudoku a resoudre Empty
MessageSujet: Re: un p'tit sudoku a resoudre   un p'tit sudoku a resoudre EmptyMar 20 Oct 2015 - 14:18

Pascal1000, je pense que tu te méprend.

Papydall a raison. Il n'y à pas dix possibilité mais bien des millions entre 0 et 1. Il a autant de chance de sortir 0.99999999999 que 0.99999999998 ou 0.9 ou 0.99 ou 0.23548 ou 0.1478921 ou 0.11114579 ou 0.2

La probabilité de sortir 1 est infinitésimale. Si tu veux avoir autant de chance d'avoir 0 que 1 tu dois faire rnd(2)
si tu veux avoir une chance sur 10 de sortir un 0 tu dois faire rend(10) (pour que ton int te retourne 0,1,2,3,4,5,6,7,8 ou 9) la chance d'avoir un 10 étant infinitésimale.)
Revenir en haut Aller en bas
papydall

papydall


Nombre de messages : 6985
Age : 73
Localisation : Moknine (Tunisie) Entre la chaise et le clavier
Date d'inscription : 03/03/2012

un p'tit sudoku a resoudre Empty
MessageSujet: Re: un p'tit sudoku a resoudre   un p'tit sudoku a resoudre EmptyMar 20 Oct 2015 - 14:45

pascal10000 a écrit:
papydall
c sur qu'il a une chance sur un million de trouver 1
n'oublie pas qu'un ordinateur c'est c.. et que sur 10
il est obligatoire a ce qu'il le trouve ne serai ce deux foix sur dix tirage

Non, il ne trouvera JAMAIS !!
Et si par miracle, ça arriverait, je jetterais mon PC par la fenêtre pour en procurer un qui saura se conformer à exécuter l’algorithme qu’on lui avait donné sans faire à sa guise.

Le générateur des nombres pseudo-aléatoires est programmé pour donner des nombres compris entre 0 et 0.9999999999….
Il ne doit en aucun cas atteindre la valeur 1.
C’est clair pour moi.
Libre à quiconque de penser le contraire.
Revenir en haut Aller en bas
http://papydall-panoramic.forumarabia.com/
silverman

silverman


Nombre de messages : 968
Age : 51
Localisation : Picardie
Date d'inscription : 18/03/2015

un p'tit sudoku a resoudre Empty
MessageSujet: Re: un p'tit sudoku a resoudre   un p'tit sudoku a resoudre EmptyMar 20 Oct 2015 - 15:18

Bonjour,

@pascal10000
nb:tu as des z%=int(rnd(1)) mélangés avec des z%=int(rnd(2))
Ta logique de départ est bonne, mais tu n'as pas besoin de int(), puisque z% est un entier que panoramic arrondi si tu lui colle un nombre à virgule.
Donc:
z%=rnd(1)
te retournera des valeurs entre 0 et 1.
Revenir en haut Aller en bas
papydall

papydall


Nombre de messages : 6985
Age : 73
Localisation : Moknine (Tunisie) Entre la chaise et le clavier
Date d'inscription : 03/03/2012

un p'tit sudoku a resoudre Empty
MessageSujet: Re: un p'tit sudoku a resoudre   un p'tit sudoku a resoudre EmptyMar 20 Oct 2015 - 15:38

Pourquoi ce GOTO ?
Code:

' triage des chiffres
tri:
for x=1 to 9
trie:
y=int(rnd(9))+1
if suite$(1,y)=""
suite$(1,y)=str$(x)
else
goto trie
end_if
next x
 a1$=suite$(1,1)
 a2$=suite$(1,2)
 a3$=suite$(1,3)
 a4$=suite$(1,4)
 a5$=suite$(1,5)
 a6$=suite$(1,6)
 a7$=suite$(1,7)
 a8$=suite$(1,8)
 a9$=suite$(1,9)
' ooooooooooooooooooooooooooooooo
jeux() :' initialisation de la grille
return

C’est très facile de l’oublier à jamais !
Code:

for x = 1 to 9
        repeat
            y = int(rnd(9))+1
        until suite$(1,y) = ""
          suite$(1,y) = str$(x)
        y = int(rnd(9))+1
    next x
    a1$ = suite$(1,1)
    a2$ = suite$(1,2)
    a3$ = suite$(1,3)
    a4$ = suite$(1,4)
    a5$ = suite$(1,5)
    a6$ = suite$(1,6)
    a7$ = suite$(1,7)
    a8$ = suite$(1,8)
    a9$ = suite$(1,9)

Cette série de choix

Code:

' jeu en lui même
choix:
 num$=caption$(2)
return
choix1:
 num$=caption$(3)
return
choix2:
 num$=caption$(4)
return
choix3:
 num$=caption$(5)
return
choix4:
 num$=caption$(6)
return
choix5:
 num$=caption$(7)
return
choix6:
 num$=caption$(8)
return
choix7:
 num$=caption$(9)
return
choix8:
 num$=caption$(10)
return

Un seul aurait suffit.
Tu peux utiliser un seul LABEL choix et tu remplaces tous les ON_CLICK par
ON_CLICK n,choix
Avec n =1,2,3,4,5,6,7,8,9,10,31,33,42,43


Code:

' jeu en lui même
choix:
    select number_click
        case 1  : Jeu()
        case 2  : num$ = caption$(2)
        case 3  : num$ = caption$(3)
        case 4  : num$ = caption$(4)
        case 5  : num$ = caption$(5)
        case 6  : num$ = caption$(6)
        case 7  : num$ = caption$(7)
        case 8  : num$ = caption$(8)
        case 9  : num$ = caption$(9)
        case 10 : num$ = caption$(10)
       
        case 31 : Annuler()
        case 33 : show 40
        case 42 : Nouveau()
        case 43 : Quitter()
    end_select
return

Dans le s/p Jeu

Code:

' mise a jour des compteur
if num$="1" then num1%=num1%+1 : caption 22,str$(num1%)
if num$="2" then num2%=num2%+1 : caption 23,str$(num2%)
if num$="3" then num3%=num3%+1 : caption 24,str$(num3%)
if num$="4" then num4%=num4%+1 : caption 25,str$(num4%)
if num$="5" then num5%=num5%+1 : caption 26,str$(num5%)
if num$="6" then num6%=num6%+1 : caption 27,str$(num6%)
if num$="7" then num7%=num7%+1 : caption 28,str$(num7%)
if num$="8" then num8%=num8%+1 : caption 29,str$(num8%)
if num$="9" then num9%=num9%+1 : caption 30,str$(num9%)

Peut être remplacé par

Code:

' mise a jour des compteur
    select val(num$)
      case 1 : num1% = num1% + 1 : caption 22,str$(num1%)
      case 2 : num2% = num2% + 1 : caption 23,str$(num2%)
      case 3 : num3% = num3% + 1 : caption 24,str$(num3%)
      case 4 : num4% = num4% + 1 : caption 25,str$(num4%)
      case 5 : num5% = num5% + 1 : caption 26,str$(num5%)
      case 6 : num6% = num6% + 1 : caption 27,str$(num6%)
      case 7 : num7% = num7% + 1 : caption 28,str$(num7%)
      case 8 : num8% = num8% + 1 : caption 29,str$(num8%)
      case 9 : num9% = num9% + 1 : caption 30,str$(num9%)
    end_select

Si tu permets, je peux ré-coder ton programme en utilisant un seul LABEL et le restructurer à ma façon.
Revenir en haut Aller en bas
http://papydall-panoramic.forumarabia.com/
Contenu sponsorisé





un p'tit sudoku a resoudre Empty
MessageSujet: Re: un p'tit sudoku a resoudre   un p'tit sudoku a resoudre Empty

Revenir en haut Aller en bas
 
un p'tit sudoku a resoudre
Revenir en haut 
Page 1 sur 2Aller à la page : 1, 2  Suivant
 Sujets similaires
-
» Résoudre une grille de SUDOKU
» SUDOKU
» Construire et résoudre un puzzle
» SUDOKU solution
» Résoudre un puzzle créé par Puzzeliser

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
FORUM DE DISCUSSION SUR LE LANGAGE PANORAMIC :: PANORAMIC :: Les jeux faits avec Panoramic-
Sauter vers: