Forum Liberty Basic France
• Index
Reprise du message précédent
Plus personne ?
Plus personne ?
____________________
Si le meilleurs langage de programmation existe, alors le Just Basic est loin devant.
Ne me tappez pas dessus ! Je débute
Si le meilleurs langage de programmation existe, alors le Just Basic est loin devant.
Ne me tappez pas dessus ! Je débute

Web
Tu en fait ce que tu veux... mais là je supprime les posts, parce que si Cassiope voit ça , je vais me faire incendier...
C'est un embryon de code, quand il sera fini et au point je mettrai tout ça en sub, avec trimballage de paramètres...Façon moderne quoi...
Ce que tu est censé faire ?....Ce que tu veux.. C'était juste pour te montrer qu'on peut s'amuser.
C'est un embryon de code, quand il sera fini et au point je mettrai tout ça en sub, avec trimballage de paramètres...Façon moderne quoi...
Ce que tu est censé faire ?....Ce que tu veux.. C'était juste pour te montrer qu'on peut s'amuser.
____________________
Roro
Roro
Ok x) j'ai presque finis la traduction de son code + l'amélioration.
Je post çà d'ici deux minutes.
Je post çà d'ici deux minutes.
____________________
Si le meilleurs langage de programmation existe, alors le Just Basic est loin devant.
Ne me tappez pas dessus ! Je débute
Si le meilleurs langage de programmation existe, alors le Just Basic est loin devant.
Ne me tappez pas dessus ! Je débute

Web
Voilà enfin la fin du logiciel ( tous traduis sauf les commentaires ) :
Code :
Merci de laisser vos commentaires.
Code :
randomize 0.5
dim ROW(12) 'arrays are larger, to hold empty margins
dim B(11,12)'only indices 3-9 are used
global DIFFICULTY : DIFFICULTY = 3 'default difficulty
global MOVE
for i = 1 to 40 : separator$ = separator$+"__" : next
'read texts
global COMPUTERTHINKS
read COMPUTERTHINKS
dim compThink$(COMPUTERTHINKS)
for i = 1 to COMPUTERTHINKS : read a$ : compThink$(i) = a$ : next
global YOURTURN
read YOURTURN
dim makeYourMove$(YOURTURN)
for i = 1 to YOURTURN : read a$ : makeYourMove$(i) = a$ : next
global HUMANWIN
read HUMANWIN
dim youWin$(HUMANWIN)
for i = 1 to HUMANWIN : read a$ : youWin$(i) = a$ : next
global COMPUTERWIN
read COMPUTERWIN
dim compWin$(COMPUTERWIN)
for i = 1 to COMPUTERWIN : read a$ : compWin$(i) = a$ : next
global DRAW
read DRAW
dim drawMessage$(DRAW)
for i = 1 to DRAW : read a$ : drawMessage$(i) = a$ : next
nomainwin
WindowWidth = 552
WindowHeight = 437
UpperLeftX=int((DisplayWidth-WindowWidth)/3)
UpperLeftY=int((DisplayHeight-WindowHeight)/4)
graphicbox #main.graph, 22, 6, 385, 330
button #main.new, "Nouveau jeu", [newGame], UL, 414, 21, 112, 25
button #main.difficulty, "Difficulté", GetDifficulty, UL, 414, 56, 112, 25
button #main.sav, "Aide", About, UL, 414, 200, 112, 25
button #main.quit, "Quitter", quit, UL, 414, 291, 112, 25
button #main.skip, "Démarrer le jeu", [CompStart], UL, 414, 161, 112, 25
button #main.about, "A propos", [apropos], UL, 414, 246, 112, 25
statictext #main, separator$, 1, 366, 546, 18
statictext #main.info, "", 4, 385, 548, 18
open "Puissance 4 by Forum Liberty Basic France" for window_nf as #main
print #main.graph,"down"
print #main, "trapclose quit"
print #main, "font ms_sans_serif 10"
#main.graph "when leftButtonDown RowButton"
' wait
[newGame]
#main.info, "Selectionner le niveau de dificulté ou appuyez sur : démarrer le jeu "
redim ROW(12)
redim B(11,12)
MOVE = 0
call DrawEmptyGrid
for i = 3 to 9
ROW(i) = 2 'row is "empty", 3 is first level
' h$ = "#main.button"+str$(i-2)
' #h$, "!enable" 'enable all buttons
next i
#main.skip, "!enable"
wait
sub GetDifficulty h$
WindowWidth = 208
WindowHeight = 230
' UpperLeftX=int((DisplayWidth-WindowWidth)/2)
' UpperLeftY=int((DisplayHeight-WindowHeight)/2)
groupbox #difficulty, "Selectionnez le niveau de dificulté:", 14, 11, 168, 180
radiobutton #difficulty.rb4, "Très facile", [dummy], [dummy], 38, 41, 72, 20
radiobutton #difficulty.rb2, "Facile", [dummy], [dummy], 38, 66, 48, 20
radiobutton #difficulty.rb3, "Normal", [dummy], [dummy], 38, 91, 64, 20
radiobutton #difficulty.rb1, "Dificile", [dummy], [dummy], 38, 116, 60, 20
button #difficulty.default, "Valider", [difficultyOk], UL, 54, 146, 80, 25
open "Niveau" for dialog_nf_modal as #difficulty
print #difficulty, "trapclose [difficultyOk]"
h$ = "#difficulty.rb"+str$(DIFFICULTY)
#h$, "set"
wait
[dummy]
wait
[difficultyOk]
for i = 1 to 4
h$ = "#difficulty.rb"+str$(i)
#h$, "value? a$"
if a$ = "set" then DIFFICULTY = i
next i
close #difficulty
end sub
[CompStart]
#main.skip, "!disable"
call CompMove DIFFICULTY
wait
sub DrawEmptyGrid
#main.graph, "cls; fill lightgray; color darkgray; size 2"
for i = 1 to 6
#main.graph, "line "; i*55-1; " 0 "; i*55-1; " 384"
next i
for i = 1 to 5
#main.graph, "line 0 "; i*55-1; " 384 "; i*55-1
next i
#main.graph, "flush"
end sub
sub DrawMove x, y
x = x-2
y = 9-y
#main.graph, "place "; x*55-28; " "; y*55-28
#main.graph, "circlefilled 24; flush"
end sub
sub RowButton handle$, mx, my
#main.skip, "!disable"
' n = val(right$(handle$,1))+2
n = int(mx/(385/7))+3
ROW(n) = ROW(n)+1
B(ROW(n), n) = 1
#main.graph, "color darkblue; backcolor darkblue"
MOVE = MOVE+1
call DrawMove n, ROW(n)
'check human move
MOVE = CheckWin(MOVE, 1, ROW(n), n)
if MOVE < 42 then call CompMove DIFFICULTY
MOVE = MOVE+1
end sub
sub quit handle$
close #main
end
end sub
sub About handle$
s$ = "Pour jouer : "
s2$ = "Vous devez selectionner le niveau ou cliquer sur démarrer le jeu."
s3$ = " Puis le but sera d'aligner 4 jetons horizontalement, verticalement ou diagonalement."
s4$ = " Mais gare à l'ordinateur ..."
WindowWidth = 384
WindowHeight = 336
' UpperLeftX=int((DisplayWidth-WindowWidth)/2)
' UpperLeftY=int((DisplayHeight-WindowHeight)/2)
groupbox #about.frame, "Comment jouer", 22, 16, 336, 240
statictext #about.text, "", 38, 46, 304, 200
button #about.default, "Ok", [aboutOk], UL, 126, 270, 122, 25
open "Aide" for dialog_nf_modal as #about
#about, "trapclose [aboutOk]"
#about, "font ms_sans_serif 10"
#about.frame, "!font ms_sans_serif 12"
#about.text, s$ ; s2$ ; s3$ ; s4$
wait
[aboutOk]
close #about
end sub
sub CompMove depth
#main.info, compThink$(int(rnd(1)*COMPUTERTHINKS)+1)
' for i = 1 to 7
' h$ = "#main.button"+str$(i)
' #h$, "!disable"
' next i
n = BestMove(-1, depth)
ROW(n) = ROW(n)+1
B(ROW(n),n) = -1
' for i = 1 to 7
' if ROW(i+2) < 8 then
' h$ = "#main.button"+str$(i)
' ' #h$, "!enable"
' end if
' next i
#main.graph, "color darkred; backcolor darkred"
call DrawMove n, ROW(n)
#main.info, makeYourMove$(int(rnd(1)*YOURTURN)+1)
MOVE = CheckWin(MOVE, -1, ROW(n), n)
end sub
function IsWin$(pl, row, col)
if B(row-1,col)=pl and B(row-2,col)=pl and B(row-3,col)= pl then _
IsWin$ = str$(row-1); col; str$(row-2); col; str$(row-3); col
if B(row,col-1)=pl and B(row,col-2)=pl and B(row,col-3)= pl then _
IsWin$ = IsWin$; row; str$(col-1); row; str$(col-2); row; str$(col-3)
if B(row,col-1)=pl and B(row,col-2)=pl and B(row,col+1)= pl then _
IsWin$ = IsWin$; row; str$(col-1); row; str$(col-2); row; str$(col+1)
if B(row,col-1)=pl and B(row,col+1)=pl and B(row,col+2)= pl then _
IsWin$ = IsWin$; row; str$(col-1); row; str$(col+1); row; str$(col+2)
if B(row,col+1)=pl and B(row,col+2)=pl and B(row,col+3)= pl then _
IsWin$ = IsWin$; row; str$(col+1); row; str$(col+2); row; str$(col+3)
if B(row+3,col-3)=pl and B(row+2,col-2)=pl and B(row+1,col-1)= pl then _
IsWin$ = IsWin$; str$(row+3); str$(col-3); str$(row+2); str$(col-2); str$(row+1); str$(col-1)
if B(row+2,col-2)=pl and B(row+1,col-1)=pl and B(row-1,col+1)= pl then _
IsWin$ = IsWin$; str$(row+2); str$(col-2); str$(row+1); str$(col-1); str$(row-1); str$(col+1)
if B(row+1,col-1)=pl and B(row-1,col+1)=pl and B(row-2,col+2)= pl then _
IsWin$ = IsWin$; str$(row+1); str$(col-1); str$(row-1); str$(col+1); str$(row-2); str$(col+2)
if B(row-1,col+1)=pl and B(row-2,col+2)=pl and B(row-3,col+3)= pl then _
IsWin$ = IsWin$; str$(row-1); str$(col+1); str$(row-2); str$(col+2); str$(row-3); str$(col+3)
if B(row-3,col-3)=pl and B(row-2,col-2)=pl and B(row-1,col-1)= pl then _
IsWin$ = IsWin$; str$(row-3); str$(col-3); str$(row-2); str$(col-2); str$(row-1); str$(col-1)
if B(row-2,col-2)=pl and B(row-1,col-1)=pl and B(row+1,col+1)= pl then _
IsWin$ = IsWin$; str$(row-2); str$(col-2); str$(row-1); str$(col-1); str$(row+1); str$(col+1)
if B(row-1,col-1)=pl and B(row+1,col+1)=pl and B(row+2,col+2)= pl then _
IsWin$ = IsWin$; str$(row-1); str$(col-1); str$(row+1); str$(col+1); str$(row+2); str$(col+2)
if B(row+1,col+1)=pl and B(row+2,col+2)=pl and B(row+3,col+3)= pl then _
IsWin$ = IsWin$; str$(row+1); str$(col+1); str$(row+2); str$(col+2); str$(row+3); str$(col+3)
if IsWin$ <> "" then IsWin$ = str$(row); str$(col); IsWin$
end function
function CheckWin(CheckWin, player, row, col)
s$ = IsWin$(player, row, col)
if s$ <> "" then
CheckWin = 42
if player = 1 then
#main.info, youWin$(int(rnd(1)*HUMANWIN)+1)
#main.graph, "color blue; backcolor blue"
else
#main.info, compWin$(int(rnd(1)*COMPUTERWIN)+1)
#main.graph, "color red; backcolor red"
end if
for i = 1 to len(s$) step 2
x = val(mid$(s$, i, 1))
y = val(mid$(s$, i+1, 1))
call DrawMove y, x
next i
else
if CheckWin = 42 then #main.info, drawMessage$(int(rnd(1)*DRAW)+1)
end if
' if CheckWin = 42 then
' for i = 1 to 7
' h$ = "#main.button"+str$(i)
' ' #h$, "!disable"
' next i
' end if
end function
function GetValue(player, depth, row, column)
pl = -1*player
if (B(row-1,column)=pl and B(row-2,column)=pl and B(row-3,column)= pl) or _
(B(row,column-1)=pl and B(row,column-2)=pl and B(row,column-3)= pl) or _
(B(row,column-1)=pl and B(row,column-2)=pl and B(row,column+1)= pl) or _
(B(row,column-1)=pl and B(row,column+1)=pl and B(row,column+2)= pl) or _
(B(row,column+1)=pl and B(row,column+2)=pl and B(row,column+3)= pl) or _
(B(row+3,column-3)=pl and B(row+2,column-2)=pl and B(row+1,column-1)= pl) or _
(B(row+2,column-2)=pl and B(row+1,column-1)=pl and B(row-1,column+1)= pl) or _
(B(row+1,column-1)=pl and B(row-1,column+1)=pl and B(row-2,column+2)= pl) or _
(B(row-1,column+1)=pl and B(row-2,column+2)=pl and B(row-3,column+3)= pl) or _
(B(row-3,column-3)=pl and B(row-2,column-2)=pl and B(row-1,column-1)= pl) or _
(B(row-2,column-2)=pl and B(row-1,column-1)=pl and B(row+1,column+1)= pl) or _
(B(row-1,column-1)=pl and B(row+1,column+1)=pl and B(row+2,column+2)= pl) or _
(B(row+1,column+1)=pl and B(row+2,column+2)=pl and B(row+3,column+3)= pl) then
GetValue = -128
else
if depth = 0 then exit function
GetValue = -1000
for i = 3 to 9
if ROW(i) < 8 then
ROW(i) = ROW(i)+1
B(ROW(i), i) = player
value = -1*GetValue(-1*player, depth-1, ROW(i), i)/2
B(ROW(i), i) = 0
ROW(i) = ROW(i)-1
if value > GetValue then
GetValue = value
if value = 64 then exit for
end if
end if
next i
end if
end function
function BestMove(player, depth)
max = -1000
for i = 3 to 9
if ROW(i) < 8 then
ROW(i) = ROW(i)+1
B(ROW(i),i) = player
value = -1*GetValue(-1*player, depth, ROW(i), i)
B(ROW(i), i) = 0
ROW(i) = ROW(i)-1
if value > max then
max = value
BestList$ = str$(i)
if max = 128 then exit for
else
if value = max then BestList$ = BestList$+str$(i)
end if
end if
next i
'print BestList$, max
BestMove = val(mid$(BestList$, int(rnd(1)*len(BestList$))+1, 1))
end function
data 9
data "Hmm... Laisse moi réfléchir"
data "Tu joues bien, Je le sais !"
data "Je le sais, je vais gagner, laisse moi juste réfléchir."
data "Silence ! Je réfléchis"
data "Ne me frappe pas !"
data "Silence s'il vous plait, je gagne."
data "Je suis sur... je pense... dur..."
data "Alors tu n'y arrive pas ? x)"
data "Arrete d'aller trop vite, je ne suis plus."
data 8
data "Je ne crains rien! Donne-moi ton meilleur coup !"
data "Réveillez-moi quand vous êtes prêt à jouer."
data "Montrez-moi ce que tu sais faire! "
data "Prouve-moi que tu es le meilleur !"
data "Je vais prendre une petite sieste pendant que vous comprendre cela !"
data "Réfléchissez bien! Une petite erreur et vous avez terminé !"
data "Vous pensez que ce n'est un tirage au sort ? "
data "Je ne le crois pas! "
data "Prenez votre temps."
data 11
data "Un grand bravo au gagnant du jeu !"
data "Cela devrait vous donner une leçon. Vous ne gagnerais JAMAIS avec moi !"
data "Vous avez perdu !"
data "Nous pouvons jouer un autre partie, mais vous allez encore perdre ..."
data "Je parie que vous n'avez pas vu que vous venez de perdre ."
data "Nous ne pouvons rester amis !"
data "Ouch! çà doit faire mal !"
data "Alors, qu'est-ce que tu fais ce soir ? Tu perds ?"
data "Mesdames et Messieurs, nous avons un gagnant. Devinez qui!"
data "C'est une autre victoire question-sur-esprit ..."
data "Je suis le roi du monde ."
data 8
data "J'offre un rêve ."
data "Dessine! Pourtant, vous étiez si proches ..."
data "Vous m'avez mis sous beaucoup de pression, mais vous ne pouviez pas me casser!"
data "Fait Nouveau Jeu maintenant ! Nous devons savoir qui est le meilleur. "
data "Euh, que c'est il passé ?"
data "Je leur ai dit que nous allions avoir besoin d'une plus grande carte pour cela."
data "Il faut que je change mon CPU ..."
data "Je vous promets, la prochaine fois je ne vais pas te laisser partir si facilement."
[apropos]
s$ = "Version : 1.0"
s2$ = " Traduis et amélioré par les membres du forum Liberty Basic France "
WindowWidth = 384
WindowHeight = 336
groupbox #about2.frame, "Version/Editeur", 22, 16, 336, 240
statictext #about2.text, "", 38, 46, 304, 200
button #about2.default, "Ok", [about2Ok], UL, 126, 270, 122, 25
open "A propos" for dialog_nf_modal as #about2
#about2, "trapclose [aboutOk]"
#about2, "font ms_sans_serif 10"
#about2.frame, "!font ms_sans_serif 12"
#about2.text, s$ ; s2$
wait
[about2Ok]
close #about2
close #main
Merci de laisser vos commentaires.
____________________
Si le meilleurs langage de programmation existe, alors le Just Basic est loin devant.
Ne me tappez pas dessus ! Je débute
Si le meilleurs langage de programmation existe, alors le Just Basic est loin devant.
Ne me tappez pas dessus ! Je débute

Web
Bandes de gamins


____________________
Devise Shadocks : "Mieux vaut mobiliser son intelligence pour des conneries, que mobiliser sa connerie pour des choses intelligentes"
Coluche disait : "C'est parce que la vitesse de la lumière est plus rapide que celle du son que certains peuvent paraîtrent brillants jusqu'à ce qu'ils ouvrent la bouche."
Devise Shadocks : "Mieux vaut mobiliser son intelligence pour des conneries, que mobiliser sa connerie pour des choses intelligentes"
Coluche disait : "C'est parce que la vitesse de la lumière est plus rapide que celle du son que certains peuvent paraîtrent brillants jusqu'à ce qu'ils ouvrent la bouche."
Web
cassiope01:
????
T'en penses quoi du programe ?
Bandes de gamins



????

T'en penses quoi du programe ?
____________________
Si le meilleurs langage de programmation existe, alors le Just Basic est loin devant.
Ne me tappez pas dessus ! Je débute
Si le meilleurs langage de programmation existe, alors le Just Basic est loin devant.
Ne me tappez pas dessus ! Je débute

Web
Bon, moi je vais faire quelques patés..... avec du sable humide.....ça tient mieux.

____________________
Roro
Roro
Nephthys:
J'en pense que je suis absolument d'accord avec Nephthys.
Pour discuter il vaut mieux parler la même langue, c'est plus facile, juste histoire que tout le monde sache à peu près de quoi on parle.
Attelle toi plutôt à étudier l'aide de JB, les variables tableaux, les commandes, la commande OPEN et opérations sur les fichiers, etc...
Je ne suis pas du tout bon professeur, sinon j'en aurais peut-être fait mon métier.
Demande à Roland ou à Atomose ce qu'ils pensent de mes talents de prof.
@+
Edité par cassiope01 Le 30/07/2012 à 18h37
Comme dis plus haut n'ais pas les yeux plus gros que le ventre (c'est pour dire moi je voulais faire une IA comme celle d'Iron Man etc.). Attelle toi d'abord à comprendre le code que je t'ai donné
Au début quand on programme on a l'impression que tout est possible simplement (d'autant plus avec langage de haut niveau comme le Basic - par contre si tu faisais de l'assembleur tu te dirais que rien n'est possible simplement XD)
Programme aussi sur papier avant d'aller à l'ordi, il faut concevoir son application sur papier avec de la faire sur ordi. En gros il faut faire un cahier des charges.
Faire un programme de chat est possible en Basic, mais il faut du temps et de l'entrainement avant d'y arriver

Programme aussi sur papier avant d'aller à l'ordi, il faut concevoir son application sur papier avec de la faire sur ordi. En gros il faut faire un cahier des charges.
Faire un programme de chat est possible en Basic, mais il faut du temps et de l'entrainement avant d'y arriver

J'en pense que je suis absolument d'accord avec Nephthys.
Pour discuter il vaut mieux parler la même langue, c'est plus facile, juste histoire que tout le monde sache à peu près de quoi on parle.
Attelle toi plutôt à étudier l'aide de JB, les variables tableaux, les commandes, la commande OPEN et opérations sur les fichiers, etc...
Je ne suis pas du tout bon professeur, sinon j'en aurais peut-être fait mon métier.
Demande à Roland ou à Atomose ce qu'ils pensent de mes talents de prof.



@+
Edité par cassiope01 Le 30/07/2012 à 18h37
____________________
Devise Shadocks : "Mieux vaut mobiliser son intelligence pour des conneries, que mobiliser sa connerie pour des choses intelligentes"
Coluche disait : "C'est parce que la vitesse de la lumière est plus rapide que celle du son que certains peuvent paraîtrent brillants jusqu'à ce qu'ils ouvrent la bouche."
Devise Shadocks : "Mieux vaut mobiliser son intelligence pour des conneries, que mobiliser sa connerie pour des choses intelligentes"
Coluche disait : "C'est parce que la vitesse de la lumière est plus rapide que celle du son que certains peuvent paraîtrent brillants jusqu'à ce qu'ils ouvrent la bouche."
Web
cassiope01:
Primo quel rapport avec ma question Citation:
Deuxio : Je me débrouille avec les open et run et je ne voit toujours pas le rapport avec Citation:
a +
Ps : Roland, mets du ciment dans ton sable humide, et çà tiendra encore mieux
Nephthys:
J'en pense que je suis absolument d'accord avec Nephthys.
Pour discuter il vaut mieux parler la même langue, c'est plus facile, juste histoire que tout le monde sache à peu près de quoi on parle.
Attelle toi plutôt à étudier l'aide de JB, les variables tableaux, les commandes, la commande OPEN et opérations sur les fichiers, etc...
Je ne suis pas du tout bon professeur, sinon j'en aurais peut-être fait mon métier.
Demande à Roland ou à Atomose ce qu'ils pensent de mes talents de prof.
@+
Comme dis plus haut n'ais pas les yeux plus gros que le ventre (c'est pour dire moi je voulais faire une IA comme celle d'Iron Man etc.). Attelle toi d'abord à comprendre le code que je t'ai donné
Au début quand on programme on a l'impression que tout est possible simplement (d'autant plus avec langage de haut niveau comme le Basic - par contre si tu faisais de l'assembleur tu te dirais que rien n'est possible simplement XD)
Programme aussi sur papier avant d'aller à l'ordi, il faut concevoir son application sur papier avec de la faire sur ordi. En gros il faut faire un cahier des charges.
Faire un programme de chat est possible en Basic, mais il faut du temps et de l'entrainement avant d'y arriver

Programme aussi sur papier avant d'aller à l'ordi, il faut concevoir son application sur papier avec de la faire sur ordi. En gros il faut faire un cahier des charges.
Faire un programme de chat est possible en Basic, mais il faut du temps et de l'entrainement avant d'y arriver

J'en pense que je suis absolument d'accord avec Nephthys.
Pour discuter il vaut mieux parler la même langue, c'est plus facile, juste histoire que tout le monde sache à peu près de quoi on parle.
Attelle toi plutôt à étudier l'aide de JB, les variables tableaux, les commandes, la commande OPEN et opérations sur les fichiers, etc...
Je ne suis pas du tout bon professeur, sinon j'en aurais peut-être fait mon métier.
Demande à Roland ou à Atomose ce qu'ils pensent de mes talents de prof.



@+
Primo quel rapport avec ma question Citation:
T'en penses quoi du programe ?
?Deuxio : Je me débrouille avec les open et run et je ne voit toujours pas le rapport avec Citation:
T'en penses quoi du programe ?
qui signifie : "Quesque tu penses de mon résultat casiope01 par rapport au code que tu avais donné au début". C'est tout.a +
Ps : Roland, mets du ciment dans ton sable humide, et çà tiendra encore mieux

____________________
Si le meilleurs langage de programmation existe, alors le Just Basic est loin devant.
Ne me tappez pas dessus ! Je débute
Si le meilleurs langage de programmation existe, alors le Just Basic est loin devant.
Ne me tappez pas dessus ! Je débute

Web
Me parle pas de ciment, en ce moment, je fais du béton.
Pour ta traduction du jeu, il se passe que Cassiope et moi, on se débrouille à peu prés en anglish.
Donc c'est pas pour nous
mais, si ça t'amuse de traduire des jeux, traduit tant que tu veux (n'oublie pas les commentaires c'est le plus interressant dans l'open source) Ne fait pas comme Google, qui traduit aussi les mots clef...
Pour avoir un avis pertinent, il faudrait le montrer à un(e) prof d'anglais.
Pour ta traduction du jeu, il se passe que Cassiope et moi, on se débrouille à peu prés en anglish.
Donc c'est pas pour nous
mais, si ça t'amuse de traduire des jeux, traduit tant que tu veux (n'oublie pas les commentaires c'est le plus interressant dans l'open source) Ne fait pas comme Google, qui traduit aussi les mots clef...

Pour avoir un avis pertinent, il faudrait le montrer à un(e) prof d'anglais.
____________________
Roro
Roro
Citation:
Tu dois t'éclater
Ok. Moi je voulais juste rendre service en faisant çà : Citation:
Me parle pas de ciment, en ce moment, je fais du béton.
Tu dois t'éclater

Ok. Moi je voulais juste rendre service en faisant çà : Citation:
Si ça dit à quelqu'un de traduire correctement tout les textes de l'auteur ( il y en a pas mal )
c'est tout .
____________________
Si le meilleurs langage de programmation existe, alors le Just Basic est loin devant.
Ne me tappez pas dessus ! Je débute
Si le meilleurs langage de programmation existe, alors le Just Basic est loin devant.
Ne me tappez pas dessus ! Je débute

Web
Voici un petit cadeau pour alex, et pour tout le monde bien sûr...
Je reconnais que tu n'aurais pas pu écrire ce que tu voulais faire à ton niveau actuel en JustBasic, tant il m'a fallu analyser très profondément le code de l'auteur qui n'avait vraiment pas prévu de pouvoir enregistrer la partie en cours... ni rien d'autre d'ailleur !
Code VB :
@+
Edité par cassiope01 Le 07/08/2012 à 07h23
Je reconnais que tu n'aurais pas pu écrire ce que tu voulais faire à ton niveau actuel en JustBasic, tant il m'a fallu analyser très profondément le code de l'auteur qui n'avait vraiment pas prévu de pouvoir enregistrer la partie en cours... ni rien d'autre d'ailleur !
Code VB :
'http://libertybasic.fr/forum/topic-117-1+puissance4.php 'connect4GUI.bas randomize 0.5 dim ROW(12) 'arrays are larger, to hold empty margins dim B(11,12)'only indices 3-9 are used dim info$(10,10) global DIFFICULTY, MOVE, diff$ DIFFICULTY = 2 'default difficulty diff$ = "Très facile;Facile;Moyen;Difficile" for i = 1 to 40 : separator$ = separator$+"__" : next global COMPUTERTHINKS read COMPUTERTHINKS dim compThink$(COMPUTERTHINKS) for i = 1 to COMPUTERTHINKS : read a$ : compThink$(i) = a$ : next global YOURTURN read YOURTURN dim makeYourMove$(YOURTURN) for i = 1 to YOURTURN : read a$ : makeYourMove$(i) = a$ : next global HUMANWIN read HUMANWIN dim youWin$(HUMANWIN) for i = 1 to HUMANWIN : read a$ : youWin$(i) = a$ : next global COMPUTERWIN read COMPUTERWIN dim compWin$(COMPUTERWIN) for i = 1 to COMPUTERWIN : read a$ : compWin$(i) = a$ : next global DRAW read DRAW dim drawMessage$(DRAW) for i = 1 to DRAW : read a$ : drawMessage$(i) = a$ : next nomainwin WindowWidth = 552 WindowHeight = 437 UpperLeftX=int((DisplayWidth-WindowWidth)/3) UpperLeftY=int((DisplayHeight-WindowHeight)/4) graphicbox #main.graph, 22, 6, 385, 330 button #main.new, "Nouveau jeu", [newGame], UL, 424, 21, 112, 25 button #main.difficulty, "Difficulté", GetDifficulty, UL, 424, 56, 112, 25 statictext #main.diff, word$(diff$,DIFFICULTY,";"), 446, 108, 112, 25 button #main.quit, "Quitter", quit, UL, 424, 291, 112, 25 button #main.skip, "Passer", [CompStart], UL, 436, 161, 88, 25 button #main.about, "A propos", About, UL, 424, 256, 112, 25 statictext #main, separator$, 1, 366, 546, 18 statictext #main.info, "", 4, 385, 548, 18 open "JB Connect4" for window_nf as #main #main "trapclose quit" #main "font ms_sans_serif 10 bold" #main.info "!font ms_sans_serif 10 bold" #main.graph "down" if fileExist(DefaultDir$,"saved.ini") then 'chargement de ROW(12) et B(11,12) et l'affiche. call DrawEmptyGrid open "saved.ini" for input as #grid LINE INPUT #grid, m$ :MOVE=val(m$) LINE INPUT #grid, d$ :DIFFICULTY=val(d$) LINE INPUT #grid, row$ for x=3 to 9 :ROW(x)=maxi(val(word$(row$,x)),2) :next for y=0 to 11 'vertical LINE INPUT #grid, B$ for x=3 to 9 'horizontal B(y,x)=val(word$(B$,x)) if abs(B(y,x))>0 then if B(y,x)=1 then color$ = "darkblue" else color$ = "darkred" #main.graph "color ";color$;" ; backcolor ";color$ cx = x-2 cy = 9-y #main.graph "place ";cx*55-28;" ";cy*55-28;" ;circlefilled 24" end if next next close #grid #main.diff word$(diff$,DIFFICULTY,";") #main.skip "!disable" #main.graph "flush; discard" #main.info "A toi de jouer..." goto [jeu] end if [newGame] #main.info, "Selectionner le niveau de difficulté ou jouez directement." redim ROW(12) redim B(11,12) MOVE = 0 call DrawEmptyGrid for i = 3 to 9 ROW(i) = 2 'row is "empty", 3 is first level next i #main.skip, "!enable" [jeu] #main.graph "when leftButtonDown RowButton" wait function maxi(a,b) maxi = a if b>a then maxi = b end function sub GetDifficulty h$ WindowWidth = 208 WindowHeight = 230 ' UpperLeftX=int((DisplayWidth-WindowWidth)/2) ' UpperLeftY=int((DisplayHeight-WindowHeight)/2) groupbox #difficulty, "Sélectionnez le niveau", 14, 11, 172, 180 radiobutton #difficulty.rb1, "Trés facile", [dummy], [dummy], 38, 41, 100, 20 radiobutton #difficulty.rb2, "Facile", [dummy], [dummy], 38, 66, 100, 20 radiobutton #difficulty.rb3, "Médium", [dummy], [dummy], 38, 91, 100, 20 radiobutton #difficulty.rb4, "Difficile", [dummy], [dummy], 38, 116, 100, 20 button #difficulty.default, "Ok", [difficultyOk], UL, 58, 155, 80, 25 open "" for dialog_nf_modal as #difficulty print #difficulty, "trapclose [difficultyOk]" #difficulty "font ms_sans_serif 10 bold" h$ = "#difficulty.rb"+str$(DIFFICULTY) #h$, "set" wait [dummy] wait [difficultyOk] for i = 1 to 4 h$ = "#difficulty.rb"+str$(i) #h$, "value? a$" if a$ = "set" then DIFFICULTY = i next i close #difficulty #main.diff, word$(diff$,DIFFICULTY,";") end sub [CompStart] #main.skip, "!disable" call CompMove DIFFICULTY wait sub DrawEmptyGrid lightcolor$ = "250 252 160" ' "darkgray" darkcolor$ = "253 213 73" ' "lightgray" #main.graph, "cls; fill ";lightcolor$ call YinYang 385/2, 330/2, 385/1.2, darkcolor$, lightcolor$ #main.graph, "color white" for i = 1 to 6 #main.graph, "line "; i*55-1; " 0 "; i*55-1; " 384" next i for i = 1 to 5 #main.graph, "line 0 "; i*55-1; " 384 "; i*55-1 next i #main.graph, "flush ; discard" end sub sub DrawMove x, y x = x-2 y = 9-y #main.graph, "place "; x*55-28; " "; y*55-28 #main.graph, "circlefilled 24; flush" end sub sub RowButton handle$, mx, my 'player and if MOVE<42 : computer if MOVE = 42 then exit sub #main.skip, "!disable" n = int(mx/(385/7))+3 ROW(n) = ROW(n)+1 B(ROW(n), n) = 1 #main.graph, "color darkblue; backcolor darkblue" MOVE = MOVE+1 call DrawMove n, ROW(n) 'check human move MOVE = CheckWin(MOVE, 1, ROW(n), n) if MOVE < 42 then call CompMove DIFFICULTY else #main.graph "when leftButtonDown" exit sub end if MOVE = MOVE+1 end sub sub quit handle$ ' enregistrer dans "saved.ini" : ROW(11) et B(11,12) si MOVE >0 et < 42 , MOVE, DIFFICULTY if MOVE>0 and MOVE<42 then open "saved.ini" for output as #grid #grid, MOVE #grid, DIFFICULTY row$ = "" for x=0 to 12 :row$ = row$;ROW(x);" " :next #grid, row$ for y=0 to 11 B$="" : for x=0 to 12 : B$ = B$;B(y,x);" " : next #grid, B$ next close #grid end if close #main end end sub sub YinYang x, y, size, darkcol$, lightcol$ #main.graph "up ; goto "; x; " "; y #main.graph "backcolor ";darkcol$;" ; color ";darkcol$ #main.graph "down ; circlefilled "; size /2 #main.graph "color ";lightcol$;" ; backcolor ";lightcol$ #main.graph "up ; goto "; x -size /2; " "; y -size /2 #main.graph "down ; boxfilled "; x; " "; y +size /2 #main.graph "up ; goto "; x; " "; y -size /4 #main.graph "down ; backcolor ";darkcol$;" ; color ";darkcol$;" ; circlefilled "; size /4 #main.graph "up ; goto "; x; " "; y -size /4 #main.graph "down ; backcolor ";lightcol$;" ; color ";lightcol$;" ; circlefilled "; size /12 #main.graph "up ; goto "; x; " "; y +size /4 #main.graph "down ; backcolor ";lightcol$;" ; color ";lightcol$;" ; circlefilled "; size /4 #main.graph "up ; goto "; x; " "; y +size /4 #main.graph "down ; backcolor ";darkcol$;" ; color ";darkcol$;" ; circlefilled "; size /12 #main.graph "up ; goto "; x; " "; y #main.graph "down ; color ";darkcol$;" ; circle "; size /2 end sub sub About handle$ s$ = "Pour jouer :"+chr$(13) s2$ = "Vous pouvez selectionner le niveau ou jouer directement."+chr$(13) s3$ = " Puis le but sera d'aligner 4 jetons horizontalement,"+chr$(13) s4$ = " verticalement ou diagonalement. Mais gare à l'ordinateur ..."+chr$(13)+chr$(13) s5$ = "A game by uncleBen" WindowWidth = 384 WindowHeight = 336 ' UpperLeftX=int((DisplayWidth-WindowWidth)/2) ' UpperLeftY=int((DisplayHeight-WindowHeight)/2) groupbox #about.frame, "How to play", 22, 16, 336, 240 statictext #about.text, "", 38, 46, 304, 200 button #about.default, "Ok", [aboutOk], UL, 126, 270, 122, 25 open "About JB Connect4" for dialog_nf_modal as #about #about, "trapclose [aboutOk]" #about, "font ms_sans_serif 10" #about.frame, "!font ms_sans_serif 12" #about.text, s$;s2$;s3$;s4$;s5$ wait [aboutOk] close #about end sub sub CompMove depth #main.info, compThink$(int(rnd(1)*COMPUTERTHINKS)+1) n = BestMove(-1, depth) ROW(n) = ROW(n)+1 B(ROW(n),n) = -1 #main.graph, "color darkred; backcolor darkred" call DrawMove n, ROW(n) #main.info, makeYourMove$(int(rnd(1)*YOURTURN)+1) MOVE = CheckWin(MOVE, -1, ROW(n), n) if MOVE = 42 then #main.graph "when leftButtonDown" end sub function IsWin$(pl, row, col) if B(row-1,col)=pl and B(row-2,col)=pl and B(row-3,col)= pl then _ IsWin$ = str$(row-1); col; str$(row-2); col; str$(row-3); col if B(row,col-1)=pl and B(row,col-2)=pl and B(row,col-3)= pl then _ IsWin$ = IsWin$; row; str$(col-1); row; str$(col-2); row; str$(col-3) if B(row,col-1)=pl and B(row,col-2)=pl and B(row,col+1)= pl then _ IsWin$ = IsWin$; row; str$(col-1); row; str$(col-2); row; str$(col+1) if B(row,col-1)=pl and B(row,col+1)=pl and B(row,col+2)= pl then _ IsWin$ = IsWin$; row; str$(col-1); row; str$(col+1); row; str$(col+2) if B(row,col+1)=pl and B(row,col+2)=pl and B(row,col+3)= pl then _ IsWin$ = IsWin$; row; str$(col+1); row; str$(col+2); row; str$(col+3) if B(row+3,col-3)=pl and B(row+2,col-2)=pl and B(row+1,col-1)= pl then _ IsWin$ = IsWin$; str$(row+3); str$(col-3); str$(row+2); str$(col-2); str$(row+1); str$(col-1) if B(row+2,col-2)=pl and B(row+1,col-1)=pl and B(row-1,col+1)= pl then _ IsWin$ = IsWin$; str$(row+2); str$(col-2); str$(row+1); str$(col-1); str$(row-1); str$(col+1) if B(row+1,col-1)=pl and B(row-1,col+1)=pl and B(row-2,col+2)= pl then _ IsWin$ = IsWin$; str$(row+1); str$(col-1); str$(row-1); str$(col+1); str$(row-2); str$(col+2) if B(row-1,col+1)=pl and B(row-2,col+2)=pl and B(row-3,col+3)= pl then _ IsWin$ = IsWin$; str$(row-1); str$(col+1); str$(row-2); str$(col+2); str$(row-3); str$(col+3) if B(row-3,col-3)=pl and B(row-2,col-2)=pl and B(row-1,col-1)= pl then _ IsWin$ = IsWin$; str$(row-3); str$(col-3); str$(row-2); str$(col-2); str$(row-1); str$(col-1) if B(row-2,col-2)=pl and B(row-1,col-1)=pl and B(row+1,col+1)= pl then _ IsWin$ = IsWin$; str$(row-2); str$(col-2); str$(row-1); str$(col-1); str$(row+1); str$(col+1) if B(row-1,col-1)=pl and B(row+1,col+1)=pl and B(row+2,col+2)= pl then _ IsWin$ = IsWin$; str$(row-1); str$(col-1); str$(row+1); str$(col+1); str$(row+2); str$(col+2) if B(row+1,col+1)=pl and B(row+2,col+2)=pl and B(row+3,col+3)= pl then _ IsWin$ = IsWin$; str$(row+1); str$(col+1); str$(row+2); str$(col+2); str$(row+3); str$(col+3) if IsWin$ <> "" then IsWin$ = str$(row); str$(col); IsWin$ end function function CheckWin(CheckWin, player, row, col) s$ = IsWin$(player, row, col) if s$ <> "" then CheckWin = 42 if player = 1 then #main.info, youWin$(int(rnd(1)*HUMANWIN)+1) #main.graph, "color blue; backcolor blue" else #main.info, compWin$(int(rnd(1)*COMPUTERWIN)+1) #main.graph, "color red; backcolor red" end if for i = 1 to len(s$) step 2 x = val(mid$(s$, i, 1)) y = val(mid$(s$, i+1, 1)) call DrawMove y, x next i else if CheckWin = 42 then #main.info, drawMessage$(int(rnd(1)*DRAW)+1) end if end function function GetValue(player, depth, row, column) pl = 0-player if (B(row-1,column)=pl and B(row-2,column)=pl and B(row-3,column)= pl) or _ (B(row,column-1)=pl and B(row,column-2)=pl and B(row,column-3)= pl) or _ (B(row,column-1)=pl and B(row,column-2)=pl and B(row,column+1)= pl) or _ (B(row,column-1)=pl and B(row,column+1)=pl and B(row,column+2)= pl) or _ (B(row,column+1)=pl and B(row,column+2)=pl and B(row,column+3)= pl) or _ (B(row+3,column-3)=pl and B(row+2,column-2)=pl and B(row+1,column-1)= pl) or _ (B(row+2,column-2)=pl and B(row+1,column-1)=pl and B(row-1,column+1)= pl) or _ (B(row+1,column-1)=pl and B(row-1,column+1)=pl and B(row-2,column+2)= pl) or _ (B(row-1,column+1)=pl and B(row-2,column+2)=pl and B(row-3,column+3)= pl) or _ (B(row-3,column-3)=pl and B(row-2,column-2)=pl and B(row-1,column-1)= pl) or _ (B(row-2,column-2)=pl and B(row-1,column-1)=pl and B(row+1,column+1)= pl) or _ (B(row-1,column-1)=pl and B(row+1,column+1)=pl and B(row+2,column+2)= pl) or _ (B(row+1,column+1)=pl and B(row+2,column+2)=pl and B(row+3,column+3)= pl) then GetValue = -128 else if depth = 0 then exit function GetValue = -1000 for i = 3 to 9 if ROW(i) < 8 then ROW(i) = ROW(i)+1 B(ROW(i), i) = player value = -1*GetValue(0-player, depth-1, ROW(i), i)/2 B(ROW(i), i) = 0 ROW(i) = ROW(i)-1 if value > GetValue then GetValue = value if value = 64 then exit for end if end if next i end if end function function BestMove(player, depth) max = -1000 for i = 3 to 9 if ROW(i) < 8 then ROW(i) = ROW(i)+1 B(ROW(i),i) = player value = -1*GetValue(0-player, depth, ROW(i), i) B(ROW(i), i) = 0 ROW(i) = ROW(i)-1 if value > max then max = value BestList$ = str$(i) if max = 128 then exit for else if value = max then BestList$ = BestList$+str$(i) end if end if next i 'print BestList$, max BestMove = val(mid$(BestList$, int(rnd(1)*len(BestList$))+1, 1)) end function data 9 data "Hmm... Laisse moi réfléchir" data "Tu joues bien, Je le sais !" data "Je le sais, je vais gagner, laisse moi juste réfléchir." data "Silence ! Je réfléchis" data "Ne me frappe pas !" data "Silence s'il vous plait, je gagne." data "Je suis sur... je pense... dur..." data "Alors tu n'y arrive pas ? x)" data "Arrete d'aller trop vite, je ne suis plus." data 9 data "Je ne crains rien! Donne-moi ton meilleur coup !" data "Réveillez-moi quand vous êtes prêt à jouer." data "Montrez-moi ce que tu sais faire! " data "Prouve-moi que tu es le meilleur !" data "Je vais prendre une petite sieste pendant que vous comprendre cela !" data "Réfléchissez bien! Une petite erreur et vous avez terminé !" data "Vous pensez que ce n'est un tirage au sort ? " data "Je ne le crois pas! " data "Prenez votre temps." data 11 data "You win! Let's play again." data "May thoughts were wandering... You win!" data "I didn't see that coming!" data "I bet you can't beat me again!" data "Congratulations! You are almost as good as I." data "That's not fair! I had something in my eye." data "I can't believe it! You win!" data "There was a magnetic storm! I couldn't think straight..." data "It's impossible... Tell me how many moves you think ahead." data "Amazing! You are my superhero." data "I couldn't concentrate. You were moving the mouse all the time." data 11 data "Un grand bravo au gagnant du jeu !" data "Cela devrait vous donner une leçon. Vous ne gagnerais JAMAIS avec moi !" data "Vous avez perdu !" data "Nous pouvons jouer un autre partie, mais vous allez encore perdre ..." data "Je parie que vous n'avez pas vu que vous venez de perdre ." data "Nous ne pouvons rester amis !" data "Ouch! çà doit faire mal !" data "Alors, qu'est-ce que tu fais ce soir ? Tu perds ?" data "Mesdames et Messieurs, nous avons un gagnant. Devinez qui!" data "C'est une autre victoire question-sur-esprit ..." data "Je suis le roi du monde ." data 8 data "J'offre un rêve ." data "Dessine! Pourtant, vous étiez si proches ..." data "Vous m'avez mis sous beaucoup de pression, mais vous ne pouviez pas me casser!" data "Fait Nouveau Jeu maintenant ! Nous devons savoir qui est le meilleur. " data "Euh, que c'est il passé ?" data "Je leur ai dit que nous allions avoir besoin d'une plus grande carte pour cela." data "Il faut que je change mon CPU ..." data "Je vous promets, la prochaine fois je ne vais pas te laisser partir si facilement." function fileExist(path$, filename$) 'DIM info$(10,10) 'must have been declared at the start of the code. files path$, filename$, info$() ' path$ = DefaultDir$ generally... fileExist = val(info$(0, 0)) end function
@+
Edité par cassiope01 Le 07/08/2012 à 07h23
____________________
Devise Shadocks : "Mieux vaut mobiliser son intelligence pour des conneries, que mobiliser sa connerie pour des choses intelligentes"
Coluche disait : "C'est parce que la vitesse de la lumière est plus rapide que celle du son que certains peuvent paraîtrent brillants jusqu'à ce qu'ils ouvrent la bouche."
Devise Shadocks : "Mieux vaut mobiliser son intelligence pour des conneries, que mobiliser sa connerie pour des choses intelligentes"
Coluche disait : "C'est parce que la vitesse de la lumière est plus rapide que celle du son que certains peuvent paraîtrent brillants jusqu'à ce qu'ils ouvrent la bouche."
Web
Adaptation pour pouvoir modifier facilement les couleurs des joueurs (foncé et claire) et aussi les couleurs (foncé et claire) du YingYang
+ léger clignotement du coup joué.
+ effacement du fichier de la dernière partie chargée,
+ correction de quelques bug...
Code VB :
Edité par cassiope01 Le 05/08/2012 à 07h43

+ léger clignotement du coup joué.
+ effacement du fichier de la dernière partie chargée,
+ correction de quelques bug...
Code VB :
'http://libertybasic.fr/forum/topic-117-1+puissance4.php 'connect4GUI.bas randomize 0.5 dim ROW(12) 'arrays are larger, to hold empty margins dim B(11,12)'only indices 3-9 are used dim colorPl$(2,2) dim info$(10,10) global DIFFICULTY, MOVE, diff$ DIFFICULTY = 2 'default difficulty diff$ = "Très facile;Facile;Moyen;Difficile" colorPl$(0,0) = "darkred" ' couleurs ordi colorPl$(0,1) = "red" colorPl$(2,0) = "darkblue" 'couleurs joueur colorPl$(2,1) = "blue" for i = 1 to 40 : separator$ = separator$+"__" : next global COMPUTERTHINKS read COMPUTERTHINKS dim compThink$(COMPUTERTHINKS) for i = 1 to COMPUTERTHINKS : read a$ : compThink$(i) = a$ : next global YOURTURN read YOURTURN dim makeYourMove$(YOURTURN) for i = 1 to YOURTURN : read a$ : makeYourMove$(i) = a$ : next global HUMANWIN read HUMANWIN dim youWin$(HUMANWIN) for i = 1 to HUMANWIN : read a$ : youWin$(i) = a$ : next global COMPUTERWIN read COMPUTERWIN dim compWin$(COMPUTERWIN) for i = 1 to COMPUTERWIN : read a$ : compWin$(i) = a$ : next global DRAW read DRAW dim drawMessage$(DRAW) for i = 1 to DRAW : read a$ : drawMessage$(i) = a$ : next nomainwin WindowWidth = 552 WindowHeight = 437 UpperLeftX=int((DisplayWidth-WindowWidth)/3) UpperLeftY=int((DisplayHeight-WindowHeight)/4) graphicbox #main.graph, 22, 6, 385, 330 button #main.new, "Nouveau jeu", [newGame], UL, 424, 21, 112, 25 button #main.difficulty, "Difficulté", GetDifficulty, UL, 424, 56, 112, 25 statictext #main.diff, word$(diff$,DIFFICULTY,";"), 446, 108, 112, 25 button #main.quit, "Quitter", quit, UL, 424, 291, 112, 25 button #main.skip, "Passer", [CompStart], UL, 436, 161, 88, 25 button #main.about, "A propos", About, UL, 424, 256, 112, 25 statictext #main, separator$, 1, 366, 546, 18 statictext #main.info, "", 4, 385, 548, 18 open "JB Connect4" for window_nf as #main #main "trapclose quit" #main "font ms_sans_serif 10 bold" #main.info "!font ms_sans_serif 10 bold" #main.graph "down" if fileExist(DefaultDir$,"saved.ini") then 'chargement de ROW(12) et B(11,12) et l'affiche. call DrawEmptyGrid open "saved.ini" for input as #grid LINE INPUT #grid, m$ :MOVE=val(m$) LINE INPUT #grid, d$ :DIFFICULTY=val(d$) LINE INPUT #grid, row$ for x=3 to 9 :ROW(x)=maxi(val(word$(row$,x)),2) :next for y=0 to 11 'vertical LINE INPUT #grid, B$ for x=3 to 9 'horizontal B(y,x)=val(word$(B$,x)) if abs(B(y,x))>0 then if B(y,x)=1 then color$ = "darkblue" else color$ = "darkred" #main.graph "color ";color$;" ; backcolor ";color$ cx = x-2 cy = 9-y #main.graph "place ";cx*55-28;" ";cy*55-28;" ;circlefilled 24" end if next next close #grid kill "saved.ini" #main.diff word$(diff$,DIFFICULTY,";") #main.skip "!disable" #main.graph "flush; discard" #main.info "A toi de jouer..." goto [jeu] end if [newGame] #main.info, "Selectionner le niveau de difficulté ou jouez directement." redim ROW(12) redim B(11,12) MOVE = 0 call DrawEmptyGrid for i = 3 to 9 ROW(i) = 2 'row is "empty", 3 is first level next i #main.skip, "!enable" [jeu] #main.graph "when leftButtonDown RowButton" wait function maxi(a,b) maxi = a if b>a then maxi = b end function sub GetDifficulty h$ WindowWidth = 208 WindowHeight = 230 ' UpperLeftX=int((DisplayWidth-WindowWidth)/2) ' UpperLeftY=int((DisplayHeight-WindowHeight)/2) groupbox #difficulty, "Sélectionnez le niveau", 14, 11, 172, 180 radiobutton #difficulty.rb1, "Trés facile", [dummy], [dummy], 38, 41, 100, 20 radiobutton #difficulty.rb2, "Facile", [dummy], [dummy], 38, 66, 100, 20 radiobutton #difficulty.rb3, "Médium", [dummy], [dummy], 38, 91, 100, 20 radiobutton #difficulty.rb4, "Difficile", [dummy], [dummy], 38, 116, 100, 20 button #difficulty.default, "Ok", [difficultyOk], UL, 58, 155, 80, 25 open "" for dialog_nf_modal as #difficulty print #difficulty, "trapclose [difficultyOk]" #difficulty "font ms_sans_serif 10 bold" h$ = "#difficulty.rb"+str$(DIFFICULTY) #h$, "set" wait [dummy] wait [difficultyOk] for i = 1 to 4 h$ = "#difficulty.rb"+str$(i) #h$, "value? a$" if a$ = "set" then DIFFICULTY = i next i close #difficulty #main.diff, word$(diff$,DIFFICULTY,";") end sub [CompStart] #main.skip, "!disable" call CompMove DIFFICULTY wait sub DrawEmptyGrid lightcolor$ = "250 252 160" ' "darkgray" darkcolor$ = "253 213 73" ' "lightgray" #main.graph, "cls; fill ";lightcolor$ call YinYang 385/2, 330/2, 385/1.2, darkcolor$, lightcolor$ #main.graph, "color white" for i = 1 to 6 #main.graph, "line "; i*55-1; " 0 "; i*55-1; " 384" next i for i = 1 to 5 #main.graph, "line 0 "; i*55-1; " 384 "; i*55-1 next i #main.graph, "flush ; discard" end sub sub DrawMove x, y, pl, win ' pl=1 -> joueur pl=-1 -> ordi win = 0 ou 1 x = x-2 y = 9-y c = win for p=1 to 6 c = c+1-2*(c=1) #main.graph, "color ";colorPl$(pl+1,c);" ; backcolor ";colorPl$(pl+1,c) #main.graph, "place "; x*55-28; " "; y*55-28 #main.graph, "circlefilled 24" timer 80, [tmp] wait [tmp] timer 0 next #main.graph, "flush ; discard" end sub sub RowButton handle$, mx, my 'player and if MOVE<42 : computer if MOVE = 42 then exit sub #main.skip, "!disable" n = int(mx/(385/7))+3 ROW(n) = ROW(n)+1 B(ROW(n), n) = 1 '#main.graph, "color darkblue; backcolor darkblue" MOVE = MOVE+1 call DrawMove n, ROW(n), 1, 0 'check human move MOVE = CheckWin(MOVE, 1, ROW(n), n) if MOVE < 42 then call CompMove DIFFICULTY else #main.graph "when leftButtonDown" exit sub end if MOVE = MOVE+1 end sub sub quit handle$ ' enregistrer dans "saved.ini" : ROW(11) et B(11,12) si MOVE >0 et < 42 , MOVE, DIFFICULTY if MOVE>0 and MOVE<42 then open "saved.ini" for output as #grid #grid, MOVE #grid, DIFFICULTY row$ = "" for x=0 to 12 :row$ = row$;ROW(x);" " :next #grid, row$ for y=0 to 11 B$="" : for x=0 to 12 : B$ = B$;B(y,x);" " : next #grid, B$ next close #grid end if close #main end end sub sub YinYang x, y, size, darkcol$, lightcol$ #main.graph "up ; goto "; x; " "; y #main.graph "backcolor ";darkcol$;" ; color ";darkcol$ #main.graph "down ; circlefilled "; size /2 #main.graph "color ";lightcol$;" ; backcolor ";lightcol$ #main.graph "up ; goto "; x -size /2; " "; y -size /2 #main.graph "down ; boxfilled "; x; " "; y +size /2 #main.graph "up ; goto "; x; " "; y -size /4 #main.graph "down ; backcolor ";darkcol$;" ; color ";darkcol$;" ; circlefilled "; size /4 #main.graph "up ; goto "; x; " "; y -size /4 #main.graph "down ; backcolor ";lightcol$;" ; color ";lightcol$;" ; circlefilled "; size /12 #main.graph "up ; goto "; x; " "; y +size /4 #main.graph "down ; backcolor ";lightcol$;" ; color ";lightcol$;" ; circlefilled "; size /4 #main.graph "up ; goto "; x; " "; y +size /4 #main.graph "down ; backcolor ";darkcol$;" ; color ";darkcol$;" ; circlefilled "; size /12 #main.graph "up ; goto "; x; " "; y #main.graph "down ; color ";darkcol$;" ; circle "; size /2 end sub sub About handle$ s$ = "Pour jouer :"+chr$(13) s2$ = "Vous pouvez selectionner le niveau ou jouer directement."+chr$(13) s3$ = " Puis le but sera d'aligner 4 jetons horizontalement,"+chr$(13) s4$ = " verticalement ou diagonalement. Mais gare à l'ordinateur ..."+chr$(13)+chr$(13) s5$ = "A game by uncleBen" WindowWidth = 384 WindowHeight = 336 ' UpperLeftX=int((DisplayWidth-WindowWidth)/2) ' UpperLeftY=int((DisplayHeight-WindowHeight)/2) groupbox #about.frame, "How to play", 22, 16, 336, 240 statictext #about.text, "", 38, 46, 304, 200 button #about.default, "Ok", [aboutOk], UL, 126, 270, 122, 25 open "About JB Connect4" for dialog_nf_modal as #about #about, "trapclose [aboutOk]" #about, "font ms_sans_serif 10" #about.frame, "!font ms_sans_serif 12" #about.text, s$;s2$;s3$;s4$;s5$ wait [aboutOk] close #about end sub sub CompMove depth #main.info, compThink$(int(rnd(1)*COMPUTERTHINKS)+1) n = BestMove(-1, depth) ROW(n) = ROW(n)+1 B(ROW(n),n) = -1 '#main.graph, "color ";colorPl$(2,1);" ; backcolor ";colorPl$(2,1) call DrawMove n, ROW(n), -1, 0 #main.info, makeYourMove$(int(rnd(1)*YOURTURN)+1) MOVE = CheckWin(MOVE, -1, ROW(n), n) if MOVE = 42 then #main.graph "when leftButtonDown" end sub function IsWin$(pl, row, col) if B(row-1,col)=pl and B(row-2,col)=pl and B(row-3,col)= pl then _ IsWin$ = str$(row-1); col; str$(row-2); col; str$(row-3); col if B(row,col-1)=pl and B(row,col-2)=pl and B(row,col-3)= pl then _ IsWin$ = IsWin$; row; str$(col-1); row; str$(col-2); row; str$(col-3) if B(row,col-1)=pl and B(row,col-2)=pl and B(row,col+1)= pl then _ IsWin$ = IsWin$; row; str$(col-1); row; str$(col-2); row; str$(col+1) if B(row,col-1)=pl and B(row,col+1)=pl and B(row,col+2)= pl then _ IsWin$ = IsWin$; row; str$(col-1); row; str$(col+1); row; str$(col+2) if B(row,col+1)=pl and B(row,col+2)=pl and B(row,col+3)= pl then _ IsWin$ = IsWin$; row; str$(col+1); row; str$(col+2); row; str$(col+3) if B(row+3,col-3)=pl and B(row+2,col-2)=pl and B(row+1,col-1)= pl then _ IsWin$ = IsWin$; str$(row+3); str$(col-3); str$(row+2); str$(col-2); str$(row+1); str$(col-1) if B(row+2,col-2)=pl and B(row+1,col-1)=pl and B(row-1,col+1)= pl then _ IsWin$ = IsWin$; str$(row+2); str$(col-2); str$(row+1); str$(col-1); str$(row-1); str$(col+1) if B(row+1,col-1)=pl and B(row-1,col+1)=pl and B(row-2,col+2)= pl then _ IsWin$ = IsWin$; str$(row+1); str$(col-1); str$(row-1); str$(col+1); str$(row-2); str$(col+2) if B(row-1,col+1)=pl and B(row-2,col+2)=pl and B(row-3,col+3)= pl then _ IsWin$ = IsWin$; str$(row-1); str$(col+1); str$(row-2); str$(col+2); str$(row-3); str$(col+3) if B(row-3,col-3)=pl and B(row-2,col-2)=pl and B(row-1,col-1)= pl then _ IsWin$ = IsWin$; str$(row-3); str$(col-3); str$(row-2); str$(col-2); str$(row-1); str$(col-1) if B(row-2,col-2)=pl and B(row-1,col-1)=pl and B(row+1,col+1)= pl then _ IsWin$ = IsWin$; str$(row-2); str$(col-2); str$(row-1); str$(col-1); str$(row+1); str$(col+1) if B(row-1,col-1)=pl and B(row+1,col+1)=pl and B(row+2,col+2)= pl then _ IsWin$ = IsWin$; str$(row-1); str$(col-1); str$(row+1); str$(col+1); str$(row+2); str$(col+2) if B(row+1,col+1)=pl and B(row+2,col+2)=pl and B(row+3,col+3)= pl then _ IsWin$ = IsWin$; str$(row+1); str$(col+1); str$(row+2); str$(col+2); str$(row+3); str$(col+3) if IsWin$ <> "" then IsWin$ = str$(row); str$(col); IsWin$ end function function CheckWin(CheckWin, player, row, col) s$ = IsWin$(player, row, col) if s$ <> "" then CheckWin = 42 if player = 1 then #main.info, youWin$(int(rnd(1)*HUMANWIN)+1) ' #main.graph, "color blue; backcolor blue" else #main.info, compWin$(int(rnd(1)*COMPUTERWIN)+1) ' #main.graph, "color red; backcolor red" end if for i = 1 to len(s$) step 2 x = val(mid$(s$, i, 1)) y = val(mid$(s$, i+1, 1)) call DrawMove y, x, player, 1 next i else if CheckWin = 42 then #main.info, drawMessage$(int(rnd(1)*DRAW)+1) end if end function function GetValue(player, depth, row, column) pl = 0-player if (B(row-1,column)=pl and B(row-2,column)=pl and B(row-3,column)= pl) or _ (B(row,column-1)=pl and B(row,column-2)=pl and B(row,column-3)= pl) or _ (B(row,column-1)=pl and B(row,column-2)=pl and B(row,column+1)= pl) or _ (B(row,column-1)=pl and B(row,column+1)=pl and B(row,column+2)= pl) or _ (B(row,column+1)=pl and B(row,column+2)=pl and B(row,column+3)= pl) or _ (B(row+3,column-3)=pl and B(row+2,column-2)=pl and B(row+1,column-1)= pl) or _ (B(row+2,column-2)=pl and B(row+1,column-1)=pl and B(row-1,column+1)= pl) or _ (B(row+1,column-1)=pl and B(row-1,column+1)=pl and B(row-2,column+2)= pl) or _ (B(row-1,column+1)=pl and B(row-2,column+2)=pl and B(row-3,column+3)= pl) or _ (B(row-3,column-3)=pl and B(row-2,column-2)=pl and B(row-1,column-1)= pl) or _ (B(row-2,column-2)=pl and B(row-1,column-1)=pl and B(row+1,column+1)= pl) or _ (B(row-1,column-1)=pl and B(row+1,column+1)=pl and B(row+2,column+2)= pl) or _ (B(row+1,column+1)=pl and B(row+2,column+2)=pl and B(row+3,column+3)= pl) then GetValue = -128 else if depth = 0 then exit function GetValue = -1000 for i = 3 to 9 if ROW(i) < 8 then ROW(i) = ROW(i)+1 B(ROW(i), i) = player value = -1*GetValue(0-player, depth-1, ROW(i), i)/2 B(ROW(i), i) = 0 ROW(i) = ROW(i)-1 if value > GetValue then GetValue = value if value = 64 then exit for end if end if next i end if end function function BestMove(player, depth) max = -1000 for i = 3 to 9 if ROW(i) < 8 then ROW(i) = ROW(i)+1 B(ROW(i),i) = player value = -1*GetValue(0-player, depth, ROW(i), i) B(ROW(i), i) = 0 ROW(i) = ROW(i)-1 if value > max then max = value BestList$ = str$(i) if max = 128 then exit for else if value = max then BestList$ = BestList$+str$(i) end if end if next i 'print BestList$, max BestMove = val(mid$(BestList$, int(rnd(1)*len(BestList$))+1, 1)) end function data 9 data "Hmm... Laisse moi réfléchir" data "Tu joues bien, Je le sais !" data "Je le sais, je vais gagner, laisse moi juste réfléchir." data "Silence ! Je réfléchis" data "Ne me frappe pas !" data "Silence s'il vous plait, je gagne." data "Je suis sur... je pense... dur..." data "Alors tu n'y arrive pas ? x)" data "Arrete d'aller trop vite, je ne suis plus." data 9 data "Je ne crains rien! Donne-moi ton meilleur coup !" data "Réveillez-moi quand vous êtes prêt à jouer." data "Montrez-moi ce que tu sais faire! " data "Prouve-moi que tu es le meilleur !" data "Je vais prendre une petite sieste pendant que vous comprendre cela !" data "Réfléchissez bien! Une petite erreur et vous avez terminé !" data "Vous pensez que ce n'est un tirage au sort ? " data "Je ne le crois pas! " data "Prenez votre temps." data 11 data "You win! Let's play again." data "May thoughts were wandering... You win!" data "I didn't see that coming!" data "I bet you can't beat me again!" data "Congratulations! You are almost as good as I." data "That's not fair! I had something in my eye." data "I can't believe it! You win!" data "There was a magnetic storm! I couldn't think straight..." data "It's impossible... Tell me how many moves you think ahead." data "Amazing! You are my superhero." data "I couldn't concentrate. You were moving the mouse all the time." data 11 data "Un grand bravo au gagnant du jeu !" data "Cela devrait vous donner une leçon. Vous ne gagnerais JAMAIS avec moi !" data "Vous avez perdu !" data "Nous pouvons jouer un autre partie, mais vous allez encore perdre ..." data "Je parie que vous n'avez pas vu que vous venez de perdre ." data "Nous ne pouvons rester amis !" data "Ouch! çà doit faire mal !" data "Alors, qu'est-ce que tu fais ce soir ? Tu perds ?" data "Mesdames et Messieurs, nous avons un gagnant. Devinez qui!" data "C'est une autre victoire question-sur-esprit ..." data "Je suis le roi du monde ." data 8 data "J'offre un rêve ." data "Dessine! Pourtant, vous étiez si proches ..." data "Vous m'avez mis sous beaucoup de pression, mais vous ne pouviez pas me casser!" data "Fait Nouveau Jeu maintenant ! Nous devons savoir qui est le meilleur. " data "Euh, que c'est il passé ?" data "Je leur ai dit que nous allions avoir besoin d'une plus grande carte pour cela." data "Il faut que je change mon CPU ..." data "Je vous promets, la prochaine fois je ne vais pas te laisser partir si facilement." function fileExist(path$, filename$) 'DIM info$(10,10) 'must have been declared at the start of the code. files path$, filename$, info$() ' path$ = DefaultDir$ generally... fileExist = val(info$(0, 0)) end function
Edité par cassiope01 Le 05/08/2012 à 07h43
____________________
Devise Shadocks : "Mieux vaut mobiliser son intelligence pour des conneries, que mobiliser sa connerie pour des choses intelligentes"
Coluche disait : "C'est parce que la vitesse de la lumière est plus rapide que celle du son que certains peuvent paraîtrent brillants jusqu'à ce qu'ils ouvrent la bouche."
Devise Shadocks : "Mieux vaut mobiliser son intelligence pour des conneries, que mobiliser sa connerie pour des choses intelligentes"
Coluche disait : "C'est parce que la vitesse de la lumière est plus rapide que celle du son que certains peuvent paraîtrent brillants jusqu'à ce qu'ils ouvrent la bouche."
Web
Roland:
Au pire je suis franco-britannique
Pour avoir un avis pertinent, il faudrait le montrer à un(e) prof d'anglais.
Au pire je suis franco-britannique

Ahaha! ...Alors...Super ton avatar.!..

____________________
Roro
Roro
Nephthys:
Salut Nephthys, c'est gentil de passer faire un petit cou-cou
et bien c'est une sympa proposition, car justement Alex a oublié de traduire un bloc de DATA 
Merci à toi.
@+
Edité par cassiope01 Le 05/08/2012 à 19h18
Roland:
Au pire je suis franco-britannique
Pour avoir un avis pertinent, il faudrait le montrer à un(e) prof d'anglais.
Au pire je suis franco-britannique

Salut Nephthys, c'est gentil de passer faire un petit cou-cou


Merci à toi.
@+
Edité par cassiope01 Le 05/08/2012 à 19h18
____________________
Devise Shadocks : "Mieux vaut mobiliser son intelligence pour des conneries, que mobiliser sa connerie pour des choses intelligentes"
Coluche disait : "C'est parce que la vitesse de la lumière est plus rapide que celle du son que certains peuvent paraîtrent brillants jusqu'à ce qu'ils ouvrent la bouche."
Devise Shadocks : "Mieux vaut mobiliser son intelligence pour des conneries, que mobiliser sa connerie pour des choses intelligentes"
Coluche disait : "C'est parce que la vitesse de la lumière est plus rapide que celle du son que certains peuvent paraîtrent brillants jusqu'à ce qu'ils ouvrent la bouche."
Web
Yep, je vous fais ça dès que j'ai un peu de temps

Jai oublie un bloc ? Oo
Je test sa des que je suis chez moi mais sa a l air cool
Je test sa des que je suis chez moi mais sa a l air cool
____________________
Si le meilleurs langage de programmation existe, alors le Just Basic est loin devant.
Ne me tappez pas dessus ! Je débute
Si le meilleurs langage de programmation existe, alors le Just Basic est loin devant.
Ne me tappez pas dessus ! Je débute

Web
• Index
1 Utilisateur en ligne : 0 Administrateur, 0 Modérateur, 0 Membre et 1 Visiteur
Utilisateur en ligne : Aucun membre connecté
Utilisateur en ligne : Aucun membre connecté
Répondre
Vous n'êtes pas autorisé à écrire dans cette catégorie