Answers.Body: <p>There's this number in Stockfish's code that assigns the <a href="https://github.com/official-stockfish/Stockfish/blob/master/src/types.h#L178" rel="nofollow noreferrer">value of a draw</a>. This is typically 0 for obvious reasons - if your position is better (&gt; 0.00) then it's preferable to avoid a draw, while if your position is worse (&lt; 0.00) then the reverse applies.</p>
  <p>If you change this value to a smaller number, then the engine will view drawing as worse than a slightly inferior position. In fact if you change this to a big negative number, then the engine will view getting mated as better than a draw.
  You will therefore get an engine that &quot;never plays for a draw&quot;.</p>
  <p>Making an engine that &quot;wants to end the game in a checkmate as soon as possible&quot; is a different matter, and it's unclear how you can do that, since the engine will always choose what its algorithm says are the best moves, not the one that is &quot;most aggressive&quot;.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-21T16:23:37.873Z
Answers.Text: Thank you for the reply! Instead of making the engine more aggressive(which is somewhat subjective) how about making the engine privilege shorter games over longer ones? Would that be possible?
Answers.UserDisplayName: TinyCamera
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-22T03:54:38.940Z
Answers.Text: About the last paragraph, my understanding is that Stockfish uses a lot heuristics, so couldn't we add more heuristics, for example: development gets a bonus, pawns around enemy king are worth more, and so on, that should make Stockfish more aggressive, though weaker.
Answers.UserDisplayName: Akavall
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-22T05:01:03.470Z
Answers.Text: @TinyCamera I don't see how one would go about programming that, though. (And why would you want to? Winning in 100 moves is better than losing/drawing in 99.)
Answers.UserDisplayName: Allure
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-22T05:01:50.043Z
Answers.Text: @Akavall I suppose you could, yeah (although that would only be classical eval - it's not clear how to apply it to NNUE eval).
Answers.UserDisplayName: Allure
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-21T04:39:11.437Z
Answers.LastActivityDate: 2022-09-21T04:39:11.437Z
Answers.UserDisplayName: Allure
Answers.Body: <p>I think the kind of exciting chess you're talking about boils down to an engine that evaluates very accurately like Stockfish, but sometimes plays inaccurate lines which contain very favorable variations. In my experience, that is what people miss about the old way of playing in the pre-engine era, which is that you take risks (meaning your position is strictly worse with best play from your opponent) but you know that its very tricky to find the best replies.</p>
  <p>If you want to make your own engine that plays like this and you know some python, I'd suggest the python-chess package. It has interfaces to interact with standard UCI engines such as stockfish. You could also interact with the engine with plain shell scripting or really any language that is capable of starting a command-line process and reading/writing to its standard in/out streams. To make your engine, you could 1) query stockfish for its top moves and the lines that result, 2) come up with your own heuristic metrics for which of the lines is most &quot;exciting&quot; or &quot;tricky&quot;, and 3) output that move from your engine instead of the top move. So the key thing there is how to make the &quot;excitingness&quot; detector. You could start your heuristics with looking for lines where the top reply is bad for you up to some threshold (say -1.0 from your perspective), but all the other reasonable replies are good for you. The problem with this kind of crude excitingness detector is that it basically will play forcing moves hoping the opponent doesn't find the easy-to-find best reply. For example, it'll take pieces hoping that the opponent doesn't take back, but if they do, you're in a worse position than if you had played something else. But maybe taking that as a starting point and thinking of other features of moves/lines/variations that make them &quot;exciting&quot; and combining it all together, you can get an engine that plays in the old style of Tal.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-10-05T18:48:38.553Z
Answers.LastActivityDate: 2022-10-05T18:48:38.553Z
Answers.UserDisplayName: rajb245
Answers.Body: <p>Tinycamera, I did just that with a Stockfish port I made several years ago when large pages were first introduced... this was long before Leela and other projects came around.  I called it Primordial.  It is brutal... I made extensive changes to the code.  If you wish, I can share the code with you.  It is more aggressive than Patricia 2.0.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-11-02T12:35:30.223Z
Answers.LastActivityDate: 2024-11-02T12:36:04.907Z
Answers.LastEditDate: 2024-11-02T12:36:04.907Z
Answers.UserDisplayName: Chessquaker
Body: <p>For the past few months, I have been experimenting with Stockfish with the goal of making the AI more fun to play against.</p>
  <p>Stockfish is obviously a very powerful Chess AI but it plays very conservatively (my understanding is all powerful chess ai ). From a humans perspective, this is kind of boring and this is especially true for new or inexperienced chess players. Additionally, when in a losing position, often moves can become totally nonsensical.</p>
  <p>I have had middling success so far by modifying various weights in stockfish's evaluation function. I want to create Chess AI that is totally ruthless, never plays for a draw and wants to end the game in a checkmate as soon as possible, potentially assuming greater risk in aid of that goal.</p>
  <p>I'm not so worried about the playing strength of the chess engine, my goal is to create a a fun and engaging chess experience for more than just expert level players.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-21T07:28:13.777Z
Comments.Text: Such engines already exist (google :-) but I can't answer your question how to specifically tune Stockfish, sorry.
Comments.UserDisplayName: Hauke Reddmann
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-21T16:25:30.453Z
Comments.Text: Do you have any specific recommendations?
Comments.UserDisplayName: TinyCamera
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-21T18:15:05.820Z
Comments.Text: Google :-) In two seconds I found e.g. http://www.pkoziol.cal24.pl/opental/ - a chess engine that plays like Tal (or so they say). And it surely wasn't the one I dimly remembered.
Comments.UserDisplayName: Hauke Reddmann
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-22T17:27:52.700Z
Comments.Text: BTW Stockfish with neural nets is not as conservative as engines used to be. If it senses the opportunity it will start attacking immediately and aggressively, not afraid to sacrifice pieces, while previous engines were more conservative about material. It's pretty terrifying to be on the recieving end.
Comments.UserDisplayName: qwr
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-10-06T08:33:38.893Z
Comments.Text: A related topic in another forum: http://talkchess.com/forum3/viewtopic.php?f=2&t=80708&sid=df76256825b81bb8d47c64bbdb08d1c0
Comments.UserDisplayName: emdio
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-10-06T17:14:33.723Z
Comments.Text: Coding that into Stockfish's evaluation function shouldn't be hard. The problem is coming up with a "computable" definition of what it is to be aggressive.
Comments.UserDisplayName: David
Tags: <stockfish><chess-ai>
Title: How to program Ruthlessly Aggressive Chess AI?
ThreadText: # How to program Ruthlessly Aggressive Chess AI?
  
  (Asked by: username_0 on 2022-09-21)
  
  For the past few months, I have been experimenting with Stockfish with the goal of making the AI more fun to play against.
  
  Stockfish is obviously a very powerful Chess AI but it plays very conservatively (my understanding is all powerful chess ai ). From a humans perspective, this is kind of boring and this is especially true for new or inexperienced chess players. Additionally, when in a losing position, often moves can become totally nonsensical.
  
  I have had middling success so far by modifying various weights in stockfish's evaluation function. I want to create Chess AI that is totally ruthless, never plays for a draw and wants to end the game in a checkmate as soon as possible, potentially assuming greater risk in aid of that goal.
  
  I'm not so worried about the playing strength of the chess engine, my goal is to create a a fun and engaging chess experience for more than just expert level players.
  
  **Tags:** stockfish, chess-ai
  
  > **Comments:**
  > **username_1**: Such engines already exist (google :-) but I can't answer your question how to specifically tune Stockfish, sorry.  
  > **username_0**: Do you have any specific recommendations?  
  > **username_1**: Google :-) In two seconds I found e.g. http://www.pkoziol.cal24.pl/opental/ - a chess engine that plays like Tal (or so they say). And it surely wasn't the one I dimly remembered.  
  > **username_2**: BTW Stockfish with neural nets is not as conservative as engines used to be. If it senses the opportunity it will start attacking immediately and aggressively, not afraid to sacrifice pieces, while previous engines were more conservative about material. It's pretty terrifying to be on the recieving end.  
  > **username_3**: A related topic in another forum: http://talkchess.com/forum3/viewtopic.php?f=2&t=80708&sid=df76256825b81bb8d47c64bbdb08d1c0  
  > **username_4**: Coding that into Stockfish's evaluation function shouldn't be hard. The problem is coming up with a "computable" definition of what it is to be aggressive.  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_5 on 2022-09-21. Score: 3
  
  There's this number in Stockfish's code that assigns the [value of a draw](https://github.com/official-stockfish/Stockfish/blob/master/src/types.h#L178). This is typically 0 for obvious reasons - if your position is better (> 0.00) then it's preferable to avoid a draw, while if your position is worse (< 0.00) then the reverse applies.
  
  If you change this value to a smaller number, then the engine will view drawing as worse than a slightly inferior position. In fact if you change this to a big negative number, then the engine will view getting mated as better than a draw.
  You will therefore get an engine that "never plays for a draw".
  
  Making an engine that "wants to end the game in a checkmate as soon as possible" is a different matter, and it's unclear how you can do that, since the engine will always choose what its algorithm says are the best moves, not the one that is "most aggressive".
  
  > **Comments:**
  > **username_0**: Thank you for the reply! Instead of making the engine more aggressive(which is somewhat subjective) how about making the engine privilege shorter games over longer ones? Would that be possible?  
  > **username_6**: About the last paragraph, my understanding is that Stockfish uses a lot heuristics, so couldn't we add more heuristics, for example: development gets a bonus, pawns around enemy king are worth more, and so on, that should make Stockfish more aggressive, though weaker.  
  > **username_5**: @username_0 I don't see how one would go about programming that, though. (And why would you want to? Winning in 100 moves is better than losing/drawing in 99.)  
  > **username_5**: @username_6 I suppose you could, yeah (although that would only be classical eval - it's not clear how to apply it to NNUE eval).  
  
  ---
  
  ### Answer by username_7 on 2022-10-05. Score: 0
  
  I think the kind of exciting chess you're talking about boils down to an engine that evaluates very accurately like Stockfish, but sometimes plays inaccurate lines which contain very favorable variations. In my experience, that is what people miss about the old way of playing in the pre-engine era, which is that you take risks (meaning your position is strictly worse with best play from your opponent) but you know that its very tricky to find the best replies.
  
  If you want to make your own engine that plays like this and you know some python, I'd suggest the python-chess package. It has interfaces to interact with standard UCI engines such as stockfish. You could also interact with the engine with plain shell scripting or really any language that is capable of starting a command-line process and reading/writing to its standard in/out streams. To make your engine, you could 1) query stockfish for its top moves and the lines that result, 2) come up with your own heuristic metrics for which of the lines is most "exciting" or "tricky", and 3) output that move from your engine instead of the top move. So the key thing there is how to make the "excitingness" detector. You could start your heuristics with looking for lines where the top reply is bad for you up to some threshold (say -1.0 from your perspective), but all the other reasonable replies are good for you. The problem with this kind of crude excitingness detector is that it basically will play forcing moves hoping the opponent doesn't find the easy-to-find best reply. For example, it'll take pieces hoping that the opponent doesn't take back, but if they do, you're in a worse position than if you had played something else. But maybe taking that as a starting point and thinking of other features of moves/lines/variations that make them "exciting" and combining it all together, you can get an engine that plays in the old style of Tal.
  
  
  ---
  
  ### Answer by username_8 on 2024-11-02. Score: 0
  
  username_0, I did just that with a Stockfish port I made several years ago when large pages were first introduced... this was long before Leela and other projects came around. I called it Primordial. It is brutal... I made extensive changes to the code. If you wish, I can share the code with you. It is more aggressive than Patricia 2.0.
  
  
  ---
  
  