mediocre_chess 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ mediocre_ruby
2
+ =============
3
+
4
+ Utility functions in JRuby that wrap the Mediocre chess engine (http://mediocrechess.blogspot.com/).
@@ -0,0 +1 @@
1
+ java -Xmx1024M -jar mediocre_v0.34.jar
@@ -0,0 +1,11 @@
1
+ #Use own book ("none" to not use own book, else the path to the book, e.g. performance.bin)
2
+ ub none
3
+
4
+ #Main transposition table size (in mb)
5
+ mts 1
6
+
7
+ #Pawn table size (in mb)
8
+ pts 1
9
+
10
+ #Eval table size (in mb)
11
+ ets 1
Binary file
Binary file
Binary file
@@ -0,0 +1,289 @@
1
+ ***************************************************************
2
+ * Mediocre v0.34 by Jonatan Pettersson *
3
+ * *
4
+ * Blog: http://mediocrechess.blogspot.com/ *
5
+ * Homepage: http://mediocrechess.sourceforge.net/ *
6
+ * Sourceforge: http://sourceforge.net/projects/mediocrechess/ *
7
+ * *
8
+ * E-mail: mediocrechess@gmail.com *
9
+ * *
10
+ * Release date: Jan 22, 2009 *
11
+ ***************************************************************
12
+
13
+ ------------
14
+ Introduction
15
+ ------------
16
+
17
+ Mediocre is the result of a chess programming blog (http://mediocrechess.blogspot.com/).
18
+ In the blog every aspect added to Mediocre is described in detail as it develops.
19
+
20
+ Mediocre is written in Java and supports both the WinBoard and UCI protocols, however UCI is
21
+ supported more extensively and is the recommended protocol to use with Mediocre.
22
+
23
+ ------------
24
+ Installation
25
+ ------------
26
+
27
+ Simply unpack the archive and use Mediocre.bat or mediocre_v<xx>.exe (depending on release) to run.
28
+
29
+ Note: Mediocre.bat runs the jar-file which needs Java installed on the computer. See the Settings-section
30
+ in this file to read how to adjust the -Xmx1024M flag.
31
+
32
+ ---------------------
33
+ WinBoard installation
34
+ ---------------------
35
+
36
+ To run Mediocre in WinBoard open the winboard.ini file and find the line:
37
+
38
+ /firstChessProgramNames={GNUChess.exe
39
+ }
40
+
41
+ It might include more engines but should look something like that. Then add Mediocre
42
+ like this:
43
+
44
+ For Java-version:
45
+ /firstChessProgramNames={GNUChess.exe
46
+ "java -Xmx1024M -jar mediocre_v<xx>.jar" /fd="<path to Mediocre>"
47
+ }
48
+
49
+ For executable-version:
50
+ /firstChessProgramNames={GNUChess.exe
51
+ mediocre_v<xx>.exe /fd="<path to Mediocre>"
52
+ }
53
+
54
+ The same can be done for secondChessProgramNames.
55
+
56
+ The next time you start WinBoard you will be able to choose Mediocre in the opening dialog.
57
+
58
+ Note: See the Settings-section in this file to read how to adjust the -Xmx1024M flag.
59
+
60
+ -----------------------------
61
+ Other winboard/uci interfaces
62
+ -----------------------------
63
+
64
+ In other interfaces (like Arena; http://www.playwitharena.com) choose Add Engine from
65
+ the the menus and select the Mediocre.bat-file or the mediocre_v<xx>.exe-file in the Mediocre folder.
66
+
67
+ Mediocre will recognize what protocol to run as.
68
+
69
+ Note: To use Mediocre with the Shredder or Chessbase interfaces (and perhaps other) you will need
70
+ to use the executable file since they do not recognize bat-files (or other ways of running Java-applications).
71
+
72
+ --------
73
+ Settings
74
+ --------
75
+
76
+ Mediocre comes with the file mediocre.ini in which you can set the size of the hash tables, and decide what opening
77
+ book to use.
78
+
79
+ Note: If you run the jar-file you will have to do the following:
80
+
81
+ Since Mediocre is a Java engine it gets 64mb RAM allocated by default. In the .bat file I have now added "-Xmx1024M"
82
+ which allocates 1024mb RAM instead. This is how much memory the application is allowed to use (not necessarily how much it
83
+ actually uses).
84
+
85
+ If you set the size of the hash table to anything larger than the allocated memory Mediocre will not run. If you want
86
+ more RAM to be allocated simply increase the number in the -Xmx1024M (e.g. -Xmx2048M). Decreasing the number will have
87
+ no other effect than not making Mediocre start if hash table size is set to anything larger.
88
+
89
+ --------------
90
+ Change History
91
+ --------------
92
+ v0.34: * Fixed a bug in the reptition detection table (repetitions were not replaced so the table would eventually fill up)
93
+ * Fixed a bug in SEE (where black king's attack squares were added to white's side)
94
+ * Fixed a problem with loading the opening book (perfomance.bin was hard coded and hence the only opening book name that was accepted)
95
+ * Fixed the perft-command at line input (wouldn't show the number)
96
+ * Fixed a bug where endgame piece square tables always were used after opening phase
97
+ * Fixed a bug in the xboard protocol where time was reported in milliseconds (not centiseconds)
98
+ * Fixed a bug in the UCI protocol when the same position was analyzed numerous times (reptable was not updated)
99
+ * Fixed a bug with probing pawn eval when no pawns were on the board
100
+ * Fixed a bug with the draw probability in evaluation (it simply wasn't used)
101
+ * Fixed contempt factor, should work now
102
+ * Move generation slightly optimized
103
+ * Some small optimizations here and there
104
+ * Aspiration window researches now only resets the exceeded limit
105
+ * This document was updated to more accurately explain how to install Mediocre in Winboard.
106
+
107
+ v0.334: * Mediocre now supports Polyglot opening books
108
+ * It is now possible to give the path to a polyglot opening book in the ini-file
109
+ * Some more code cleaning was made
110
+
111
+ v0.333: * Mediocre now comes in a jar-executable and a Windows executable
112
+ * The perft-class has a main-method that can be used to run a standard perft testing procedure
113
+ * The readme was revised
114
+
115
+ v0.332: * Fixed a problem regarding fen-strings using the UCI protocol (thanks to Phokham Nonava)
116
+ * Mediocre now checks for legality of inputted moves in both the UCI and Winboard protocol (thanks to Volker Pittlik)
117
+
118
+ v0.331: * Fixed a bug that caused the feature command not being recognized by Winboard, and the first id command
119
+ not being recognized by Shredder and Chessbase
120
+
121
+ v0.33: * Eval hash added
122
+ * Pawn hash added
123
+ * The zobrist keys are now pseudorandom, meaning they stay the same when restarting the application
124
+ * Pawn zobrist key added to the Board class
125
+ * Pawn eval divided between structure and passed pawns to fit with the pawn hash
126
+ * Switched name between 'depth' and 'ply' in the search, depth is the number of plies left to search
127
+ ply is the number of plies deep the search currently is
128
+ * Fractional plies added
129
+ * Matethreat extension and pawn to 7th rank extension added
130
+ * It is now possible to change the transposition table size in the mediocre.ini file
131
+
132
+ v0.32: * Killer moves verification to avoid generating unnecessary moves
133
+ * The finalEval is now started with globalBestMove to make sure we always get the right move there
134
+ (I'm not sure this was ever a problem, but just in case)
135
+ * Passed pawn values halfed in middle/opening
136
+ * Fixed x-ray attacks for queens
137
+ * Simplified castling rights code
138
+ * Added time search to line input and fixed some bugs
139
+ * Dynamic null move depth
140
+ * Futility check moves outside while loop
141
+ * Fixed bug with black queen on 2nd rank bonus
142
+ * Increased bonus for rook on 2nd/7th rank
143
+ * Searched moves instead of HASH_EXACT to determine LMR and PVS (results in more reduced moves)
144
+ * Hung piece check in the evaluation
145
+ * Tempo bonus in evaluation
146
+
147
+ v0.311: * Fixed a bug that made the engine enter an infinite loop if it was mated using the winboard protocol
148
+ * Reworked the ended game draw detection using the winboard protocol (does not affect the search)
149
+
150
+ v0.31: * Made a few arrays static in the SEE, speeding it up quite a bit
151
+ * Futility pruning added
152
+ * X-ray attacks in the evaluation (e.g. queen attacking empty squares behind own bishop)
153
+ * Eval is adjusted towards 0 if a draw is likely
154
+ * Pawns are valued slightly less but becomes a bit more valuable in endings
155
+ * Knight outposts added
156
+ * King tropism added
157
+ * Rook/queen on 7th rank only awarded if enemy king on 8th or enemy pawns still on 7th
158
+ * Fixed bug with bishop positioning and also one with pawn evaluation
159
+
160
+ v0.3: * Mediocre is now stable enough to leave the beta, this is the frist 'sharp' version
161
+ * Complete redesdign of the evaluation
162
+ * In line input mode the command 'eval' now prints a list of the results of the
163
+ different evaluation segments
164
+ * New piece lists that store every type of piece in its own list, no more looping over the pawns
165
+ to check for promoted pieces
166
+ * Simple late move reduction added, every move after the first four are reduced with one ply
167
+ if they were not a capture or a check
168
+ * Static exchange evaluation added, used for sorting of both ordinary and quiescent moves
169
+ * Losing quiescent captures (captures that lose material) are now pruned
170
+ * New move generation methods gen_caps and gen_noncaps replaces the old generatePseudoMoves
171
+ * Sorting moves is now handled inside the alpha-beta method, it is done step by step so
172
+ we do not have to generate all moves up front, but rather one portion at a time
173
+ * Move legality (not leaving king in check) is now verified when the pseudo-legal move is being
174
+ played in the alpha-beta method instead of verifying all moves up front
175
+ * With the new move sorting all non-losing captures are searched before the killer moves,
176
+ the killer moves can only be non-captures now
177
+ * The UCI protcol would crash the engine if an illegal move was sent in the position string,
178
+ while this really should not happen Mediocre now recognizes illegal moves and sends an error
179
+ message instead of crashing
180
+
181
+ v0.241b: * Internal iterative deepening was added along with hash move search before generating moves
182
+ * The aspiration windows were reduced to 10 centipawns
183
+ * The evaluation output was changed back to show the eval from the engine's point of view
184
+ (in accordance with the winboard and uci protocols)
185
+
186
+ v0.24b: * The evaluation was readjusted, resulting in quite an improvement in overall strength
187
+ * Fixed an issue with the force mode in winboard, was not leaving force mode on the 'new' command
188
+ * Added searchRoot() that works a bit differently on root nodes than ordinary alpha-beta,
189
+ this should take care of the rare occasions where Mediocre did not have a move to make
190
+ * The thinking output now shows white ahead as positive value and black ahead as negative value,
191
+ the evaluation output no longer depends on what side the engine is playing
192
+ * Fixed the contempt factor again, hopefully it works now (slightly negative number for the
193
+ draw if white is moving, and slightly positive if black)
194
+
195
+ v0.232b: * Mediocre now automatically detects what interface is being used, no parameter is needed
196
+
197
+ v0.231b: * A bug in the new 'game over' check for winboard that made the engine crash was fixed
198
+ * The transposition tables now use depth/new replacement scheme
199
+
200
+ v0.23b: * Completely new evaluation, now accounts for king attacks, pawn evaluation and more
201
+ * Check extension added
202
+ * Draw repetition is now accounted for in the search tree as well
203
+ * A bug concerning contempt factor was fixed
204
+ * Piece lists added, no more 120 loops
205
+ * Now gives correct mate count (and not just a high number) for both uci and winboard,
206
+ evaluations from the transposition tables gives the count when the mate was found
207
+ (this is on the todo-list)
208
+ * The broken 'force' mode in winboard should now be fixed
209
+ * Winboard protocol now sends the score when the game is finished (still needs some work)
210
+
211
+ v0.22b: * Fixed a bug in the isAttacked method that made it do unnescessary checks
212
+ * Changed the way unmake move works. The Board-class now has a history array where
213
+ it keeps track of passed positions instead of using the Move-objects
214
+ * The Board-class now keeps track of passed Zobrist keys so we do not have to
215
+ 'unmake' them when unmaking a move
216
+ * The alphaBeta() does not generate moves at leaf nodes anymore
217
+ * Changed ordering values for hash moves and killer moves so they always come
218
+ first and second (at high depths the history moves sometimes came first)
219
+ * Fixed an issue with reporting time using the UCI protocol
220
+ * The Board-class now keeps track of king positions so we do not need to loop
221
+ through the boardArray to find them
222
+ * Changed move generation to use arrays instead of Vectors. generateMoves() now
223
+ fills a given array from a certain index and returns the number of moves that
224
+ were added
225
+ * Alpha-beta and quiescent search now uses a common big array for storing
226
+ generated moves instead of creating many small local arrays
227
+ * Moves are now represented by an integer instead of a Move-object
228
+ * The Move-class was completely rewritten and now only contains static
229
+ methods for analyzing the new move integer
230
+ * Fixed yet another issue with en passants (hopefully they work now)
231
+ * The transposition table now uses an integer array instead of using Hashentry
232
+ objects. Many new methods for retrieving different values were added
233
+
234
+ v0.21b: * Added support for 'infinite' search in uci (not applicable in winboard)
235
+ * Added support for fixed time per move search for both uci and winboard
236
+ * Added support for fixed depth search for both uci and winboard
237
+ * Added support for the '?' (winboard) and 'stop' (uci) move-now commands,
238
+ the 'move now' command in certain interfaces make Mediocre move immediately
239
+ * Made null-moves only possible if the game is not in a pawn ending
240
+ * Introduced contempt factor to draw values (dependant on game phase)
241
+ * Added a game phase check that decides if the game is in the opening,
242
+ middle game, ending or pawn ending
243
+ * Added final INFINITY variable instead of using 200000 in the code
244
+ * Cleaned up the line input, currently it can only set up a board with FEN
245
+ and do perft/divide, might be enhanced again in later releases
246
+ * Increased the number of nodes before time or interrupt command are checked,
247
+ hopefully this should take care of the bug where Mediocre stops searching
248
+
249
+ v0.2b: * Transposition tables are implemented along with a new draw detection scheme
250
+ * There is now a zobrist key field in the Board-class, the key is updated when
251
+ making and unmaking moves, but can also be generated from scratch with the
252
+ static getZobristKey-method in the Zobrist-class
253
+ * Changed pv search so it is only used if a best move has been found
254
+ * Sorting moves is now done with a much faster bubble-sort method
255
+ * Changed move generation slightly and added a new filterQuis-method which adds
256
+ the right values to the captures
257
+ * Quiescent search now re-uses the moves generated in the alphaBeta method
258
+ * Mediocre is now developed in Eclipse so the folders look a bit different
259
+ * The .bat-files now point to "/bin/" so they work as long they are kept in the
260
+ original folder (you should not have to update the path in them anymore)
261
+ * Sorting methods are completely rewritten, based on orderingValue
262
+ * Preliminary orderingValues are added to moves at generation time
263
+ * Move-objects now have a orderingValue used in sorting
264
+ * Implemented fixed depth search, call Engine.search() with depth>0 to use,
265
+ call with depth=0 for time control mode
266
+ * The line input can now be used to play games with fixed depth (5 for now)
267
+ if you enter moves on the form "e2e4" etc. It is still very crude and is
268
+ supposed to be used for testing
269
+ * Plus many minor tweaks and changes
270
+
271
+ v0.12b: * Time mangement added
272
+ * UCI support added
273
+ * Machine vs. Machine in winboard should now work
274
+ * Added support for the 'force' command in winboard
275
+ * Fixed a bug conerning en passant, perft values are now correct
276
+ * Perft and Tests classes were added, these are best called in the new line mode
277
+ * Calling Mediocre without argument now enters a simple line mode
278
+ * Added a few parameters to Engine.search() to allow uci/winboard thinking,
279
+ fixed depth and time management
280
+ * Added setupStart() to Board, which sets up the initial position
281
+
282
+ v0.11b: * Null-moves added
283
+ * Added isInCheck() to the engine class (used by null-moves)
284
+ * Move sorting is now done after the mate check to save time
285
+
286
+ v0.1b: * Aspiration windows added
287
+ * Killer moves heuristic added
288
+ * Principal Variation Search added
289
+ * A new opening book, shorter but lets the engine play itself better
Binary file
@@ -0,0 +1,21 @@
1
+ $:.unshift(File.join(File.dirname(__FILE__), 'mediocre'))
2
+ require 'java'
3
+ require 'mediocre/mediocre_v0.34.jar'
4
+ java_import 'mediocre.board.Board'
5
+ java_import 'mediocre.board.Move'
6
+
7
+ module MediocreChess
8
+ # Input: FEN board rep., rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
9
+ # Returns: Array of move strings, ['e2e4', 'd2d4', ...]
10
+ def self.moves_for_fen(fen_board)
11
+ board = Java::Mediocre.board.Board.new
12
+ board.inputFen(fen_board)
13
+ moves = Java::int[128].new
14
+ number_of_moves = board.gen_allLegalMoves(moves, 0)
15
+ results = []
16
+ number_of_moves.times do |i|
17
+ results << Java::mediocre.board.Move.inputNotation(moves[i])
18
+ end
19
+ results
20
+ end
21
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mediocre_chess
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Joey Robert
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-11-16 00:00:00 +00:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: Chess utility functions in JRuby that wrap the Mediocre chess engine (http://mediocrechess.blogspot.com/).
22
+ email: joey@joeyrobert.org
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files:
28
+ - README.md
29
+ files:
30
+ - lib/mediocre/Mediocre.bat
31
+ - lib/mediocre/mediocre.ini
32
+ - lib/mediocre/mediocre.jpg
33
+ - lib/mediocre/mediocre_v0.34.jar
34
+ - lib/mediocre/performance.bin
35
+ - lib/mediocre/readme.txt
36
+ - lib/mediocre/source.zip
37
+ - lib/mediocre_chess.rb
38
+ - README.md
39
+ has_rdoc: true
40
+ homepage: http://github.com/joeyrobert/mediocre_ruby
41
+ licenses: []
42
+
43
+ post_install_message:
44
+ rdoc_options: []
45
+
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ segments:
53
+ - 0
54
+ version: "0"
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ requirements: []
63
+
64
+ rubyforge_project:
65
+ rubygems_version: 1.3.6
66
+ signing_key:
67
+ specification_version: 3
68
+ summary: Chess utility functions using the Mediocre chess engine
69
+ test_files: []
70
+