lightvector / KataGo

GTP engine and self-play learning in Go
https://katagotraining.org/
Other
3.51k stars 565 forks source link

Has anyone tried to test this in a unity engine #815

Open Shahjamal-frag opened 1 year ago

Shahjamal-frag commented 1 year ago

I wanted to test this in a unity game but I'm not sure how to. Has anyone tried this before?

Emanuel-de-Jong commented 1 year ago

I don't think there's a C# wrapper for katago. So you would have to start it in a new process and make code to interpret the output. This is the way that most programs using katago interact with it. There's no reason why it wouldn't work for unity specifically.

I'm making a C# program that uses katago myself. It's private, but I dumped the relevant code in a pastebin: https://pastebin.com/YR4Nkyyq The code is not great, but it can give you an idea of what to do.

Out of curiosity, what are you making?

Shahjamal-frag commented 1 year ago

i want to run katago but not as a separate service. I want to integrate it in a game which will run on switch but i think switch doesnt allow 2 applications to run at a time. So i am stuck right now. Do you have any suggestions?

I don't think there's a C# wrapper for katago. So you would have to start it in a new process and make code to interpret the output. This is the way that most programs using katago interact with it. There's no reason why it wouldn't work for unity specifically.

I'm making a C# program that uses katago myself. It's private, but I dumped the relevant code in a pastebin: https://pastebin.com/YR4Nkyyq The code is not great, but it can give you an idea of what to do.

Out of curiosity, what are you making?

Emanuel-de-Jong commented 1 year ago

There might be a work around for that, but I don't know any.

Running katago on a switch could be a problem because they have their own operating system. I would first test if katago even works on it and if so, if using the C# Process class really doesn't work.

Alternatively you could make an API server with endpoints to interact with katago. That would solve both problems and katago's strength won't be limited by the switches hardware. Though it'll cost money, the app won't work without internet and you'll probably want to make it multi threaded which can be difficult.

Might be better to just go with an AI that doesn't use a neural network like GNU Go...

lightvector commented 1 year ago

If it's just the neural network and getting GPU acceleration libraries and such to work that's the problem but you have the ability to run other processes like GnuGo, then you could consider using the pure CPU version of KataGo. If you don't have the ability to run other processes at all, then it's less clear what you do.

ChinChangYang commented 1 year ago

To use KataGo GTP as a function, you can refer to how I have done for KataGo iOS. I redirected the buffers of standard input and output streams to communicate with KataGo in iOS development. So, you can send GTP commands to KataGo via the stream buffers.

https://github.com/ChinChangYang/KataGo/blob/ios-dev/ios/KataGo%20iOS/KataGo%20iOS/KataGoHelper.mm