1

I am creating a Chess Game in Unity. I want to build my game for Android. For AI I am using Stockfish Chess Engine and more particularly "Stockfish-9-arm64v8" file which is a binary file for Android. I have created a C# script which creates a process to run this binary file and communicate with it. When I try to Start my process the exception is raised ->

try{
     mProcess.Start(); 
}
catch(Exception e){
    Helper.PrintString(e.GetType().ToString()); // ----------------(1)
    Helper.PrintString(e.Message); // --------------(2)
}

/* 
(1) is printing : 
 system.componentmodel.win32exception
(2) is printing : 
ApplicationName = 
'/storage/emulated/0/Android/data/com.chessmania.chess/files/Stockfish-9- arm64v8', CommandLine = '', CurrentDirectory = ''
*/

Also my process info parameters are as follows:

ProcessStartInfo si = new ProcessStartInfo() 
{
FileName = System.IO.Path.Combine(Application.persistentDataPath, "Stockfish-9-arm64v8"),
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardError = true,
RedirectStandardInput = true,
RedirectStandardOutput = true
};

Can anyone please help me with it. I have been trying to resolve this issue past few days but unable to. Does it have something to do with file permission?? I mean shall I include some arguments in my ProcessInfoParameters to forcefully run the binary file?? I really don't know if this is the problem or something else? Correct me from the start if I am wrong.

I just want to integrate Stockfish Chess Engine with with Unity Project and build it for Android Platform. If anyone has any ideas or suggestions or if anyone has dealt with similar problem before, please let me know how to solve this issue. I would be grateful. Thanks for bearing with me till here :)

Summi
  • 63
  • 8
  • 1
    Probably the problem is that `Stockfish-9-arm64v8` is compiled for `arm64v8` architecture, while windows runs on `x86`? – Vladyslav Matviienko May 14 '18 at 07:39
  • `So how can I run` I think that you should find a proper file for win32 first. `doesn't it get converted to Android machine code` no, it doesn't – Vladyslav Matviienko May 14 '18 at 09:19
  • @VladyslavMatviienko I think Summi is trying to run this on Android, so I'm not sure what you mean by the problem being that "Windows runs on x86." (I think the `Win32Exception` is a `Process.Start` Mono exception, but I'm not familiar with this on Android.) Also, the [Android download link for Stockfish](https://stockfishchess.org/download/) gives arm64v8 and armv7 files so I don't think using incorrect files is the problem. – sonnyb May 14 '18 at 12:17
  • Just to be sure, the errors you posted are from a built app running on Android, right? Also I would suggest you figure out how to use adb for debugging Android apps if you haven't yet - you should be able to see the exception message or do `Debug.Log(e)` directly rather than only logging parts of the exception. I don't have any ideas on this but maybe [this thread](https://stackoverflow.com/q/43566840/5170571) will be useful. Also, I saw your other question - if you really think it's file permissions, you might want to figure out how to do that to try and se if it works or rule it out. – sonnyb May 14 '18 at 12:21
  • Also, you should include more info about why you think it's a "file permission" issue because it's not clear why from the question. I happen to know what you're talking about because I remember your other question... – sonnyb May 14 '18 at 12:24

0 Answers0