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
» PANORAMIC V 1
BETCHESS  Emptypar Klaus Aujourd'hui à 9:53

» Je teste PANORAMIC V 1 beta 1
BETCHESS  Emptypar Klaus Aujourd'hui à 9:52

» bouton dans autre form que 0
BETCHESS  Emptypar leclode Hier à 13:59

» KGF_dll - nouvelles versions
BETCHESS  Emptypar Klaus Hier à 11:41

» Gestion d'un système client-serveur.
BETCHESS  Emptypar Klaus Hier à 10:23

» Editeur EliP 6 : Le Tiny éditeur avec 25 onglets de travail
BETCHESS  Emptypar Froggy One Jeu 2 Mai 2024 - 11:16

» @Jack
BETCHESS  Emptypar Jack Mar 30 Avr 2024 - 20:40

» trop de fichiers en cours
BETCHESS  Emptypar papydall Lun 29 Avr 2024 - 23:39

» Une calculatrice en une ligne de programme
BETCHESS  Emptypar jean_debord Dim 28 Avr 2024 - 8:47

» Form(résolu)
BETCHESS  Emptypar leclode Sam 27 Avr 2024 - 17:59

» Bataille navale SM
BETCHESS  Emptypar jjn4 Ven 26 Avr 2024 - 17:39

» Les maths du crocodile
BETCHESS  Emptypar jean_debord Jeu 25 Avr 2024 - 10:37

» Naissance de Crocodile Basic
BETCHESS  Emptypar jean_debord Jeu 25 Avr 2024 - 8:45

» Dessine-moi une galaxie
BETCHESS  Emptypar jjn4 Lun 22 Avr 2024 - 13:47

» Erreur END_SUB
BETCHESS  Emptypar jjn4 Lun 22 Avr 2024 - 13:43

Navigation
 Portail
 Index
 Membres
 Profil
 FAQ
 Rechercher
Rechercher
 
 

Résultats par :
 
Rechercher Recherche avancée
Mai 2024
LunMarMerJeuVenSamDim
  12345
6789101112
13141516171819
20212223242526
2728293031  
CalendrierCalendrier
Le deal à ne pas rater :
Pokémon EV06 : où acheter le Bundle Lot 6 Boosters Mascarade ...
Voir le deal

 

 BETCHESS

Aller en bas 
3 participants
AuteurMessage
mimic

mimic


Nombre de messages : 103
Localisation : france
Date d'inscription : 02/09/2009

BETCHESS  Empty
MessageSujet: BETCHESS    BETCHESS  EmptyVen 8 Jan 2021 - 12:32

Dans le but d'aider Marc dans son projet de jeu d'échecs.

Voici, les règles de ma variante, suivi du code.

Il s'agît là d'une préversion ; je n'ai donc apporté que peu de soin au code, version volontairement minimaliste, un peu près fonctionnelle pour tester. De plus, ce programme a été dégrossi à l'origine sur une calculatrice.

Fonctionnement actuel du code :

Les pièces sur l'échiquier sont affichées par des numéros :
1 désigne un pion blanc, -1 un pion noir
2 désigne un cavalier blanc, 3 un fou blanc, 4 une tour, 5 la dame, 6 le Roi blanc.

Les coups sont annoncés par leurs coordonnées sous la forme E2E4.

Vous jouez avec les blancs contre l'ordinateur avec les noirs.

L'intelligence artificielle est très faible, n'étant qu'une simulation purement aléatoire sur  2 coups (la profondeur de recherche peut être modifiée dans le code sans que, actuellement, cela ne change vraiment le niveau de jeu).

LES REGLES DU JEU :

But du jeu : faire le score le plus élevé.

Valeur des pièces :
le pion vaut 1 point,
le cavalier vaut 3 points,
le fou vaut 4 points,
la tour vaut 5 points,
la dame vaut 9 points,
le roi vaut 60 points.

Les pièces et les déplacements sont les mêmes qu'aux échecs classiques, à ceci près qu'il n'existe pas :
de prise en passant,
pas de roque, pas de pat
La promotion du pion se fait uniquement en dame.
Le Roi ne peut pas se mettre en échec.

La sous-promotion immédiate :

si une pièce de valeur inférieure en capture une de valeur supérieure,
le score de l'adversaire est augmenté de la valeur de la pièce à l'origine de la prise ;
le score du joueur, auteur de la capture croît de la valeur de la pièce prise,
la pièce capturée change de camps et reste sur l'échiquier.

REGLES SPECIALES :

Les joueurs choisissent leur prochain coup, en même temps, donc à partir de la même position.

L'on ne peut pas jouer la même pièce deux fois de suite consécutives.

Exécution des coups :

si les deux adversaires veulent atteindre la même case, alors il y a conflit et aucun coup n'est effectué, mais les pièces concernées ne peuvent plus bouger, pour le coup suivant.

Dans tous les autres cas, les coups sont exécutés dans l'ordre qui permet à chaque adversaires d'effectuer un coup, qu'il soit encore légal ou non.

REGLES DE FIN DE PARTIE :

La capture d'un Roi met fin à la partie.

Si au moins l'un des joueurs n'a plus de coups disponible, la partie prends fin.

Code:
DATA 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,-4,-2,-3,-5,-6,-3,-2,-4,7,7,7,7,-1,-1,-1,-1,-1,-1,-1,-1,7,7,7,7,0,0,0,0,0,0,0,0,7,7,7,7,0,0,0,0,0,0,0,0,7,7,7,7,0,0,0,0,0,0,0,0,7,7,7,7,0,0,0,0,0,0,0,0,7,7,7,7,1,1,1,1,1,1,1,1,7,7,7,7,4,2,3,5,6,3,2,4,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
DATA 0,1,3,4,5,9,60,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,-4,-2,-3,-5,-6,-3,-2,-4,7,7,7,7,-1,-1,-1,-1,-1,-1,-1,-1,7,7,7,7,0,0,0,0,0,0,0,0,7,7,7,7,0,0,0,0,0,0,0,0,7,7,7,7,0,0,0,0,0,0,0,0,7,7,7,7,0,0,0,0,0,0,0,0,7,7,7,7,1,1,1,1,1,1,1,1,7,7,7,7,4,2,3,5,6,3,2,4,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
DATA 0,1,3,4,5,9,60,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,-4,-2,-3,-5,-6,-3,-2,-4,7,7,7,7,-1,-1,-1,-1,-1,-1,-1,-1,7,7,7,7,0,0,0,0,0,0,0,0,7,7,7,7,0,0,0,0,0,0,0,0,7,7,7,7,0,0,0,0,0,0,0,0,7,7,7,7,0,0,0,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7,7,7,7,7,7,7,7,7

DIM O,A,H,F,T,D,V,M,B,L,K,J,I,C,taille,N,S,E,G,MEM(2303)
DIM ref,ncp,tcp,nbs,dph,nsm,npm,numcp,txs,flg,txc,txr,txctr,id,vctr,dctr,cod
DIM actr,txv,txvn,txvb,txcn,txcb,txdn,txdb,stval$(144),txt$,adsim,txtc$,col,lig
LABEL DO

FOR i=0 TO 2303
READ J:MEM(I)=J
NEXT i
full_space 0:font_size 0,12
taille=40:ref=144:nbs=0:dph=1:npm=2:S=0:flg=0:txc=0:MEM(298)=114:MEM(296)=30
MEM(295)=0:MEM(297)=0:MEM(305)=0:MEM(303)=0:MEM(307)=0
for i=1 to 8
for j=1 to 8
k=12*(1+J)+1+I
button k:width k,taille:height k,taille
top k,taille*j-30:left k,taille*i+10:caption k,STR$(MEM(K))
next j
next i
button 120:width 120,taille:height 120,taille:left 120,400:caption 120,"NCP"
button 122:width 122,ref:height 122,taille:left 122,400:caption 122,"MESSAGE"
top 122,100:PROGRESS_BAR 119:LEFT 119,500:MIN 119,0
LIST 121:LEFT 121,700
LIST 123:LEFT 123,800
MEMO 124:TOP 124,150:LEFT 124,500:height 124,200
LIST 125:TOP 125,175:LEFT 125,800:height 125,200

clrctr()
DO:
lect():finjeu():autojeu()
if S=0
ITEM_ADD 124,"NOMBRE DE COUPS NOIRS :"+STR$(MEM(299))
ITEM_ADD 124,"NOMBRE DE COUPS BLANCS :"+STR$(MEM(301))
ITEM_ADD 124,"SCORE DES NOIRS :"+STR$(MEM(295))
ITEM_ADD 124,"SCORE DES BLANCS :"+STR$(MEM(297)):STOP
end_if
GOTO DO
END

SUB autojeu()
IF S=0
numcp=ncp
ELSE
IF MEM(299)<=1
numcp=0
ELSE
numcp=INT(RND(MEM(299+1008)))
END_IF
END_IF
MEM(300)=MEM(720-ref+numcp+1008)
IF S=1
N=INT(RND(MEM(301+1008)))
MEM(302)=MEM(720+ref+N+1008)
txt$=str$(numcp)+":"+str$(N)+":"+str$(MEM(300))+":"
txt$=txt$+str$(MEM(302))+":"+str$(MEM(MEM(296)+432))
REM message txt$
ELSE
jeublcs():MEM(302)=cod
END_IF
K=INT(MEM(300)/1000):L=MEM(300)-1000*K
I=INT(MEM(302)/1000):J=MEM(302)-1000*I
execp()
END_SUB

SUB jeublcs()
CLEAR 121
for id=0 TO MEM(301)-1
rem liste coups blancs
ITEM_ADD 121,STR$(MEM(720+ref+ID))
NEXT id
FILE_SAVE 121,"listcoups.txt"
if message_input("COORDONNEES", "VOTRE COUP" , "")=1
convn()
end_if
E=0
for id=0 TO MEM(301)-1
IF MEM(720+ref+ID)=cod
E=1:EXIT_FOR
END_IF
NEXT id
IF E=0
MESSAGE "COUP ILLEGAL !":jeublcs()
END_IF
MEM(307)=MEM(307)+1
CAPTION 120,str$(MEM(307))
END_SUB

SUB convn()
txtc$=message_text$
col=asc(MID$(txtc$,1,1))-64
lig=VAL(MID$(txtc$,2,1))
cod=(12*(10-lig)+col+1)*1000
col=asc(MID$(txtc$,3,1))-64
lig=VAL(MID$(txtc$,4,1))
cod=cod+(12*(10-lig)+col+1)
END_SUB

SUB simul()
IF S=0
savtmp():nsm=npm*(MEM(301)+MEM(299)):MAX 119,nsm
rem message str$(nsm)
FOR ncp=0 to ref
MEM(2159+ncp)=1
next ncp
nbs=0
END_IF
END_SUB

SUB majct()
if F*T<0              
message "ERREUR : "+str$(F)+":"+str$(T)
end_if
if 288+ref*T+A=432+MEM(296)
rem message "echec"+str$(F)+":"+str$(T)+":"+str$(A)+":"+str$(O)+":"+str$(H)
rem message txt$
end_if
MEM(288+ref*T+A)=1
END_SUB

SUB enreg()
IF MEM(305+T)<>O
ncp=MEM(300+T):MEM(720+ref*T+ncp)=1000*O+A:MEM(300+T)=ncp+1
END_IF
END_SUB

SUB tprom()
if MEM(K)=-1
if L>=111
MEM(L)=-5
MEM(296+T)=MEM(296+T)+MEM(288+5)-1
else
if MEM(I)=1
if J<=34
MEM(J)=5
MEM(296+T)=MEM(296+T)+MEM(288+5)-1
END_IF
END_IF
END_IF
END_IF
END_SUB

SUB pfort()
F=MEM(O)
for V=1 TO 8
tlim()
if H=7
EXIT_FOR
END_IF
if H*F=0
enreg():majct()
END_IF
if H*F<0
enreg():majct():EXIT_FOR
END_IF
if H*F>0
majct():EXIT_FOR
END_IF
NEXT V
END_SUB

SUB exejou(ori,ari,jou)
B=abs(MEM(ari)):D=abs(MEM(ori))
if (B>D AND B<>6)
MEM(296-jou)=MEM(296-jou)+MEM(288+D)
MEM(ari)=-1*MEM(ari)
else
MEM(ari)=MEM(ori)
tprom()
END_IF
MEM(305+jou)=ari
MEM(ori)=0
MEM(296+jou)=MEM(296+jou)+MEM(288+B)
if B=6
MEM(304+jou)=1
if s=0
flg=1
end_if    
END_IF
if jou*MEM(ari)=6
MEM(297+jou)=ari
END_IF
END_SUB
 
SUB execp()
if J=L
CAPTION 122,"CONFLIT"
MEM(306)=I:MEM(304)=K
else
if (J=K) AND (L=I)
CAPTION 122,"ECHANGE"
B=MEM(K):MEM(K)=MEM(I):MEM(304)=L:MEM(306)=J:MEM(I)=B
if MEM(I)=6
MEM(298)=K
END_IF
if B=-6
MEM(296)=I
END_IF
tprom()
else
CAPTION 122,"INDP"
C=0
if J=K
C=1
exejou(K,L,-1)
exejou(I,J,1)
else
exejou(I,J,1)
exejou(K,L,-1)
END_IF
END_IF
END_IF
tprom()
END_SUB

SUB lect()
IF (flg=1) and (S=0)
DISPLAY
MESSAGE "PARTIE TERMINEE"
END
END_IF
clrctr():J=26:lectlig():J=38:lectlig():J=50:lectlig():J=62:lectlig():J=74
lectlig():J=86:lectlig():J=98:lectlig():J=110:lectlig()
F=-6:O=MEM(296):T=-1:G=0:roi()
F=6:O=MEM(298):T=1:G=0:roi()
F=-6:O=MEM(296):T=-1:G=1:roi()
F=6:O=MEM(298):T=1:G=1:roi():simul()
IF S=0
ITEM_ADD 124,"ADR PIECE FIGEE NOIRS :"+STR$(MEM(304))
ITEM_ADD 124,"ADR PIECE FIGEE BLANCS :"+STR$(MEM(306))
IF MEM(MEM(296)+432)<>0
ITEM_ADD 124,"ROI NOIR EN ECHEC":STOP
END_IF
S=1
END_IF
END_SUB
 
SUB lectlig()
for C=0 TO 7
 O=J+C
 F=MEM(O)
IF S=0
 caption O,STR$(F)
END_IF
IF flg=0
T=1
if F<0
T=-1
END_IF
 if (F<>0) and (F<>7)  and (abs(F)<>6)
gencp()
 END_IF
END_IF
NEXT C
END_SUB

SUB gencp()
D=abs(F):V=1
select D
case 1:pion()
case 2:cavalier()
case 3:fou()
case 4:tour()
case 5:dame()
END_SELECT
END_SUB

SUB pion()
M=-13:gpion():M=-11:gpion():M=-12:dpas()
if H=0
B=T*O:M=-24
if (B>=98) or (B>-46)
dpas()
END_IF
END_IF
END_SUB

SUB gpion()
tlim()
if H<>7
if H*F<0
enreg()
END_IF
majct()
END_IF
END_SUB

SUB tlim()
A=V*M*T+O:H=MEM(A)
END_SUB

SUB dpas()
tlim()
if H=0
enreg()
END_IF
END_SUB

SUB cavalier()
M=25:tmov():M=-25:tmov():M=23:tmov():M=-23:tmov():M=10:tmov():M=-10:tmov():M=14
tmov():M=-14:tmov()
END_SUB

SUB tour()
M=1:pfort():M=-1:pfort():M=12:pfort():M=-12:pfort()
END_SUB

SUB fou()
M=13:pfort():M=-13:pfort():M=11:pfort():M=-11:pfort()
END_SUB

SUB dame()
tour():fou()
END_SUB

SUB roi()
M=13:rmov():M=-13:rmov():M=12:rmov():M=-12:rmov():M=11:rmov():M=-11:rmov()
M=1:rmov():M=-1:rmov()
END_SUB

SUB tmov()
tlim()
if H<>7
if H*F<=0
enreg()
END_IF
majct()
END_IF
END_SUB

SUB rmov()
V=1:tlim()
IF H<>7
IF G=1 and (MEM(288+ref*(-1*T)+A)=0)
IF H*F<=0
enreg()        
END_IF
majct()
END_IF
END_IF
END_SUB

SUB clrctr()
 for i=144 TO 287
 MEM(i)=0
 NEXT i
 for i=432 TO 575
 MEM(i)=0
 NEXT i
 MEM(300)=0:MEM(302)=0:MEM(301)=0:MEM(299)=0:MEM(303)=0:MEM(305)=0
END_SUB

SUB finjeu()
IF ((MEM(301)*MEM(299))=0)  OR  ((MEM(305)+MEM(303))>0)
flg=1
END_IF
IF S=1
testsim()
END_IF
END_SUB

SUB cpmax()
D=0:CLEAR 123:ncp=0:CLEAR 125
FOR numcp=0 TO MEM(299+1008)-1
ITEM_ADD 123,stval$(numcp)
ITEM_ADD 125,str$(MEM(720-ref+numcp+1008))
adsim=MEM(2159+numcp)
IF (adsim>=D) AND (adsim<>1)
D=adsim:ncp=numcp
END_IF
NEXT numcp
FILE_SAVE 123,"listvals.txt"
FILE_SAVE 125,"listcpnoirs.txt"
rem MESSAGE "les noirs jouent : "+str$(MEM(720-ref+ncp))+":"+str$(ncp)
MESSAGE "EVALUATION :"+str$(D)
END_SUB

SUB valctr(jou)
vctr=0:dctr=0
FOR id=1 TO ref
actr=287+ref*jou+id
IF MEM(actr)=1
actr=MEM(288+abs(MEM(id-1)))
IF (MEM(id-1)<>7) and (MEM(id-1)*jou<>6)
IF MEM(id-1)*jou<0
vctr=vctr+actr
ELSE
dctr=dctr+actr
END_IF
END_IF
END_IF
NEXT id
MEM(310+jou)=vctr:MEM(311+jou)=dctr
END_SUB

SUB enrval()
CLEAR 124
txs=(MEM(295)+1)/(MEM(297)+MEM(295)+2)
txcn=(MEM(299)+1)/ref:txcb=(MEM(301)+1)/ref
valctr(-1):valctr(1)
txvn=(MEM(309)+1)/101:txvb=(MEM(311)+1)/101
txdn=(MEM(310)+1)/41:txdb=(MEM(312)+1)/41
rem txr=1-(1-txs)*txcn*txvn*txdn*txcb*txvb*txdb
rem txr=(txs*txcn*txvn*txdn*txcb*txvb*txdb)
txr=1-(1-txs)*(1-txcn)*(1-txvn)*(1-txdn)*txcb*txvb*txdb
IF MEM(MEM(296)+432)<>0
txr=0
END_IF
adsim=MEM(2159+numcp)
rem If adsim<>0
rem IF (txr<adsim)
MEM(2159+numcp)=MEM(2159+numcp)*0.8+0.2*txr
stval$(numcp)=txt$+":"+str$(MEM(2159+numcp))+":"+str$(MEM(296))
stval$(numcp)=stval$(numcp)+":"+str$(MEM(MEM(296)+432))
rem END_IF
rem END_IF
dph=1:flg=0:restmp()
IF nbs<nsm
nbs=nbs+1:display
ELSE
S=0:nbs=0:cpmax()
END_IF
END_SUB

SUB testsim()
rem PRINT_LOCATE 400,300:PRINT str$(dph)+":"+str$(nbs)
POSITION 119,nbs
IF (dph>npm) or (flg=1)
enrval()
else
dph=dph+1
end_if
END_SUB

SUB savtmp()
FOR I=0 TO 1007
MEM(1008+I)=MEM(I)
NEXT I
END_SUB

SUB restmp()
FOR I=0 TO 1007
MEM(I)=MEM(1008+I)
NEXT I
END_SUB
Revenir en haut Aller en bas
Marc

Marc


Nombre de messages : 2389
Age : 63
Localisation : TOURS (37)
Date d'inscription : 17/03/2014

BETCHESS  Empty
MessageSujet: Re: BETCHESS    BETCHESS  EmptyVen 8 Jan 2021 - 13:59

Merci beaucoup Mimic pour ton partage !

J'étudierai ton code ce soir.

Bon après midi !
Revenir en haut Aller en bas
mimic

mimic


Nombre de messages : 103
Localisation : france
Date d'inscription : 02/09/2009

BETCHESS  Empty
MessageSujet: Re: BETCHESS    BETCHESS  EmptyDim 10 Jan 2021 - 15:48

Voici une nouvelle version légèrement commentée, avec une évaluation simplifiée et un peu améliorée.


Code:
DATA 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,-4,-2,-3,-5,-6,-3,-2,-4,7,7,7,7,-1,-1,-1,-1,-1,-1,-1,-1,7,7,7,7,0,0,0,0,0,0,0,0,7,7,7,7,0,0,0,0,0,0,0,0,7,7,7,7,0,0,0,0,0,0,0,0,7,7,7,7,0,0,0,0,0,0,0,0,7,7,7,7,1,1,1,1,1,1,1,1,7,7,7,7,4,2,3,5,6,3,2,4,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
DATA 0,1,3,4,5,9,60,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,-4,-2,-3,-5,-6,-3,-2,-4,7,7,7,7,-1,-1,-1,-1,-1,-1,-1,-1,7,7,7,7,0,0,0,0,0,0,0,0,7,7,7,7,0,0,0,0,0,0,0,0,7,7,7,7,0,0,0,0,0,0,0,0,7,7,7,7,0,0,0,0,0,0,0,0,7,7,7,7,1,1,1,1,1,1,1,1,7,7,7,7,4,2,3,5,6,3,2,4,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
DATA 0,1,3,4,5,9,60,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,-4,-2,-3,-5,-6,-3,-2,-4,7,7,7,7,-1,-1,-1,-1,-1,-1,-1,-1,7,7,7,7,0,0,0,0,0,0,0,0,7,7,7,7,0,0,0,0,0,0,0,0,7,7,7,7,0,0,0,0,0,0,0,0,7,7,7,7,0,0,0,0,0,0,0,0,7,7,7,7,1,1,1,1,1,1,1,1,7,7,7,7,4,2,3,5,6,3,2,4,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7

DIM O,A,H,F,T,D,V,M,B,L,K,J,I,C,taille,N,S,E,G,MEM(2303),savnpm
DIM ref,ncp,tcp,nbs,dph,nsm,npm,numcp,txs,flg,txc,txr,txctr,id,vctr,dctr,cod
DIM actr,txv,txvn,txvb,txcn,txcb,txdn,txdb,stval$(144),txt$,adsim,txtc$,col,lig
LABEL DO

rem O case origine A case arrivee F contenu a origine H contenu a arrivee
rem T couleur piece G drapeaux activation enregistremen mouvements roi
rem M valeur pas de deplacement piece
rem S drapeaux activation simulation, nsm nombre simulation totale
rem dph profondeur de recherche, npm profondeur maximale de recherche
rem savnpm sauvegarde profondeur maximale npm
rem nbs nombre de simulation realisee
rem flg drapeaux detection arret partie
rem cod code representant le coup blanc joue
rem numcp numero du coup joue
rem txr=taux de reussite noir evalue, txs=taux score noirs
rem txcn=taux mouvement possible noir,txcb=taux mouvement possible blancs
 
FOR i=0 TO 431
READ J:MEM(I)=J
NEXT i
full_space 0:font_size 0,12
taille=40:ref=144:nbs=0:dph=1:npm=2:S=0:flg=0:txc=0:MEM(298)=114:MEM(296)=30
MEM(295)=0:MEM(297)=0:MEM(305)=0:MEM(303)=0:MEM(307)=0:savnpm=1
for i=1 to 8
for j=1 to 8
k=12*(1+J)+1+I
button k:width k,taille:height k,taille
top k,taille*j-30:left k,taille*i+10:caption k,STR$(MEM(K))
next j
next i
button 120:width 120,taille:height 120,taille:left 120,400:caption 120,"NCP"
button 122:width 122,ref:height 122,taille:left 122,400:caption 122,"MESSAGE"
top 122,100:PROGRESS_BAR 119:LEFT 119,500:MIN 119,0
LIST 121:LEFT 121,700
LIST 123:LEFT 123,800
MEMO 124:TOP 124,150:LEFT 124,500:height 124,200
LIST 125:TOP 125,175:LEFT 125,800:height 125,200

clrctr()
DO:
lect():finjeu():autojeu()
if S=0
ITEM_ADD 124,"NOMBRE DE COUPS NOIRS :"+STR$(MEM(299))
ITEM_ADD 124,"NOMBRE DE COUPS BLANCS :"+STR$(MEM(301))
ITEM_ADD 124,"SCORE DES NOIRS :"+STR$(MEM(295))
ITEM_ADD 124,"SCORE DES BLANCS :"+STR$(MEM(297)):STOP
end_if
GOTO DO
END

SUB autojeu()
IF S=0
numcp=ncp
ELSE
IF MEM(299)<=1
numcp=0
ELSE
numcp=INT(RND(MEM(299+1008)))
END_IF
END_IF
MEM(300)=MEM(720-ref+numcp+1008)
IF S=1
N=INT(RND(MEM(301+1008)))
MEM(302)=MEM(720+ref+N+1008)
txt$=str$(numcp)+":"+str$(N)+":"+str$(MEM(300))+":"
txt$=txt$+str$(MEM(302))+":"+str$(MEM(MEM(296)+432))
REM message txt$
ELSE
jeublcs():MEM(302)=cod
END_IF
K=INT(MEM(300)/1000):L=MEM(300)-1000*K
rem K case origine piece jouee par les noirs
rem L case arrivee piece jouee par les noirs
I=INT(MEM(302)/1000):J=MEM(302)-1000*I
rem I case origine piece jouee par les blancs
rem J case arrivee piece jouee par les blancs
execp()
END_SUB

SUB jeublcs()
CLEAR 121
for id=0 TO MEM(301)-1
rem liste coups blancs
ITEM_ADD 121,STR$(MEM(720+ref+ID))
NEXT id
FILE_SAVE 121,"listcoups.txt"
if message_input("COORDONNEES", "VOTRE COUP" , "")=1
convn()
end_if
E=0
for id=0 TO MEM(301)-1
IF MEM(720+ref+ID)=cod
E=1:EXIT_FOR
END_IF
NEXT id
IF E=0
MESSAGE "COUP ILLEGAL !":jeublcs()
END_IF
MEM(307)=MEM(307)+1
CAPTION 120,str$(MEM(307)):rem nombre coups total joues
END_SUB

SUB convn()
txtc$=message_text$
col=asc(MID$(txtc$,1,1))-64
lig=VAL(MID$(txtc$,2,1))
cod=(12*(10-lig)+col+1)*1000
col=asc(MID$(txtc$,3,1))-64
lig=VAL(MID$(txtc$,4,1))
cod=cod+(12*(10-lig)+col+1)
END_SUB

SUB simul()
IF S=0
savtmp():nsm=npm*(MEM(301)+MEM(299)):MAX 119,nsm
rem message str$(nsm)
FOR ncp=0 to ref
MEM(2159+ncp)=1
next ncp
nbs=0
END_IF
END_SUB

SUB majct()
if F*T<0              
message "ERREUR : "+str$(F)+":"+str$(T)
end_if
MEM(288+ref*T+A)=1
END_SUB

SUB enreg()
IF MEM(305+T)<>O
ncp=MEM(300+T):MEM(720+ref*T+ncp)=1000*O+A:MEM(300+T)=ncp+1
END_IF
END_SUB

SUB tprom()
if MEM(K)=-1
if L>=111
MEM(L)=-5
MEM(296+T)=MEM(296+T)+MEM(288+5)-1
else
if MEM(I)=1
if J<=34
MEM(J)=5
MEM(296+T)=MEM(296+T)+MEM(288+5)-1
END_IF
END_IF
END_IF
END_IF
END_SUB

SUB pfort()
F=MEM(O)
for V=1 TO 8
tlim()
if H=7
EXIT_FOR
END_IF
if H*F=0
enreg():majct()
END_IF
if H*F<0
enreg():majct():EXIT_FOR
END_IF
if H*F>0
majct():EXIT_FOR
END_IF
NEXT V
END_SUB

SUB exejou(ori,ari,jou)
B=abs(MEM(ari)):D=abs(MEM(ori))
if (B>D AND B<>6)
MEM(296-jou)=MEM(296-jou)+MEM(288+D)
MEM(ari)=-1*MEM(ari)
else
MEM(ari)=MEM(ori)
tprom()
END_IF
MEM(305+jou)=ari
MEM(ori)=0
MEM(296+jou)=MEM(296+jou)+MEM(288+B)
if B=6
MEM(304+jou)=1
if s=0
flg=1
end_if    
END_IF
if jou*MEM(ari)=6
MEM(297+jou)=ari
END_IF
END_SUB
 
SUB execp()
if J=L
CAPTION 122,"CONFLIT"
MEM(306)=I:MEM(304)=K
else
if (J=K) AND (L=I)
CAPTION 122,"ECHANGE"
B=MEM(K):MEM(K)=MEM(I):MEM(304)=L:MEM(306)=J:MEM(I)=B
if MEM(I)=6
MEM(298)=K
END_IF
if B=-6
MEM(296)=I
END_IF
tprom()
else
CAPTION 122,"INDP"
C=0
if J=K
C=1
exejou(K,L,-1)
exejou(I,J,1)
else
exejou(I,J,1)
exejou(K,L,-1)
END_IF
END_IF
END_IF
tprom()
END_SUB

SUB lect()
IF (flg=1) and (S=0)
DISPLAY
MESSAGE "PARTIE TERMINEE"
END
END_IF
clrctr():J=26:lectlig():J=38:lectlig():J=50:lectlig():J=62:lectlig():J=74
lectlig():J=86:lectlig():J=98:lectlig():J=110:lectlig()
F=-6:O=MEM(296):T=-1:G=0:roi()
F=6:O=MEM(298):T=1:G=0:roi()
F=-6:O=MEM(296):T=-1:G=1:roi()
F=6:O=MEM(298):T=1:G=1:roi():simul()
IF S=0
ITEM_ADD 124,"ADR PIECE FIGEE NOIRS :"+STR$(MEM(304))
ITEM_ADD 124,"ADR PIECE FIGEE BLANCS :"+STR$(MEM(306))
IF MEM(MEM(296)+432)<>0
ITEM_ADD 124,"ROI NOIR EN ECHEC":STOP
savnpm=npm:npm=1
ELSE
npm=savnpm
END_IF
S=1
END_IF
END_SUB
 
SUB lectlig()
for C=0 TO 7
 O=J+C
 F=MEM(O)
IF S=0
 caption O,STR$(F)
END_IF
IF flg=0
T=1
if F<0
T=-1
END_IF
 if (F<>0) and (F<>7)  and (abs(F)<>6)
gencp()
 END_IF
END_IF
NEXT C
END_SUB

SUB gencp()
D=abs(F):V=1
select D
case 1:pion()
case 2:cavalier()
case 3:fou()
case 4:tour()
case 5:dame()
END_SELECT
END_SUB

SUB pion()
M=-13:gpion():M=-11:gpion():M=-12:dpas()
if H=0
B=T*O:M=-24
if (B>=98) or (B>-46)
dpas()
END_IF
END_IF
END_SUB

SUB gpion()
tlim()
if H<>7
if H*F<0
enreg()
END_IF
majct()
END_IF
END_SUB

SUB tlim()
A=V*M*T+O:H=MEM(A)
END_SUB

SUB dpas()
tlim()
if H=0
enreg()
END_IF
END_SUB

SUB cavalier()
M=25:tmov():M=-25:tmov():M=23:tmov():M=-23:tmov():M=10:tmov():M=-10:tmov():M=14
tmov():M=-14:tmov()
END_SUB

SUB tour()
M=1:pfort():M=-1:pfort():M=12:pfort():M=-12:pfort()
END_SUB

SUB fou()
M=13:pfort():M=-13:pfort():M=11:pfort():M=-11:pfort()
END_SUB

SUB dame()
tour():fou()
END_SUB

SUB roi()
M=13:rmov():M=-13:rmov():M=12:rmov():M=-12:rmov():M=11:rmov():M=-11:rmov()
M=1:rmov():M=-1:rmov()
END_SUB

SUB tmov()
tlim()
if H<>7
if H*F<=0
enreg()
END_IF
majct()
END_IF
END_SUB

SUB rmov()
V=1:tlim()
IF H<>7
IF G=1 and (MEM(288+ref*(-1*T)+A)=0)
IF H*F<=0
enreg()        
END_IF
majct()
END_IF
END_IF
END_SUB

SUB clrctr()
 for i=144 TO 287
 MEM(i)=0
 NEXT i
 for i=432 TO 575
 MEM(i)=0
 NEXT i
 MEM(300)=0:MEM(302)=0:MEM(301)=0:MEM(299)=0:MEM(303)=0:MEM(305)=0
END_SUB

SUB finjeu()
IF ((MEM(301)*MEM(299))=0)  OR  ((MEM(305)+MEM(303))>0)
flg=1
END_IF
IF S=1
testsim()
END_IF
END_SUB

SUB cpmax()
D=0:CLEAR 123:ncp=0:CLEAR 125
FOR numcp=0 TO MEM(299+1008)-1
ITEM_ADD 123,stval$(numcp)
ITEM_ADD 125,str$(MEM(720-ref+numcp+1008))
adsim=MEM(2159+numcp)
IF (adsim>=D) AND (adsim<>1)
D=adsim:ncp=numcp
END_IF
NEXT numcp
FILE_SAVE 123,"listvals.txt"
FILE_SAVE 125,"listcpnoirs.txt"
rem MESSAGE "les noirs jouent : "+str$(MEM(720-ref+ncp))+":"+str$(ncp)
MESSAGE "EVALUATION :"+str$(D)
END_SUB

SUB testsim()
rem PRINT_LOCATE 400,300:PRINT str$(dph)+":"+str$(nbs)
POSITION 119,nbs
IF (dph>npm) or (flg=1)
enrvpos()
else
dph=dph+1
end_if
END_SUB

SUB savtmp()
FOR I=0 TO 1007
MEM(1008+I)=MEM(I)
NEXT I
END_SUB

SUB restmp()
FOR I=0 TO 1007
MEM(I)=MEM(1008+I)
NEXT I
END_SUB

SUB enrvpos()
CLEAR 124
txs=(MEM(295)+1)/(MEM(297)+MEM(295)+2)
txcn=(MEM(299)+1)/ref:txcb=(MEM(301)+1)/ref
txr=(1-txs)*txcb*(1-txcn)
IF MEM(MEM(296)+432)<>0
txr=0
END_IF
IF npm=1                        
if txr<MEM(2159+numcp)
MEM(2159+numcp)=txr
END_IF
ELSE
adsim=MEM(2159+numcp)
MEM(2159+numcp)=MEM(2159+numcp)*0.8+0.2*txr
END_IF
stval$(numcp)=txt$+":"+str$(MEM(2159+numcp))+":"+str$(MEM(296))
stval$(numcp)=stval$(numcp)+":"+str$(MEM(MEM(296)+432))
dph=1:flg=0:restmp()
IF nbs<nsm
nbs=nbs+1:display
ELSE
S=0:nbs=0:cpmax()
END_IF
END_SUB
Revenir en haut Aller en bas
jean_debord

jean_debord


Nombre de messages : 1250
Age : 69
Localisation : Limoges
Date d'inscription : 21/09/2008

BETCHESS  Empty
MessageSujet: Re: BETCHESS    BETCHESS  EmptyVen 8 Oct 2021 - 11:30

Un autre article qui pourrait être intéressant :

https://www.codeproject.com/Articles/5313417/Worlds-Fastest-Bitboard-Chess-Movegenerator

Je n'ai pas regardé en détail. C'est tout en C++. Je ne sais pas si c'est adaptable.
Revenir en haut Aller en bas
http://www.unilim.fr/pages_perso/jean.debord/index.htm
Marc

Marc


Nombre de messages : 2389
Age : 63
Localisation : TOURS (37)
Date d'inscription : 17/03/2014

BETCHESS  Empty
MessageSujet: Re: BETCHESS    BETCHESS  EmptySam 9 Oct 2021 - 13:05

Ah oui ! Magnifique !

Citation :
This movegenerator can generate 2 billion chessmoves per thread and per second!

Deux milliards de coups d’échecs par seconde et par thread ! C'est époustouflant !

Merci Jean pour le partage.

Adaptable : non, l’algorithme est basé sur des entiers non-signés de 64bits.
Les 64 cases de l’échiquier sont mappées dans ces entiers.
Revenir en haut Aller en bas
jean_debord

jean_debord


Nombre de messages : 1250
Age : 69
Localisation : Limoges
Date d'inscription : 21/09/2008

BETCHESS  Empty
MessageSujet: Re: BETCHESS    BETCHESS  EmptySam 9 Oct 2021 - 16:48

Dans FBCroco on a les entiers de 64 bits non signés :

Code:

dim n%*8u     ' 8 octets, unsigned

Je vais regarder si on peut faire quelque chose.
Revenir en haut Aller en bas
http://www.unilim.fr/pages_perso/jean.debord/index.htm
Contenu sponsorisé





BETCHESS  Empty
MessageSujet: Re: BETCHESS    BETCHESS  Empty

Revenir en haut Aller en bas
 
BETCHESS
Revenir en haut 
Page 1 sur 1

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: