ChessV 2.0 - open source GUI and engine for chess variants

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: ChessV 2.0 - open source GUI and engine for chess varian

Post by Evert »

Greg Strong wrote: Strange that it works under Wine but not directly with Mono (for a .NET program, I believe Wine is also using Mono under the surface.) The piece coloring not working is also strange. See what version of Mono you have installed - the piece coloring is working for me on Linux (there are a couple of tiny graphics glitches but they are minor - still disappointing, though, it's not like I'm doing anything complicated - just really basic bitmap operations.) Anyway, if you update Mono to the latest and greatest, that will probably help, even if you are operating under Wine.
I have no idea what version of Mono Wine might be using, the version I have for OS X I downloaded and installed today. It says 4.8.0, with a copyright date of 2014. Seems a bit old for something I downloaded today.

The error I get from it is this:

Code: Select all

$ mono ChessV.exe 

Unhandled Exception:
System.TypeInitializationException: The type initializer for 'ChessV.GUI.Program' threw an exception. ---> System.DllNotFoundException: kernel32
  at (wrapper managed-to-native) ChessV.SystemEnvironment:LoadLibrary (string)
  at ChessV.SystemEnvironment.GetIsWow64ProcessDelegate () &#91;0x00000&#93; in <8fba81e93d3d4b8ca8b107e81c4abfb2>&#58;0 
  at ChessV.SystemEnvironment.Is32BitProcessOn64BitProcessor () &#91;0x00000&#93; in <8fba81e93d3d4b8ca8b107e81c4abfb2>&#58;0 
  at ChessV.SystemEnvironment.IsOS64Bit () &#91;0x00010&#93; in <8fba81e93d3d4b8ca8b107e81c4abfb2>&#58;0 
  at ChessV.EngineLibrary.discoverEnvironment () &#91;0x0000f&#93; in <8fba81e93d3d4b8ca8b107e81c4abfb2>&#58;0 
  at ChessV.EngineLibrary..ctor () &#91;0x0001c&#93; in <8fba81e93d3d4b8ca8b107e81c4abfb2>&#58;0 
  at ChessV.GUI.Program..cctor () &#91;0x00000&#93; in <08af1e99efd247c19fa989933de75b60>&#58;0 
   --- End of inner exception stack trace ---
&#91;ERROR&#93; FATAL UNHANDLED EXCEPTION&#58; System.TypeInitializationException&#58; The type initializer for 'ChessV.GUI.Program' threw an exception. ---> System.DllNotFoundException&#58; kernel32
  at &#40;wrapper managed-to-native&#41; ChessV.SystemEnvironment&#58;LoadLibrary &#40;string&#41;
  at ChessV.SystemEnvironment.GetIsWow64ProcessDelegate () &#91;0x00000&#93; in <8fba81e93d3d4b8ca8b107e81c4abfb2>&#58;0 
  at ChessV.SystemEnvironment.Is32BitProcessOn64BitProcessor () &#91;0x00000&#93; in <8fba81e93d3d4b8ca8b107e81c4abfb2>&#58;0 
  at ChessV.SystemEnvironment.IsOS64Bit () &#91;0x00010&#93; in <8fba81e93d3d4b8ca8b107e81c4abfb2>&#58;0 
  at ChessV.EngineLibrary.discoverEnvironment () &#91;0x0000f&#93; in <8fba81e93d3d4b8ca8b107e81c4abfb2>&#58;0 
  at ChessV.EngineLibrary..ctor () &#91;0x0001c&#93; in <8fba81e93d3d4b8ca8b107e81c4abfb2>&#58;0 
  at ChessV.GUI.Program..cctor () &#91;0x00000&#93; in <08af1e99efd247c19fa989933de75b60>&#58;0 
   --- End of inner exception stack trace ---
$
which means it can't find its own libraries for some reason. In short, that's not a problem with ChessV, but with Mono.
User avatar
Nordlandia
Posts: 2821
Joined: Fri Sep 25, 2015 9:38 pm
Location: Sortland, Norway

Re: ChessV 2.0 - open source GUI and engine for chess varian

Post by Nordlandia »

Gregory Strong -->

Please consider add "Two King Each" to the program.
There are two kings. The king closest to the a-file is the one you must checkmate to win. If the two kings are on the same file, the one closest to rank 1 is the king you must checkmate.
The royal-king may change during the phase of the game.

Image

https://www.chessclub.com/user/help/wild9

https://images.chesscomfiles.com/upload ... Z9hVza.png
User avatar
Greg Strong
Posts: 388
Joined: Sun Dec 21, 2008 6:57 pm
Location: Washington, DC

Re: ChessV 2.0 - open source GUI and engine for chess varian

Post by Greg Strong »

Evert wrote:
Greg Strong wrote: Strange that it works under Wine but not directly with Mono (for a .NET program, I believe Wine is also using Mono under the surface.) The piece coloring not working is also strange. See what version of Mono you have installed - the piece coloring is working for me on Linux (there are a couple of tiny graphics glitches but they are minor - still disappointing, though, it's not like I'm doing anything complicated - just really basic bitmap operations.) Anyway, if you update Mono to the latest and greatest, that will probably help, even if you are operating under Wine.
I have no idea what version of Mono Wine might be using, the version I have for OS X I downloaded and installed today. It says 4.8.0, with a copyright date of 2014. Seems a bit old for something I downloaded today.

The error I get from it is this:

Code: Select all

$ mono ChessV.exe 

Unhandled Exception&#58;
System.TypeInitializationException&#58; The type initializer for 'ChessV.GUI.Program' threw an exception. ---> System.DllNotFoundException&#58; kernel32
  at &#40;wrapper managed-to-native&#41; ChessV.SystemEnvironment&#58;LoadLibrary &#40;string&#41;
  at ChessV.SystemEnvironment.GetIsWow64ProcessDelegate () &#91;0x00000&#93; in <8fba81e93d3d4b8ca8b107e81c4abfb2>&#58;0 
  at ChessV.SystemEnvironment.Is32BitProcessOn64BitProcessor () &#91;0x00000&#93; in <8fba81e93d3d4b8ca8b107e81c4abfb2>&#58;0 
  at ChessV.SystemEnvironment.IsOS64Bit () &#91;0x00010&#93; in <8fba81e93d3d4b8ca8b107e81c4abfb2>&#58;0 
  at ChessV.EngineLibrary.discoverEnvironment () &#91;0x0000f&#93; in <8fba81e93d3d4b8ca8b107e81c4abfb2>&#58;0 
  at ChessV.EngineLibrary..ctor () &#91;0x0001c&#93; in <8fba81e93d3d4b8ca8b107e81c4abfb2>&#58;0 
  at ChessV.GUI.Program..cctor () &#91;0x00000&#93; in <08af1e99efd247c19fa989933de75b60>&#58;0 
   --- End of inner exception stack trace ---
&#91;ERROR&#93; FATAL UNHANDLED EXCEPTION&#58; System.TypeInitializationException&#58; The type initializer for 'ChessV.GUI.Program' threw an exception. ---> System.DllNotFoundException&#58; kernel32
  at &#40;wrapper managed-to-native&#41; ChessV.SystemEnvironment&#58;LoadLibrary &#40;string&#41;
  at ChessV.SystemEnvironment.GetIsWow64ProcessDelegate () &#91;0x00000&#93; in <8fba81e93d3d4b8ca8b107e81c4abfb2>&#58;0 
  at ChessV.SystemEnvironment.Is32BitProcessOn64BitProcessor () &#91;0x00000&#93; in <8fba81e93d3d4b8ca8b107e81c4abfb2>&#58;0 
  at ChessV.SystemEnvironment.IsOS64Bit () &#91;0x00010&#93; in <8fba81e93d3d4b8ca8b107e81c4abfb2>&#58;0 
  at ChessV.EngineLibrary.discoverEnvironment () &#91;0x0000f&#93; in <8fba81e93d3d4b8ca8b107e81c4abfb2>&#58;0 
  at ChessV.EngineLibrary..ctor () &#91;0x0001c&#93; in <8fba81e93d3d4b8ca8b107e81c4abfb2>&#58;0 
  at ChessV.GUI.Program..cctor () &#91;0x00000&#93; in <08af1e99efd247c19fa989933de75b60>&#58;0 
   --- End of inner exception stack trace ---
$
which means it can't find its own libraries for some reason. In short, that's not a problem with ChessV, but with Mono.
Ok, I know what this is about. The code that is crashing is where I try to determine if the OS you are running on is 32-bit or 64-bit. The code does work in Linux, so I assumed it would be ok, but I guess I'm not all that surprised it is giving trouble. I have changed it to skip this check if the OS is not Windows.

Incidentally, the reason I do this is because it is programmed to auto-discover engines that it finds in directories under Engines/XBoard. Throw a new engine in there and it will automatically fire it up, determine its capabilities, and add it to the engine library. If it finds both a 32-bit and 64-bit version, it will pick the right one based on the OS. I was trying to be slick...

Anyway, I will assume the OS is 64-bit if non-windows. The engine auto-discovery is turned off by default on non-windows platforms anyway.

Try this for me... Replace the ChessV.Base.dll file with this one:
http://www.chessv.org/downloads/ChessV.Base.dll
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: ChessV 2.0 - open source GUI and engine for chess varian

Post by Evert »

Greg Strong wrote: Try this for me... Replace the ChessV.Base.dll file with this one:
http://www.chessv.org/downloads/ChessV.Base.dll
Ok, with that I can start ChessV. It still has major issues though.

For some reason, it takes a long time (several seconds) for the interface to appear (much longer than when I run the Windows version under Wine). When it finally does appear, the drawing does not go smoothly: I can see the window being drawn, and it seems not all parts of the window are updated correctly. It's a bit hard to explain, but it looks like some parts that should be redrawn aren't. I was able to install SjaakII as an engine (annoying point: the dialog box still has "*.exe" listed as a default selection, but that doesn't make sense away from Windows; not sure how easy that is to configure), but trying to select "Two engine match" didn't work as expected because the engine selection drop-down boxes didn't appear. Starting the match made the internal engine play itself.
When I exited the game and tried again, it crashed. For what it's worth, this is the tracelog:

Code: Select all

$ mono ChessV.exe 
System.ArgumentOutOfRangeException&#58; Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name&#58; index
  at System.ThrowHelper.ThrowArgumentOutOfRangeException &#40;System.ExceptionArgument argument, System.ExceptionResource resource&#41; &#91;0x00011&#93; in <f712f98eb8e445c8918edaf595bbe465>&#58;0 
  at System.ThrowHelper.ThrowArgumentOutOfRangeException () &#91;0x00000&#93; in <f712f98eb8e445c8918edaf595bbe465>&#58;0 
  at System.Collections.Generic.List`1&#91;T&#93;.get_Item &#40;System.Int32 index&#41; &#91;0x0000c&#93; in <f712f98eb8e445c8918edaf595bbe465>&#58;0 
  at ChessV.Match.addPGNMove &#40;System.Collections.Generic.List`1&#91;T&#93; move, System.String comment&#41; &#91;0x0001c&#93; in <108510579dfa43aa9b47365a60e5d7f7>&#58;0 
  at ChessV.Match.OnMoveMade &#40;ChessV.Player sender, System.Collections.Generic.List`1&#91;T&#93; moves&#41; &#91;0x00023&#93; in <108510579dfa43aa9b47365a60e5d7f7>&#58;0 
  at &#40;wrapper delegate-invoke&#41; <Module>&#58;invoke_void_Player_List`1<Movement> &#40;ChessV.Player,System.Collections.Generic.List`1<ChessV.Movement>)
  at ChessV.Player.emitMove &#40;System.Collections.Generic.List`1&#91;T&#93; moves&#41; &#91;0x0003c&#93; in <108510579dfa43aa9b47365a60e5d7f7>&#58;0 
  at ChessV.InternalEngine.onTimerTick &#40;System.Object sender, System.EventArgs e&#41; &#91;0x0000b&#93; in <108510579dfa43aa9b47365a60e5d7f7>&#58;0 
  at System.Windows.Forms.Timer.OnTick &#40;System.EventArgs e&#41; &#91;0x0000b&#93; in <e37081a3704b4473a59cdf5048ad96bc>&#58;0 
  at System.Windows.Forms.Timer.FireTick () &#91;0x00000&#93; in <e37081a3704b4473a59cdf5048ad96bc>&#58;0 
  at &#40;wrapper remoting-invoke-with-check&#41; System.Windows.Forms.Timer&#58;FireTick ()
  at System.Windows.Forms.XplatUICarbon.CheckTimers &#40;System.DateTime now&#41; &#91;0x000a6&#93; in <e37081a3704b4473a59cdf5048ad96bc>&#58;0 
  at System.Windows.Forms.XplatUICarbon.GetMessage &#40;System.Object queue_id, System.Windows.Forms.MSG& msg, System.IntPtr hWnd, System.Int32 wFilterMin, System.Int32 wFilterMax&#41; &#91;0x00012&#93; in <e37081a3704b4473a59cdf5048ad96bc>&#58;0 
  at System.Windows.Forms.XplatUICarbon.WaitForHwndMessage &#40;System.Windows.Forms.Hwnd hwnd, System.Windows.Forms.Msg message&#41; &#91;0x0000a&#93; in <e37081a3704b4473a59cdf5048ad96bc>&#58;0 
  at System.Windows.Forms.XplatUICarbon.CreateWindow &#40;System.Windows.Forms.CreateParams cp&#41; &#91;0x0057d&#93; in <e37081a3704b4473a59cdf5048ad96bc>&#58;0 
  at System.Windows.Forms.XplatUI.CreateWindow &#40;System.Windows.Forms.CreateParams cp&#41; &#91;0x00000&#93; in <e37081a3704b4473a59cdf5048ad96bc>&#58;0 
  at System.Windows.Forms.NativeWindow.CreateHandle &#40;System.Windows.Forms.CreateParams cp&#41; &#91;0x0000c&#93; in <e37081a3704b4473a59cdf5048ad96bc>&#58;0 
  at System.Windows.Forms.Control.CreateHandle () &#91;0x0003a&#93; in <e37081a3704b4473a59cdf5048ad96bc>&#58;0 
  at System.Windows.Forms.Form.CreateHandle () &#91;0x00000&#93; in <e37081a3704b4473a59cdf5048ad96bc>&#58;0 
  at System.Windows.Forms.Control.CreateControl () &#91;0x0004b&#93; in <e37081a3704b4473a59cdf5048ad96bc>&#58;0 
  at System.Windows.Forms.Control.SetVisibleCore &#40;System.Boolean value&#41; &#91;0x00043&#93; in <e37081a3704b4473a59cdf5048ad96bc>&#58;0 
  at System.Windows.Forms.Form.SetVisibleCore &#40;System.Boolean value&#41; &#91;0x0007b&#93; in <e37081a3704b4473a59cdf5048ad96bc>&#58;0 
  at System.Windows.Forms.Control.set_Visible &#40;System.Boolean value&#41; &#91;0x0000c&#93; in <e37081a3704b4473a59cdf5048ad96bc>&#58;0 
  at &#40;wrapper remoting-invoke-with-check&#41; System.Windows.Forms.Control&#58;set_Visible &#40;bool&#41;
  at System.Windows.Forms.Application.RunLoop &#40;System.Boolean Modal, System.Windows.Forms.ApplicationContext context&#41; &#91;0x0005f&#93; in <e37081a3704b4473a59cdf5048ad96bc>&#58;0 
  at System.Windows.Forms.Form.ShowDialog &#40;System.Windows.Forms.IWin32Window owner&#41; &#91;0x001fe&#93; in <e37081a3704b4473a59cdf5048ad96bc>&#58;0 
  at System.Windows.Forms.Form.ShowDialog () &#91;0x00000&#93; in <e37081a3704b4473a59cdf5048ad96bc>&#58;0 
  at &#40;wrapper remoting-invoke-with-check&#41; System.Windows.Forms.Form&#58;ShowDialog ()
  at ChessV.GUI.MainForm.startGame &#40;ChessV.Game game&#41; &#91;0x00007&#93; in <08af1e99efd247c19fa989933de75b60>&#58;0 
  at ChessV.GUI.MainForm.btnSelectorButtons_Click &#40;System.Object sender, System.EventArgs e&#41; &#91;0x00028&#93; in <08af1e99efd247c19fa989933de75b60>&#58;0 
  at System.Windows.Forms.Control.OnClick &#40;System.EventArgs e&#41; &#91;0x0001c&#93; in <e37081a3704b4473a59cdf5048ad96bc>&#58;0 
  at System.Windows.Forms.Button.OnClick &#40;System.EventArgs e&#41; &#91;0x00024&#93; in <e37081a3704b4473a59cdf5048ad96bc>&#58;0 
  at System.Windows.Forms.ButtonBase.OnMouseUp &#40;System.Windows.Forms.MouseEventArgs mevent&#41; &#91;0x00081&#93; in <e37081a3704b4473a59cdf5048ad96bc>&#58;0 
  at System.Windows.Forms.Button.OnMouseUp &#40;System.Windows.Forms.MouseEventArgs mevent&#41; &#91;0x00000&#93; in <e37081a3704b4473a59cdf5048ad96bc>&#58;0 
  at System.Windows.Forms.Control.WmLButtonUp &#40;System.Windows.Forms.Message& m&#41; &#91;0x0007e&#93; in <e37081a3704b4473a59cdf5048ad96bc>&#58;0 
  at System.Windows.Forms.Control.WndProc &#40;System.Windows.Forms.Message& m&#41; &#91;0x0016f&#93; in <e37081a3704b4473a59cdf5048ad96bc>&#58;0 
  at System.Windows.Forms.ButtonBase.WndProc &#40;System.Windows.Forms.Message& m&#41; &#91;0x0004e&#93; in <e37081a3704b4473a59cdf5048ad96bc>&#58;0 
  at System.Windows.Forms.Button.WndProc &#40;System.Windows.Forms.Message& m&#41; &#91;0x00000&#93; in <e37081a3704b4473a59cdf5048ad96bc>&#58;0 
  at System.Windows.Forms.Control+ControlWindowTarget.OnMessage &#40;System.Windows.Forms.Message& m&#41; &#91;0x00000&#93; in <e37081a3704b4473a59cdf5048ad96bc>&#58;0 
  at System.Windows.Forms.Control+ControlNativeWindow.WndProc &#40;System.Windows.Forms.Message& m&#41; &#91;0x0000b&#93; in <e37081a3704b4473a59cdf5048ad96bc>&#58;0 
  at System.Windows.Forms.NativeWindow.WndProc &#40;System.IntPtr hWnd, System.Windows.Forms.Msg msg, System.IntPtr wParam, System.IntPtr lParam&#41; &#91;0x0008e&#93; in <e37081a3704b4473a59cdf5048ad96bc>&#58;0 
$
EDIT: by the way, I think it's starting the program in 32 bit mode; not sure if that matters or not.
EDIT2: Ok, I'm sure it's running in 32 bits, because if I try to run in 64 bit mode I get

Code: Select all

WARNING&#58; The Carbon driver has not been ported to 64bits, and very few parts of Windows.Forms will work properly, or at all
followed by a crash.
Anyway, if it's using Carbon as a back-end, that isn't so good and may explain why it's not running so well. Carbon has been deprecated for a while now. Presumably this is something that can be configured in Mono, but I haven't looked into this.
User avatar
hgm
Posts: 27788
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: ChessV 2.0 - open source GUI and engine for chess varian

Post by hgm »

Greg Strong wrote:I don't think I'd do the lion the same way I do Marseillais Chess though, ...
How does it work in Winboard?
WinBoard (and the Interactive Diagram JavaScript) highlight squares that are (or can be) intermediate destinations in a different color (cyan) than final destinations (yellow or red, depending on whether it is a capture). When you release the piece on a cyan square, the piece remains selected, and the possible target squares of the next leg are then highlighted. Including the square the piece is now on if this intermediate destination can also be the final one. Intermediate squares are only given as a option when something is captured there; adjacent empty squares are always considered final destinations.

The way it works is that the move generator accepts a sequence of squares as arguments, a certain (otherwise invalid) square code acting as a wild card. It generates all moves that match all given squares and are legal considering the board occupancy, but only highlights the first wild-card square along the move (making it sensitive to clicks for selecting it). Cyan dominates the other colors here. If the user clicks it, the square is added to the sequence, replacing the wild card, and the move generator is run again. This 'uncovers' moves that would have ended there, as the moves that highlighted in cyan now have moved to their next target, and the completed move still matches all entered squares. Clicking it a second time then selects the move ending there.
Oh, I don't think I've seen Mighty-Lion.
Well it is a very simplistic variant, just FIDE Chess with the b-file Knights replaced by a Lion. I wanted something simple featuring a Lion, which would not scare off orthodox Chess players immediately. WinBoard even supports it as a standard variant.
It was actually when a friend showed me about Tenjiku Shogi that I first became interested in chess variants.
Indeed, I remembered you told me.
I'm more worried about the repetition rules in Xiangqi.
Well, there is a reasonable logic underlying those. Most of the apparent exceptions follow from the fact that they are based on legal moves, not pseudo-legal. So an attack is only an attack if you can legally capture the piece, and a piece is only protected if you can legally recapture on its square once it gets captured. (So you protect against a specific attack, not the piece per se.) This of course make it a pain to detect it, because you really need to do the 2-ply search on all the captures to see if the recaptures are legal. So basically you generate all legal attacks before your move, and then after your move, and look if any new (attacker, victim) combinations did arise. (The same piece attacking from a different square still counts as the same attack, because actually capturing erases all memory of where the attack was coming from!) Then you play those new captures, and check if legal recapture is possible. If not, the victim was not protected, and your move chased it. If you chase the same piece on every move of the repeat loop, it is a perpetual chase. (And this can still be a draw if the other side is perpetually chasing as well.)

There are a few exceptions to these basic rules:
1) An attack on an unpassed Pawn is never a chase. (Too insignificant)
2) An attack by a King is never a chase. (Too difficult?)
3) An attack with C or H or a Rook is a chase even when the Rook is protected. (Too valuable)
4) An attack on a piece that can capture its attacker legally (R on R, C on C, H on H) is not a chase, even if the attacked piece is unprotected. (Trading yourself is as good a defense as recapturing)

Cases 1-3 save you the trouble of checking if the victim is protected. (And 1-2 even whether the capture itself is legal.) In Case 4 the protection only becomes relevant when trading is not legal. (When the victim is pinned by another piece. Remember that in XQ you can be pinned by Cannons that cannot capture you.)

There still is a complication when checks are involved, as being in check makes most moves illegal, and evading the check then seemingly creates many new attacks. The rules are ambiguous in this, but all people I discussed it with play it like the legality of captures by a checked side should be judged as if the existing attack on the King is temporarily disabled.
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: ChessV 2.0 - open source GUI and engine for chess varian

Post by Ferdy »

Greg Strong wrote:Wow. You have not only configured ChessV to play Makruk, but you've also got it controlling Fairy-max to play a game that is not even built in. Thank you for testing this out. Although you've encountered a crash, this is very encouraging.

It's late here, and I have been drinking :D So I am not sure what is going on. I will look further into this tomorrow. It would help, however, if you told me the line of the error. Your screen-shot does not show me the line number of the error because it is to the right. To be most helpful, if the "Inner Exception" button is active, click that, maybe more than once. Then scroll to the right to see the line number of the error.

Probably I should add a button 'Export' that saves all the information when the Crash dialog box comes up. Then you could send me the file with all the information.
The "Inner Exception" button is not active. After some tries of moving a piece by a mouse, I am able to repeat the problem.
The problem would occur (perhaps not always) if you drag and drop the piece by mouse left click hold it and drag the piece to the destination. To avoid the problem, move the piece by mouse left click selecting the piece, then release it, then left click to the destination.
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: ChessV 2.0 - open source GUI and engine for chess varian

Post by Ferdy »

Greg Strong wrote:To disable castling, just add this line to the SetGameVariables handler:

Code: Select all

Castling.Value = "None";
Promotion on the 6th rank is more difficult. The script language is really young and does not directly allow what you want. BUT you can get mostly what you want, but only by luck :) Trick is, instead of deriving your game from Chess, derive it from 'Mecklenbeck Chess'.

Code: Select all

Game 'Makruk' &#58; 'Mecklenbeck Chess'
This game has optional promotion at the 6th rank and mandatory at the 8th. This isn't exactly what you want since you would like mandatory promotion on the 6th, but really, the engine will want to promote as soon as it can, so this probably doesn't make much difference.

I should also mention a little more about the quotes - SilverGeneral vs. 'Silver General' and single quotes vs. double quotes. Text in double quotes is a string constant, as in any programming language. Text in single quotes are actual identifiers. You need not use the quotes if there are no spaces or otherwise illegal characters. But it allows spaces and other characters right inside actual language identifiers if you put them in single quotes. This probably seems strange from the perspective of a normal programming language. But this language is very specific to the task of defining pieces and games. The game of Omega Chess, for example, should always be displayed as "Omega Chess". But if you couldn't have spaces, you'd have to refer to it in code with a different name, like OmegaChess, and then we would need a facility to specify what the "real name" is for every piece and/or game. I decided instead to have only one name, the identifier, and the identifier is the "real name". Omega Chess is 'Omega Chess' and the Silver General is 'Silver General'.
After some manual tests playing black it does not promote to queen, but it considered promotion at lower depth :), probably winning vs Fairy-Max.

Image



Also after press Game->quick analysis, I get this,

Image



I created a site dedicated to engines that can play makruk here.
https://sites.google.com/view/makruks/home
User avatar
Greg Strong
Posts: 388
Joined: Sun Dec 21, 2008 6:57 pm
Location: Washington, DC

Re: ChessV 2.0 - open source GUI and engine for chess varian

Post by Greg Strong »

Nordlandia wrote:Gregory Strong -->

Please consider add "Two King Each" to the program.
Ok, this does not look too difficult. The name of the game is "wild9"? Any information on who invented it and when?

Also, concerning this:
Castling is done as in normal chess. You lose the right to castle if either one of your kings move.
I think this implies that you can only castle queen-side?
User avatar
Greg Strong
Posts: 388
Joined: Sun Dec 21, 2008 6:57 pm
Location: Washington, DC

Re: ChessV 2.0 - open source GUI and engine for chess varian

Post by Greg Strong »

hgm wrote:
Greg Strong wrote:I don't think I'd do the lion the same way I do Marseillais Chess though, ...
How does it work in Winboard?
WinBoard (and the Interactive Diagram JavaScript) highlight squares that are (or can be) intermediate destinations in a different color (cyan) than final destinations (yellow or red, depending on whether it is a capture). When you release the piece on a cyan square, the piece remains selected, and the possible target squares of the next leg are then highlighted. Including the square the piece is now on if this intermediate destination can also be the final one. Intermediate squares are only given as a option when something is captured there; adjacent empty squares are always considered final destinations.
Ok, I like this. It makes good sense. I'll have to give some thought about how I fit that into the existing UI code. I think you've told me this before - sorry if I'm making you repeat yourself!
hgm wrote:
I'm more worried about the repetition rules in Xiangqi.
Well, there is a reasonable logic underlying those. Most of the apparent exceptions follow from the fact that they are based on legal moves, not pseudo-legal. So an attack is only an attack if you can legally capture the piece, and a piece is only protected if you can legally recapture on its square once it gets captured. (So you protect against a specific attack, not the piece per se.) This of course make it a pain to detect it, because you really need to do the 2-ply search on all the captures to see if the recaptures are legal. So basically you generate all legal attacks before your move, and then after your move, and look if any new (attacker, victim) combinations did arise. (The same piece attacking from a different square still counts as the same attack, because actually capturing erases all memory of where the attack was coming from!) Then you play those new captures, and check if legal recapture is possible. If not, the victim was not protected, and your move chased it. If you chase the same piece on every move of the repeat loop, it is a perpetual chase. (And this can still be a draw if the other side is perpetually chasing as well.)

There are a few exceptions to these basic rules:
1) An attack on an unpassed Pawn is never a chase. (Too insignificant)
2) An attack by a King is never a chase. (Too difficult?)
3) An attack with C or H or a Rook is a chase even when the Rook is protected. (Too valuable)
4) An attack on a piece that can capture its attacker legally (R on R, C on C, H on H) is not a chase, even if the attacked piece is unprotected. (Trading yourself is as good a defense as recapturing)

Cases 1-3 save you the trouble of checking if the victim is protected. (And 1-2 even whether the capture itself is legal.) In Case 4 the protection only becomes relevant when trading is not legal. (When the victim is pinned by another piece. Remember that in XQ you can be pinned by Cannons that cannot capture you.)

There still is a complication when checks are involved, as being in check makes most moves illegal, and evading the check then seemingly creates many new attacks. The rules are ambiguous in this, but all people I discussed it with play it like the legality of captures by a checked side should be judged as if the existing attack on the King is temporarily disabled.
Thank you for the info. This is helpful but will still require significant thought about how to pull it off...
User avatar
Greg Strong
Posts: 388
Joined: Sun Dec 21, 2008 6:57 pm
Location: Washington, DC

Re: ChessV 2.0 - open source GUI and engine for chess varian

Post by Greg Strong »

Thank you for the bug reports! I'll see what I can do to reproduce/fix...