                      B R U T A L I S  1.0   -    Jens B‘k Nielsen
                      
                      Documentation.

PURPOSE
This program solves (and helps composing) helpmates and constructed tasks.

SPECIAL OPTION
It can use normal knights and nightriders.
(A nightrider on g1 can fx. move to f3, e5, d7.)
But you cannot mix knights and knightriders.
Another special option is to choose english/danish(=german,sweedish) notation.

DEPTH
Use function 2 to set the depth.
Black normally starts in helpmates. A helpmate in 2 moves (H#2) has moves
by black, white, black and white mating black.
Set the depth to 4 for such a H#2.
BRUTALIS goes a halfmove deeper internally to see if there is a mate.
Maximum depth is 32.
See more about the iterative search later.

HOW TO TYPE IN
Don't care about upper-/lowercase. BRUTALIS handles this.
I have not bothered to make a nice typing of men, so when you have the
option to type in "2,3,4,5,6,7" it simply means P,N,B,R,Q,R.
You can use "s" and "S" for rooks that cannot castle (type in position).

SPECIAL FEATURES
My main interest is constructed tasks from the initial position.
Fx "a game started e2-e4. a knight captured a rook in move 5 with mate. how?".
Solution: 1.e4,Nf6 2.Qe2,Nxe4 3.f3,Ng3 4.Qxe7+,Qxe7+ 5.Kf2,Nxh1# 
Another: "A game ended with 6.gxf8N#". how?".
Solution: 1.h4,d5 2.h5,Nd7 3.h6,Ndf6 4.hxg7,Kd7 5.Rh6,Ne8 6.gxf8N#

I have made some special features to speed up the program.
If you know a piece makes many moves you can tell the program this.
You can chose a piece for both black and white if you want, and you can
also tell how many moves by other pieces is allowed.

Another feature is that you can demand something about the mating position.
You can choose any square and tell what content it should have (empty or a
certain black or white piece).
With these features I have tried to find mates with the white king on row
number 4 and where black mates in move 4.
Among these mates I have found these: 
"The white king is mated on g4 in move 4, and black has made two bishopmoves.
how?".
"The white king is mated on f4 in move 4, and a capture occured in the game.
how?".
"The white king is mated on h4 in move 4 in a game where black opened 1.-,e6.
how?".

If you can't solve these, BRUTALIS can.
Demand (function 7) the white king to be on f4/g4/h4, and use function 9 to 
tell that many moves should be made with the piece on e1 - the white king.
Remember to allow 1 move by another piece - white must move a pawn to let
the king come out.
Set the depth to 8 and start the search. It will take a little more than 
half an hour. All timings in this documentation and in the menues applies 
to my 486 dx 50 Mhz.
I have tried to only allow g1(the mating side) and g8 to move, and then all
the mates in move 6 (use depth 11) will occur in an hour as far as I remember.
White captures d8/f8, black moves to d8/f8, white mates on c7/g7.
This shows how deep you can go with these features.

I have also made some other things you can demand on the mating position.
You can demand a certain kind of man to make the mating move (function 5).
Please notice that this does not have to be the man that checks the king if
the check is a discovered check. You cannot demand a certain kind of man to
check and mate.

You can also demand something about the square the mating move goes to. Must
it be empty or a certain kind of man (function 6).

ITERATIVE SEARCH
I had hoped that the program with the above features could find the shortest 
mate in all combinations where (a certain kind of man makes the mating move) 
and (moves to a square with a certain content).
For this purpose I have made an iterative search. That is, it first searches
for a mate in n moves, then in n+1 moves etc.
Try to search for the fools mate (fx 1.g4,e6 2.f3,Qh4) with function 2.  
Search from mate in 1 move to a mate in 8 moves. 
When the program finds a mate in iteration 4, it cancels further iterations.
In iteration 1 BRUTALIS searches for white to mate in 1 move, in iteration 2 
for black to mate in 2 moves etc.
If you want to find the shortest white mate, you should choose both the 
first and last iteration as odd, so the difference is an even number.
In this case the program ask if you will go to next iteration with +1 (this
means altering white and black mates) or +2 (only mates by one side - in our
case white if you start with an odd iteration).
So iteration from 1 to iteration 9 with a step +2 finds the shortest white
mate.
You can use the iterative search to find shorter solutions than the intended
solutions in helpmateproblems. 
Please notice that the special functions 'change side' if you use a step that
is +1. If you for the fools mate demand that the black queen is on h4, the
next iteration will demand a white queen on h5!
The initial position (or any other position) is mirrored this way.
BRUTALIS has a hidden function 't' that makes this turn manually. Try to set
some demands in function 7, 8 and 9 and use the turning.
Be aware that function 7, 8 and 9 fits with the FIRST iteration you have 
chosen - function 5 and 6 turns automatically. 

DISPLAY
BRUTALIS displays the move it searches right now. 
It also displays a line when it goes to the next iteration.
When a solution is found, nothing but solutions are displayed.
For every 10 solutions the program pauses so you won't miss any solution. 

PLEASE NOTICE
Almost nothing you type in is checked in any way.  
So any error may crash the program (I have never tried; though).

HISTORY
Torben Osted and I makes a chessprogram in C called NO-CHESS. 
When it was 2 months old I took a copy of it and made BRUTALIS.

SPEED
NO-CHESS has some knowledge to make better ordering of moves.
This is unimportant for BRUTALIS and slows it a bit. 
But it is also incorporated in the movegeneration, so I have not bothered
to remove it (may increase the speed by 40%).
Identifying identical positions may make the program 2-3 times faster, BUT:
   Every extra halfmove search with fx 32 moves in a position takes 32 times
   longer.
   This means that 2 extra halfmoves takes 1000 times longer.
   Even with a computer that is 1.000.000 times faster you can only search
   4 extra halfmoves...
   So small improvements don't help very much...

KNOWN ERRORS
The timer overflows when the programs solves long tasks. 
The castle-move is always considered as a kingmove, so if you want many  
moves with a rook that castles it will disappear for BRUTALIS.

IMPROVEMENTS
A save, load and edit position would be nice.
I had other ideas about the program, but dropped them when I discovered how
long time a deep search takes.
Typing 2,3,4,5,6,7 instead of p,n,b,r,q,k is silly.
An interesting idea is to make the program selektive so it only searches
promising lines. Then it could search deeper and eventually find (unwanted)
solutions in deeper problems.
You cannot break the programs search.

THE NAME BRUTALIS
Most chessprograms use a 'brute-force' search with alpha-beta, but a program 
like BRUTALIS cannot use the very timesaving alpha-beta feature because it
must search every single move in all variations.
So BRUTALIS is really brute force.
Besides; a danish ZOO had a rhinoceros named BRUTALIS. It lost its partner
and got more and more angry. It became a problem because it started to
destroy everything.
Taken it's life was considered, but it was decided to bring it back to Africa
even though it was expensive and difficult.
The television followed BRUTALIS and visitid it later. It is happy now as
your BRUTALIS is happy to be on your harddisc.


