Programming A Mini Chess in Phyton
Programming A Mini Chess in Phyton
„ Pico-Schach“
Do we all have time in the “world”? The subject of “Time and Heaven” is covered in
the “Appendix” of this book.
With this in mind, I wish all readers a lot of fun with programming.
Gerald Wartensteiner
Pico means something like "trillionth" - that is very small. The amount of work involved in programming
a “chess program” on 64 fields is very large. So the author has made up his mind. To program a very small
chess on 20 fields, so to speak, as an "experiment" without any special requirements. Phyton was used as the
programming language. Goal of this project it was the "construction fundamentals" to roughly understand the
blueprint of a chess program. The current state of knowledge of chess programming is only rudimentary
at | 4 + 5 |Chess. Rather, the program is its own "programming creation".
For a long time the author was moved by the question: "How does the chess computer make its move".
What is the secret of the chess programs? Unfortunately there is almost no literature on this Theme. It is also
only possible to program already with a very high expenditure of time „Understand“ existing chess programs.
Sometimes the programmers work studied computer scientists or mathematicians for years on a good chess
program. You can't live from it. Only the writers of top chess programs can dated Sell the software live.
| 4 + 5 | Chess is played on a 4x5 field. The farmers can move forward one space at a time. If the pawns have
reached the baseline, they are automatically converted into a queen. The towers and the queen as well as the
king are present on figures.
The pieces are set up according to "Silverman 1981", a chess variant, whereby all chess rules apply - with the
exception of castling and the double pawn step.
Knight and bishop are missing in | 4 + 5 | Chess. The edge fields are assigned a number in the course of chess
programming. For | 4 + 5 | ChessJ this is the "2".
The pieces are represented in the chess program with numbers. In our case, the ones (1) stand for the black
pawns. Four (4) represents the black rooks, 8 represents the black queen and 9 represents the black king. The
negative numbers, i.e. the minus ones (-1), stand for the white pawns. The number -4 represents the white
rooks, -8 stands for the white queen and -9 is the substitute number for the white king. The empty fields are gi-
ven a zero (0). These numbers also roughly represent the material value. The material value of the lady is obtai-
ned alternatively by two towers (2x4 = 8). The pawns have a material value of one (1 = one pawn unit). If you
add up all the black numbers you get the material value plus 29 for the white side, the opposite is the material
value for the black pieces, i.e. minus 29. The 4x5 chess field is surrounded by twos (2). These two are used for
programming.
Array Offsets
You also need an array. This array can be looked at like clear paper with numbers which is exactly above the
figure field. The Moving figures. Above the number -4 in the figure field is the number 31 in the array. So if the
-4 (rock white) is moved, the -4 can be the white rock from the array 31-25 and 31-19, 31-13 and so on. 31-
7drive. The individual driving options or steps can be easily calculated.
The black rock moves from array no. 7 to array no.13 exactly 13-7 = 6 steps, so that's the
black rook advanced one space. These driving possibilities of the figures are called offsets. At the same time the
black rock can move to the right, i.e. from array number 7 to number 8
for this he needs 8-7 = 1 which corresponds to an offset step. The drawing with the arrows
shows this. So white rock to the left corresponds to an offset step of -1.
White rock to the right corresponds to an offset step from 1. Rock down corresponds to
6 and up the -6. These offset steps apply to both white and black.
For the direction of travel of the queen, the diagonal directions also apply, i.e. after
diagonally above below -5 and 5. Arrow direction to the left (offset +7) corresponds to, for example
Moving the queen from square 8 -15.
Component overview:
The field input and output is done with the program parts array and figure field representation
carried out as described above. The necessary calculation operations can now be transferred to the Phyton
programming language on the basis of the theoretical considerations.
The move generator calculates all possible moves of the white stones and all
Moving possibilities of the black stones.
The move generator calculates the movement possibilities for the black tower
according to the recipe as follows:
Practically it looks like this - in the program the „moves“ are collected in a list, for example the rock moves in a
rock move list. At the beginning the computer saves the rock moves = [] as an empty list. After executing the re-
cipe are possible rock moves in a list as follows: [7,13,7,19,7,25]. Please note that these moves are "pseudo-
legal", i.e. illegal king moves are also saved. These will then be dealt with separately later.
Finally, all black moves are separated from the white in one List collected, the same is done with white moves.
It looks like this, for example:
The example is a move list for "Black", the numbers are separated by commas.
"Black" can therefore drive from field 21-26 and from field 10 to field 9 etc.
As you can see, such a move generator is a lot of work. That is also important
it works flawlessly, it should have the right moves in every chess position
determine for "white" and "black".
The so-called "material value count" is also important. The computer makes internal moves in the program (in your head,
so to speak) and calculates the material value of the position for each move.
The material value is very easy to calculate. The individual material values of the red figures (black) are added together. If
the red (black) side still has a rook and a pawn and the king as well, then the material value is 4 + 1 + 8 = 13. In return, the
material value of the blue (white) figures is calculated. For example, if blue (white) has a rook and a king, the material va-
lue is -4 + (- 8) = -12. The material difference is 1, i.e. the red (black) side is one point ahead. Now the computer anticipa-
tes all possible red (black) moves and calculates the material value for the moves. At the same time, all possible response
moves on the blue (white) side are calculated in advance. The computer thinks: "If I drive with the red (black) queen from
field 8 to field 32, what answer options does the blue (white) side have and what is my material value and that of my op-
ponent". In order to find out, all possible moves are carried out on a trial basis and the material value of the "chess posi-
tion" and the associated position image (chess diagram) are calculated. In this case, the difference in material is interes-
ting, so if I were to drive from field 8 to field 32 and my opponent makes all possible moves, how big are the material diffe-
rences? Likewise, if I were to drive the pawn from square 15 to square 21, the computer asks itself, which answer moves
would my opponent have and how big are the material differences? This difference is calculated for all possible moves.
The representation shows possible moves in the form of a "chess tree". The square boxes are called nodes. All X, Y, Z stand
for possible moves of red, whereby not all possible moves are shown. Possible moves are, for example, the red pawn mo-
ve 15-21 or the queen move 8-32. Possible answer moves from blue are rook 31-32, pawn 28-21, queen 32-8 and other
moves that cannot be seen in the tree. The computer has the red pieces and always chooses the move that has the smal-
lest material difference to blue, so the computer plays a draw.
(He spares the human opponent). As can be seen from the illustration, he selects the move with the material difference of
0 for this purpose, namely queen from square 8 to square 32. The computer writes the material differences in the Dif list
(difference list ), he writes possible moves in the move list, and he writes the material differences in the MiD list.
So the first possible move is from fields 8-32 etc. as in the above move list of the computer
cited. The computer now executes and calculates all moves with the help of the move generator
for each move the points of the material. Simply the numbers 4 + 8 + 9 + 4 + 1 + 1 + 1 that results in the
Material sum of "black" (red) is 28 for this position. All possible at the same time
Counter-moves of the "white" (human) are calculated and the material sum for "white" is determined.
For this position, all possible moves must be calculated and evaluated.
At the same time, the material differences (Dif) of the chess positions “black” (red) and “white” (blue) are cal-
culated.
The queen move (red) from fields 8-32 is carried out on a trial basis and the material sum is calculated,
that is 28. Now all white answer moves are calculated and the material difference is determined.
If "black" has fewer material points after the white counter move, these differences are entered in the list of
differences. If “White” (blue) takes the queen with the rook, “White” also has 28 points. The material diffe-
rence between “black” (red) and “white” (“blue) is therefore zero (28-28 = 0).
This is stated in the difference list (Dif =) with the empty list [] in the first position.
The computer now calculates the maximum of all material differences, see list of differences (Dif).
So he looks for the maximum of [1,8] that is 8, as well as of [8,8] that is again 8 and from zero [],
so nothing - that is []. He writes these maximum values in the MiD list.
He looks for the smallest number (minimum) from the MiD list, so that is [] means zero.
The zero [] is in the 1st position in the MiD list, so he makes the 1st move from the move list (move):
White (bl) can only reach the next move see point differences
Black (ro) chooses the
move where white can achieve the least = minimum >
first entry in the list is minimum
The moving possibilities are carried out on a trial basis and the material difference is calculated
RED chooses the move where blue can reach the least = minimum, hence queen 8-32
The double underlined line shows the material difference in the positional images after the move from "BLUE".
This is "zero" so 0 = [], and 1 and 8 = [1,8]. If you look at the Dif list, these differences are in the list. The computer (RED)
selects the LEFT OF THE SOLUTION which has the smallest material differences after the counter-move of "BLUE". There-
fore he chooses the move Queen 8-32. For the right side of the subtree, the computer calculates a material difference
of 1 or 8, for the draw option pawn 15-21. Since 1 or 8 is greater than "zero", he discards this option. He also examines
the possible moves 16-22, 8-14, 8-20, 8-26, 9-14 - the difference in material between these moves is greater than "zero",
so this is of no interest for the time being.
It should also be mentioned that he tests and calculates all possible moves on level 1 and level 2.
Programming a mini chess in phyton 9
9. The chess program gets a chess
| 4 + 5 | Chess gets a chess "a look into the future"
| 4 + 5 | Schach is looking into the future with two half moves. That corresponds to a mini chess tree
with a very simple material evaluation function, so | 4 + 5 | Chess
even just about a “mini” chess knowledge.
Testing „Moves“
White (bl) can only reach the next move see point differences
Black (ro) chooses the move where white can reach the least = minimum
In the dif-list there is mainly the number 9, i.e. 9 points difference between what the
Material value corresponds to the king. The computer can also lose the "king",
it can be captured on the next move. The only alternative is escape field 7
The computer selects the minimum from the MiD list, which is the empty list [], ie zero.
The zero [] is in fourth position in the MiD list, so the computer chooses from the
Move list (move) the fourth move, i.e. 8-7, this move is made.
| 4 + 5 | Chess is still imperfect - full of "bugs", an experiment, so to speak,
for this reason a comment section has been implemented.
So "| 4 + 5 | ChessJ" adds its mustard with every move.
The reader may find this sometimes more or sometimes less pleasant.
For demonstration purposes, a game with | 4 + 5 | Chess follows
MOVE 1: The | 4 + 5 | chess takes the pawn, which results in a point material advantage
MOVE 2: The | 4 + 5 | chess takes the queen, so the program has 8 points more
MOVE 3: The author takes the queen of | 4 + 5 | chess with the rook, therefore equalizing points
TRAIN 4: The author occupies the 4th row with the „rock“
Move 5: The author tests how | 4 + 5 | chess reacts when he plays "very stupid"
MOVE 5: | 4 + 5 | Chess moves the pawn forward one space on the d-row
MOVE 6: The author "gives away" his "rock", the gift is not accepted
MOVE 7: The | 4 + 5 | chess transforms the pawn into a queen and gives "chess"
MOVE 8: The author takes the black queen with his white king
MOVE 9: The author comfortably moves one field forward with the white "rock"
MOVE 9: | 4 + 5 | Chess takes the white rook, so his material advantage is 8 points
MOVE 10: The author takes the rook from | 4 + 5 | chess with the king
MOVE 10: Finally, the program "| 4 + 5 | Chess" takes the white pawn, thus
the material advantage of black [| 4 + 5 | chess] is a total of 14-9 = 5 points.
Conclusion
As my first hobby chess program, | 4 + 5 | SchachJ is not yet perfect. There is still a lot
to improve. So sometimes there are several good moves, but the program chooses
always select the first move from the MiD list. Another evaluation function could be used here
programmed to solve this problem.
Also, the royal security is not guaranteed in every case, from time to time it arises
the king went illegally into chess to the amusement. The author has these problems
already solved on the other hand, the reader of these lines should have fun programming,
so that would be a bit of a challenge.
According to the MiD list there are two "good" moves - zero is shown in the 1st position of the MiD list
with 2 empty square brackets. However, the zero also appears in the 2nd position on the MiD list.
However, the program always plays the move that comes first on the MiD list
stands, so an additional evaluation function would have to calculate whether move 1 or
Move 2 is better. In the event that the king is in chess, he could have his own „Part“ of the program.
Chess programs calculate evaluation numbers. The move with the best
Evaluation number is executed. Chess programming is a numbers game
and functions. There are certain theoretical bases but these were used at
| 4 + 5 | Chess intentionally only partially implemented, so it is an easy one
Explainability guaranteed.
If you assign x range (0,10,2), the list field (row of two) is called
from now on x. For i in x means that the computer will select every x in the list
should, just me. There are 5 numbers in the list, so this statement becomes
repeated 5 times. The following print i statement prints the row of two.
This is a so-called for loop, i.e. a repetition statement.
The pop () instruction clears the last number in the list. If you put x before pop (),
then the last number is deleted from the list x.
Since the result of len (x) = 5, is 5, the following repetition statement for i in range
(len (x)) is executed five times, where The print i statement prints all five numbers in
the list x.
With x.remove (99) you can remove the number 99 from the list.
the computer should do something. The break statement on the line below says
from what to do. Break stands for "interrupt". Break the iteration loop when i equals 3.
As a result, the 7 series is only printed up to 3x7.
This code assigns five numbers to the variable field-list. With print the
List printed out.
Then the numbers in the list are sorted, which is what the
Command "feldliste.sort ()" and printed out.
The instruction max (field list) determines the maximum, i.e. the largest number,
min (field list) is the smallest number.
If you want to copy the list, the command [:] creates a new list.
The copy can be given any name, in our case the list is called
simply "copy".
You can of course add several numbers to a list, this is done with
the command feldliste.list.extend (see below). The code example shows the procedure.
If the 2nd number is to be output in the field, write print feldliste [1].
The 1st number in the field is assigned to the expression field list [0].
Should be the maximum of the list [1,2], which is in the main list a
are determined, this can be done with max ([a4]). The minimum will be
determined with min ([a4]).
If one wants to multiply the first number of the list b, the instruction is
b [0] = b [0] * 2 expedient.
If you want to calculate with strings (names, operators), the use of the
"Eval function" makes sense. The instruction eval (`three * four`) calculates 3x4,
if three = 3 and four = 4 are defined. The example shows another
Possible application of eval. A numberA and a numberB become the
Numbers 3.5 and 2.0 assigned in string form. Also an "operator"
defined with times *. The strings are added up, that's done
the command Evaluate = numberA + operator + numberB. Lastly, the expression
calculated by eval (evaluation), i.e. 2.0 * 3.5 = 7.0 is calculated.
Calculate the result and print it out with the print statement.
q=[]
print'***********',' ''***************'
voon=0;biis=0
for a in range(1,100):#anzahl der zuge
# hier zugeingabe
Programming a mini chess in phyton 27
voon=input('Feldnummer von-> ')
biis=input('Feldnummer bis-> ')
f[biis]=f[voon]#ausfuehern
f[voon]=0
#print'***************'
#print f[7:11]
#print f[13:17]
#print f[19:23]
#print f[25:29]
#print f[31:35]
#print'***************'
#damverwandlung
if f[7]==-1:
f[7]=-8
if f[8]==-1:
f[8]=-8
if f[9]==-1:
f[9]=-8
if f[10]==-1:
f[10]=-8
q=[]
for i in f:
if i==3:
q.append('L')
if i==5:
q.append('S')
if i==4:
q.append('T')
if i==8:
q.append('D')
if i==9:
q.append('K')
if i==1:
q.append('+')
if i==0:
q.append('.')
if i==-3:
q.append('l')
if i==-5:
q.append('s')
if i==-4:
q.append('t')
if i==-8:
q.append('d')
if i==-9:
q.append('k')
if i==-1:
q.append('*')
print'***********',' ''***************'
print'*',q[0],q[1],q[2],q[3],'*',' *'' 7 8 9 10 *'
print'*', q[4],q[5],q[6],q[7],'*',' *'' 13 14 15 16 *'
print'*', q[8],q[9],q[10],q[11],'*',' *'' 19 20 21 22 *'
print'*', q[12],q[13],q[14],q[15],'*',' *'' 25 26 27 28 *'
print'*', q[16],q[17],q[18],q[19],'*',' *'' 31 32 33 34 *'
print'***********',' ''***************'
q=[]
turmzuge=[];turmschlag=[]
k=0;ad=0 # dazuzaehlen fuer turmposition
for n in turmpositionschwarz:
for v in range(1,5): #fuer die Richtungen 4x
if v==1:
ad=6 #ad fuer nach unten
if v==2:
ad=-6 #ad fuer nach oben
if v==3:
ad=1 #ad fuer nach rechts
if v==4:
ad=-1
#nach unten suchen
z=0;abbruchwert=0
for i in range(1,5): # ab turmposition schleife z.bsp 4x
z=z+ad
if f[turmpositionschwarz[0+k]+z]!=0:
break
else:
turmzuge.append(n) #von
turmzuge.append(turmpositionschwarz[0+k]+z) #bis
abbruchwert=z
#Restglied dazu wenn unter null=feind
if f[turmpositionschwarz[0+k]+abbruchwert+ad]<0:
turmschlag.append(n)
turmschlag.append(turmpositionschwarz[0+k]+abbruchwert+ad)
# wenn 2 tuerme k anders weil zweiter turm
if su==2:
k=1
damger=[];damschl=[]
damger.extend(damzuges)
damger.extend(damzuge)
damschl.extend(damschlags)
damschl.extend(damschlag)
#turmpositonweiss
turmpositionweiss=[]#Turmzuege
turmw=-4;x=0
for i in fe:
if i==turmw:
turmpositionweiss.append(x)
x=x+1
turmzugew=[];turmschlagw=[]
k=0;ad=0 # dazuzaehlen fuer turmposition
for n in turmpositionweiss:
for v in range(1,5): #fuer die Richtungen 4x
if v==1:
ad=6 #ad fuer nach unten
if v==2:
ad=-6 #ad fuer nach oben
if v==3:
ad=1 #ad fuer nach rechts
if v==4:
ad=-1
#nach unten suchen
z=0;abbruchwert=0
for i in range(1,5): # ab turmposition schleife z.bsp 4x
z=z+ad
if fe[turmpositionweiss[0+k]+z]!=0:
break
else:
turmzugew.append(n) #von
turmzugew.append(turmpositionweiss[0+k]+z) #bis
abbruchwert=z
#Restglied dazu wenn ueber null=feind
if fe[turmpositionweiss[0+k]+abbruchwert+ad]>0:
if fe[turmpositionweiss[0+k]+abbruchwert+ad]!=2:
turmschlagw.append(n)
turmschlagw.append(turmpositionweiss[0+k]+abbruchwert+ad)
# wenn 2 tuerme k anders weil zweiter turm
if su==2:
k=1
#dampositonweiss
dampositionweiss=[]#Turmzuege
damw=-8;x=0
Programming a mini chess in phyton 32
for i in fe:
if i==damw:
dampositionweiss.append(x)
x=x+1
damzugew=[];damschlagw=[]
k=0;ad=0 # dazuzaehlen fuer turmposition
for n in dampositionweiss:
for v in range(1,5): #fuer die Richtungen 4x
if v==1:
ad=6 #ad fuer nach unten
if v==2:
ad=-6 #ad fuer nach oben
if v==3:
ad=1 #ad fuer nach rechts
if v==4:
ad=-1
#nach unten suchen
z=0;abbruchwert=0
for i in range(1,5): # ab damposition schleife z.bsp 4x
z=z+ad
if fe[dampositionweiss[0+k]+z]!=0:
break
else:
damzugew.append(n) #von
damzugew.append(dampositionweiss[0+k]+z) #bis
abbruchwert=z
#Restglied dazu wenn ueber null=feind
if fe[dampositionweiss[0+k]+abbruchwert+ad]>0:
if fe[dampositionweiss[0+k]+abbruchwert+ad]!=2:
damschlagw.append(n)
damschlagw.append(dampositionweiss[0+k]+abbruchwert+ad)
# wenn 2 damen k anders weil zweiter dam
if su==2:
k=1
#schraege weisse zuege
damzugews=[];damschlagws=[]
k=0;ad=0 # dazuzaehlen fuer damposition
for n in dampositionweiss:
for v in range(1,5): #fuer die Richtungen 4x
if v==1:
ad=7 #ad fuer nach unten
if v==2:
ad=-7 #ad fuer nach oben
if v==3:
ad=5 #ad fuer nach rechts
if v==4:
ad=-5
#nach unten suchen
z=0;abbruchwert=0
for i in range(1,5): # ab damposition schleife z.bsp 4x
z=z+ad
if fe[dampositionweiss[0+k]+z]!=0:
break
else:
damzugews.append(n) #von
damzugews.append(dampositionweiss[0+k]+z) #bis
abbruchwert=z
#Restglied dazu wenn ueber null=feind
if fe[dampositionweiss[0+k]+abbruchwert+ad]>0:
if fe[dampositionweiss[0+k]+abbruchwert+ad]!=2:
damschlagws.append(n)
damschlagws.append(dampositionweiss[0+k]+abbruchwert+ad)
# wenn 2 damen k anders weil zweiter dam
if su==2:
k=1
kingpositionweiss=[]# kingposition
kingw=-9;x=0
for i in fe:
if i==kingw:
kingpositionweiss.append(x)
x=x+1
#berechne geradenzug fuer jede kingposition
kingzugweiss=[];kingweisss=[] #kingzuege
for i in kingpositionweiss:
if (fe[i+6]==0)and(fe[i+6]!=2):
kingzugweiss.append(i)
kingzugweiss.append(i+6)
if (fe[i-6]==0)and(fe[i-6]!=2):
kingzugweiss.append(i)
kingzugweiss.append(i-6)
if (fe[i+1]==0)and(fe[i+1]!=2):
kingzugweiss.append(i)
kingzugweiss.append(i+1)
if (fe[i-1]==0)and(fe[i-1]!=2):
kingzugweiss.append(i)
kingzugweiss.append(i-1)
if (fe[i+7]==0)and(fe[i+7]!=2):
kingzugweiss.append(i)
kingzugweiss.append(i+7)
if (fe[i-7]==0)and(fe[i-7]!=2):
kingzugweiss.append(i)
kingzugweiss.append(i-7)
if (fe[i+5]==0)and(fe[i+5]!=2):
kingzugweiss.append(i)
kingzugweiss.append(i+5)
if (fe[i-5]==0)and(fe[i-5]!=2):
kingzugweiss.append(i)
kingzugweiss.append(i-5)
if (fe[i+6]>0)and(fe[i+6]!=2):
kingweisss.append(i)
kingweisss.append(i+6)
if (fe[i-6]>0)and(fe[i-6]!=2):
kingweisss.append(i)
kingweisss.append(i-6)
if (fe[i+1]>0)and(fe[i+1]!=2):
kingweisss.append(i)
kingweisss.append(i+1)
if (fe[i-1]>0)and(fe[i-1]!=2):
kingweisss.append(i)
kingweisss.append(i-1)
if (fe[i+7]>0)and(fe[i+7]!=2):
kingweisss.append(i)
kingweisss.append(i+7)
if (fe[i-7]>0)and(fe[i-7]!=2):
kingweisss.append(i)
kingweisss.append(i-7)
if (fe[i+5]>0)and(fe[i+5]!=2):
kingweisss.append(i)
kingweisss.append(i+5)
if (fe[i-5]>0)and(fe[i-5]!=2):
kingweisss.append(i)
kingweisss.append(i-5)
gesamtweiss=[]
weisszug=[] #alle weissen sammeln
weisszug.extend(bauernzugweiss)
weisszug.extend(turmzugew)
weisszug.extend(damzuggerade)
weisszug.extend(kingzugweiss)
weissschlag=[]
Programming a mini chess in phyton 34
weissschlag.extend(bauernweissschlag)
weissschlag.extend(turmschlagw)
weissschlag.extend(damzugschlagt)
weissschlag.extend(kingweisss)
gesamtweiss.extend(weisszug)
gesamtweiss.extend(weissschlag)
#fahre weiss
x=0;y=0
y=len(gesamtweiss)/2
weissreaktion=[]
for i in range(1,y+1): #fuehre alle weissen zuege aus
x=x+1
v=x-1;b=x
#print gesamtweiss[v],gesamtweiss[b]
weissreaktion.append(gesamtweiss[v])
weissreaktion.append(gesamtweiss[b])
x=x+1
ausweiss.append(weissreaktion)#zu ausweiss dazu
#return fe[7:11],fe[13:17],fe[19:23],fe[25:29],fe[31:35],weissreaktion
return weissreaktion
#****************************funktion ende***************************
#print gesamtschwarz
schwarzein=[]
x=0;y=0
y=len(gesamtschwarz)/2
for i in range(1,y+1): #fuehre alle schwarzen zuege aus rufe weisse reaktion
fe=f[:]
x=x+1
v=x-1;b=x
#print gesamtschwarz[v],gesamtschwarz[b]
schwarzein.append(gesamtschwarz[v])
schwarzein.append(gesamtschwarz[b])
fe[gesamtschwarz[b]]=fe[gesamtschwarz[v]]#ausfuehern
fe[gesamtschwarz[v]]=0
weiss() #weisse funktion aufrufen
x=x+1
#print "first"
#print f[7:11]
#print f[13:17]
#print f[19:23]
#print f[25:29]
#print f[31:35]
#print'+++++++++++++'
x=0;y=0
y=len(gesamtschwarz)/2
za=0;zui=[];ges=[]
for i in range(1,y+1):
fa=f[:]
x=x+1
v=x-1;b=x
#print gesamtschwarz[v],gesamtschwarz[b]
ges.append(gesamtschwarz[v])
ges.append(gesamtschwarz[b])
fa[gesamtschwarz[b]]=fa[gesamtschwarz[v]]#ausfuehern
fa[gesamtschwarz[v]]=0
#hier innere addition
Programming a mini chess in phyton 35
add=0;zu=[]
zui.append(zu)
for k in range(7,11): #innere addition
if fa[k]>0:
add=add+fa[k]
if za==za:
x1=0;y1=0;v1=0;b1=0
y1=len(ausweiss[za])/2
for c in range(1,y1+1):
fi=fa[:]
x1=x1+1 #ueber antwort iterieren
v1=x1-1;b1=x1 # noch addition einf?gen
#print ausweiss[za][v1],ausweiss[za][b1]
fi[ausweiss[za][b1]]=fi[ausweiss[za][v1]]#ausfuehern
fi[ausweiss[za][v1]]=0
sus=0;suw=0#addiere innere summe
for k in range(7,11):
if fi[k]>0:
sus=sus+fi[k]
if fi[k]<0:
suw=suw+fi[k]
for k in range(13,17):
if fi[k]>0:
sus=sus+fi[k]
if fi[k]<0:
suw=suw+fi[k]
for k in range(19,23):
if fi[k]>0:
sus=sus+fi[k]
if fi[k]<0:
suw=suw+fi[k]
for k in range(25,29):
if fi[k]>0:
sus=sus+fi[k]
if fi[k]<0:
suw=suw+fi[k]
for k in range(31,35):
if fi[k]>0:
sus=sus+fi[k]
if fi[k]<0:
suw=suw+fi[k]
#print'sum',sus,abs(suw)
ab=abs(suw)-sus # unterschied berechnen
if sus<abs(suw):
zu.append(ab)
#zu.append(sus)
#zu.append(abs(suw))
x1=x1+1
#print'***************'
#print fi[7:11]
#print fi[13:17]
#print fi[19:23]
#print fi[25:29]
#print fi[31:35]
#print '****************'
#print "Zug=",ges
#print "unterschiede der materialien bei zug"
#print "Dif=",zui
Programming a mini chess in phyton 36
ne=[] # hier alle geringen unterschiede sammeln
for i in zui:
if i==[]:
ne.append([])
if i!=[]:
ne.append(max(i))
st=0;mi=[]
for k in ne:
st=st+1
if k==[]:
mi.append(st-1)
break
f[ges[n1]]=f[ges[n]]#ausfuehern
f[ges[n]]=0
#print'**************'
#print f[7:11]
#print f[13:17]
#print f[19:23]
#print f[25:29]
#print f[31:35]
#print'**************'
#damverwandlung
if f[31]==1:
f[31]=8
if f[32]==1:
f[32]=8
if f[33]==1:
f[33]=8
if f[34]==1:
f[34]=8
#spielstand
aus=0;auw=0#addiere innere summe
for k in range(7,11):
if f[k]>0:
Programming a mini chess in phyton 37
aus=aus+f[k]
if f[k]<0:
auw=auw+f[k]
for k in range(13,17):
if f[k]>0:
aus=aus+f[k]
if f[k]<0:
auw=auw+f[k]
for k in range(19,23):
if f[k]>0:
aus=aus+f[k]
if f[k]<0:
auw=auw+f[k]
for k in range(25,29):
if f[k]>0:
aus=aus+f[k]
if f[k]<0:
auw=auw+f[k]
for k in range(31,35):
if f[k]>0:
aus=aus+f[k]
if f[k]<0:
auw=auw+f[k]
q=[]
for i in f:
if i==3:
q.append('L')
if i==5:
q.append('S')
if i==4:
q.append('T')
if i==8:
q.append('D')
if i==9:
q.append('K')
if i==1:
q.append('+')
if i==0:
q.append('.')
if i==-3:
q.append('l')
if i==-5:
q.append('s')
if i==-4:
q.append('t')
if i==-8:
q.append('d')
if i==-9:
q.append('k')
if i==-1:
q.append('*')
print'***********',' ''***************'
print'*',q[0],q[1],q[2],q[3],'*',' *'' 7 8 9 10 *'
print'*', q[4],q[5],q[6],q[7],'*',' *'' 13 14 15 16 *'
print'*', q[8],q[9],q[10],q[11],'*',' *'' 19 20 21 22 *'
print'*', q[12],q[13],q[14],q[15],'*',' *'' 25 26 27 28 *'
print'*', q[16],q[17],q[18],q[19],'*',' *'' 31 32 33 34 *'
q=[]
print'***********',' ''***************'
print "Spielstand:","Computer:",aus,"p","Mensch:",abs(auw),"p"
if aus>abs(auw):
xxx=random.randint(1,6)
if xxx==1:
print"juhuhu ich bin besser,hab mehr Punkte"
if xxx==2:
print"ich bin super!!!"
if xxx==3:
print"bin ich nicht gut???"
Programming a mini chess in phyton 38
if xxx==4:
print"das ist mein bester Zug"
if xxx==5:
print"ich mach Dich platt"
if xxx==6:
print"Bald bist Du fertig"
if aus<abs(auw):
yyy=random.randint(1,6)
if yyy==1:
print"jau!!!das hab ich nicht gesehen!!"
if yyy==2:
print"warum muss das mir passieren?"
if yyy==3:
print"das tut weh!!!"
if yyy==4:
print"schade...wo ich schon so gut war"
if yyy==5:
print"ach nein!!!ohweh....!!!"
if yyy==6:
print"das ist nicht so schlimm.."
if aus==abs(auw):
zzz=random.randint(1,10)
if zzz==1:
print"es steht anscheinend ausgeglichen...mein Sieg ist nahe"
if zzz==2:
print"irgendwie sieht diese Stellung komisch aus"
if zzz==3:
print"das sieht schon gut aus!!!"
if zzz==4:
print"der Weg zum Sieg ist nahe"
if zzz==5:
print"das war ein guter Zug"
if zzz==6:
print"irgendwie bin ich doch gut"
if zzz==7:
print"das sieht nach 'Unentschieden'aus"
if zzz==8:
print"ok ich denke noch..."
if zzz==9:
print"mir ist nicht so gut"
if zzz==10:
print"willst Du das wirklich?"
if aus-abs(auw)==1:
aaa=random.randint(1,4)
if aaa==1:
print"hihi...ich habe Deinen Bauern geschlagen"
if aaa==2:
print"trara...dieses war der erste Streich"
if aaa==3:
print"hehe...schon bin ich im Vorteil!"
if aaa==4:
print"den nehme ich mir!"
if aus-abs(auw)==4:
bbb=random.randint(1,3)
if bbb==1:
print"haha->dein Turm ist mein"
if bbb==2:
print"steil..nun hab ich deinen Turm erobert!"
if bbb==3:
print"meck,meck,meck...dein Turm ist weg!!!"
if aus-abs(auw)==8:
ccc=random.randint(1,3)
if ccc==1:
print"super!!super!!->jetzt habe ich Deine Dame doch erwischt"
if ccc==2:
print"toll,toll,auch deine Dame ist nun weg!!"
if ccc==3:
print"dumm gelaufen...ich habe gewonnen"
if aus-abs(auw)==2:
Programming a mini chess in phyton 39
ddd=random.randint(1,3)
if ddd==1:
print"tralala...ich bin zwei Bauerneinheiten vorne"
if ddd==2:
print"zwo,zwo,zwo...da bin ich froh"
if ddd==3:
print"zwei Punkte vorn....ich bin enorm stark!"
if aus-abs(auw)==3:
eee=random.randint(1,3)
if eee==1:
print"gewaltig...ich bin drei Bauerneinheiten vor Dir!"
if eee==2:
print"eklatant ich bin so gut...."
if eee==3:
print"dieser Zug ist Dein Ende"
if aus-abs(auw)==5:
fff=random.randint(1,3)
if fff==1:
print"bin bestens drauf!-->Turm+Bauer habe ich erobert!"
if fff==2:
print"und dieses war der zweite Streich-Turm+Bauer vorne!!"
if fff==3:
print"das war ein schlechter Zug von Dir"
if aus-abs(auw)==6:
ggg=random.randint(1,3)
if ggg==1:
print"ich bin so gut!-->Turm+2xBauer habe ich schon erobert!"
if ggg==2:
print"ich werde immer besser!-->dein Turm+Bauer+Bauer ist weg!!"
if ggg==3:
print"aufgeben bitte!!!"
if aus-abs(auw)==9:
hhh=random.randint(1,3)
if hhh==1:
print"genial-->aufgeben bitte!eine Dame+1xBauer habe ich schon erobert!"
if hhh==2:
print"willst Du wirklich weiterspielen..."
if hhh==3:
print"ich mach Dich fertig !!!"
if aus-abs(auw)==10:
iii=random.randint(1,3)
if iii==1:
print"sauber-->wieder was erwischt,es sieht schlecht aus"
if iii==2:
print"dieser Zug vernichtet Dich !!!"
if iii==3:
print"Patzer,Patzer!!!"
if aus-abs(auw)==-1:
jjj=random.randint(1,3)
if jjj==1:
print"naja...bin einen Bauer hinten,das war Zufall!"
if jjj==2:
print"das macht gar nichts ich bin super!!!"
if jjj==3:
print"bald habe ich den Sieg errungen..."
if aus-abs(auw)==-2:
kkk=random.randint(1,3)
if kkk==1:
print"nunja...hab halt zwei Bauern weniger,denken!denken!"
if kkk==2:
print"das war fies von Dir"
if kkk==3:
print"jetzt kommt mein Angriff"
if aus-abs(auw)==-4:
lll=random.randint(1,3)
if lll==1:
print"auweh!wo ist mein Turm?"
if lll==2:
print"auch ohne Turm bin ich besser!!!"
Programming a mini chess in phyton 40
if lll==3:
print"Fehlzug von Dir!!!-->jetzt nehme ich Deine Dame!!"
if aus-abs(auw)==-8:
mmm=random.randint(1,3)
if mmm==1:
print"ach nein!!! meine Dame ist schon weg!"
if mmm==2:
print"egal...ich mach mir eine neue Dame!!"
if mmm==3:
print"mein Dame weg??-->nun werde ich Dich vernichten!!!"
if aus-abs(auw)==-9:
nnn=random.randint(1,3)
if nnn==1:
print"gibt es das?meine Dame?mein Bauer?"
if nnn==2:
print"auch ohne Dame+Bauer bin ich besser!!"
if nnn==3:
print"das war purer Zufall...ich bin gut"
if aus-abs(auw)==-3:
ooo=random.randint(1,3)
if ooo==1:
print"jetzt muss ich denken...hab halt drei Bauern weniger"
if ooo==2:
print"Achtung dein Turm!!!"
if ooo==3:
print"ich bin anscheinend im Vorteil"
if aus-abs(auw)==-5:
ppp=random.randint(1,3)
if ppp==1:
print"ouweh!wo ist mein Turm?wo ist mein Bauer?"
if ppp==2:
print"warum?...fehlt mir ein Turm???"
if ppp==3:
print"das ist unfair!!!"
if aus-abs(auw)==-10:
qqq=random.randint(1,3)
if qqq==1:
print"bist Du ein Schachcomputer?"
if qqq==2:
print"dieser Zug macht keinen Sinn...ich bin immmer noch besser!!"
if qqq==3:
print"Sieg,Sieg!!ich mach mir zwei Damen..10 Punkte weniger ist egal!"
An oversized place
Who still knows August Hermann Francke today?
His work, the “Francke Foundations in Halle”, is still present. He lived from 1663 to 1727. Al-
ready at the age of 24 he realized that neither work nor profession, as well as the pursuit of
money, are the fulfillment of life.
Since a human life is immeasurably short, a hyphen between two years, he devotes all his
energy to fighting poverty. He founds orphanages and schools and provides training places for
young people.
But where is August Hermann Francke now? Does he live on in higher dimensions? Is there a
place called "Heaven" or "Paradise"?
This livelihood from 1699 is still relevant today, it may seem old-fashioned
appear, but the author of these lines can heartily endorse this confession.
Now the author knows for sure, like August Hermann Francke once, that he will live on after death.
Why?
A gift
Eternal life as a gift:
The creed of August Hermann Francke can be asked very personally word for word, claim and
simply "believe". This invitation from God is addressed to “volunteers”, it is a gift.
Our journey continues into immeasurable depths beyond space and time. Already from a distance
we hear the terrible cries of the unfortunate people who have to live in this horrible place. A yawning
black hole opens before our eyes. We must be careful not to get too close to this hole so that we are not
torn apart. Warns them, warns them the voices call out, we must be here forever separated from our lo-
ved ones, we must suffer eternal darkness, pain and horror. Lost, we are lost, we must be here forever.
I do want to, but I cannot do what is good. Because I don't do the good that I want; but the evil that I
don't want, that's what I do. But if I do what I do not want, it is not I who do it, but the sin that dwells
in me. That is what we need to think about, everybody explore his heart. I miserable man! Who will de-
liver me from the dead body?
There is hope
We leave this place in a hurry and sad. We don't want to stay here a minute longer.
With the utmost effort we manage to escape. Then it occurs to me: No one should be lost and come to
this terrible place.
Did not the good, merciful, holy and just triune God, who loves us always, send his Son so that we may
not perish. Jesus obtained redemption for our sins through his vicarious death on the cross.
When we confess our sins, He is faithful and righteous to forgive our sins and cleanse
us from all injustice. (The Bible: 1 John 1: 9)
For God so loved the world that he gave his only begotten Son, so that everyone who
believes in him should not perish, but have eternal life.
(The Bible: John 3:16)
I am the resurrection and the life; whoever believes in me will live even if he dies "(The
Bible: John 11:25)
For if you confess with your mouth that Jesus is the Lord and believe in your heart
that God raised him from the dead, you will be saved. (The Bible: Romans 10.9)
Where will we be after death? "At home with the Lord in heaven" or lost forever.
I have learned two important things in my life: that I am a great sinner and that
Christ is an even greater Savior.
[Sir Isaac Newton 1643-1727]
mpressum, copyright, care and errors. Great care was taken in compiling the text and the images.
However, errors cannot be completely ruled out. The publisher and the author cannot accept any legal
responsibility or liability for incorrect information and their consequences. All rights reserved, inclu-
ding photomechanical reproduction and storage in electronic media. Commercial use of the models
and works shown in this book is only permitted with the consent of the © author. For hardware and
software names and other keywords that are protected as registered trademarks, it was not possible in
all cases to determine promptly whether a trademark protection exists , for this reason the ®R symbol
is not used in this book. Edition No. 1- 2020 / self-published.
The author: