Topic: Maratis Chess

Here is Maratis Chess
an UCI Chess client written with Maratis ( actually using cross-platform Rodent Chess Engine )

http://www.misadev.com/p/maratisChess/screens/chess.jpg

http://www.misadev.com/p/maratisChess/screens/scn1.jpg

end of this match
http://www.misadev.com/p/maratisChess/screens/scn2.jpg

Everything about controlling legal move, checkmates , check , castlings and stalemate are done.

Input:
"arrow" to rotate te board "space" to reset the view
mouse click and move system implemented

here is the project if you wanna take a look
Still missing a working chess engine to play human vs computer
missing a turn control
pre-pre-pre-alpha

Playable Alpha version

UPDATE: 01/09/2013
updated wih a lua based ai too try on other platform ( win & mac reports are welcome smile )

UPDATE: 28/08/2013
--First milestone!
UCI Protocol comunication plugin implemented
Now you can play as white anganist an UCI chess engine!

Next step:
-turn control!
-playing color selection!
-table switching!
-improve graphics!
hope to get a final/usable product soon! smile

Last edited by SadWolf (2013-09-01 18:29:14)

Re: Maratis Chess

nice project,
how do you plan to interface a chess engine in c++ ?
using behaviors ?

Re: Maratis Chess

Today I have studied a bit the uci interface.
UCI compatible chess engine are standalone programs that works with commands throught stdin / stdout.
I will need two half-duplex connection between maratis and the chess engine process.
Lua can't handle a half-duplex interprocess connection so I need to implement, two lua functions
1 - lua function for sends commands from maratis to the other process throught the stdin of the receiver
2 - lua function that receive the stdout of the other process

Do you think that's gonna be painfull?

Re: Maratis Chess

Looks very good it could be made into a full game easily and thanks for the project. smile

Re: Maratis Chess

it should not be too complicated.
you can add a function using the script context.

Re: Maratis Chess

@argoon: thanks! my first goal is to make a simple playable version using external professional chess engines smile
second goal is to make it usefull for learning adavanced tecniques and openings, with supports and hints

@anael: I'm trying to create a plugin, I have started with a simple helloworld, it worked!

/////////////////////////////////////////////////////////////////////////////////////////////////////////
// SimpleGamePlugin.cpp
/////////////////////////////////////////////////////////////////////////////////////////////////////////

#include <MEngine.h>
#include "SimpleGamePlugin.h"
#include <iostream>

int helloworld()
{
    std::cout << "hello world" <<std::endl;
    return 0;
}

void StartPlugin(void)
{
    // get engine
    std::cout << "hello world plugin started" <<std::endl;
    MEngine * engine = MEngine::getInstance();
    MScriptContext* script = engine->getScriptContext();

    script->addFunction("helloworld", helloworld);
}

void EndPlugin(void)
{

}

Last edited by SadWolf (2013-08-27 22:58:48)

Re: Maratis Chess

after a lot of work between nigth and morning I have created a plugin that can interact with an external program throught the stdin/stdout

here is the code...
The tricky part was finding a way to create a fullduplex communication system between two process throught stdin/stdout

Hope this helps someone smile

#include "ChessEngineInterfacePlugin.h"
#include <MEngine.h>
#include <sys/types.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <poll.h>

#define READ 0
#define WRITE 1

int infp, outfp;
char buf[4096];
struct pollfd ufds;

/** Interprocess comunication throught stdin/stdout */
pid_t
popen2(const char *command, int *infp, int *outfp)
{
    int p_stdin[2], p_stdout[2];
    pid_t pid;

    if (pipe(p_stdin) != 0 || pipe(p_stdout) != 0)
        return -1;

    pid = fork();

    if (pid < 0)
        return pid;
    else if (pid == 0)
    {
        close(p_stdin[WRITE]);
        dup2(p_stdin[READ], READ);
        close(p_stdout[READ]);
        dup2(p_stdout[WRITE], WRITE);

        execl(command, command, NULL);
        perror("execvp");
        exit(1);
    }

    if (infp == NULL)
        close(p_stdin[WRITE]);
    else
        *infp = p_stdin[WRITE];

    if (outfp == NULL)
        close(p_stdout[READ]);
    else
        *outfp = p_stdout[READ];

    return pid;
}

int readChessEngineOutput(){
    int rv;
    rv = poll(&ufds, 1, 1);
    if (  rv > 0 ){
        read(outfp, buf, 4096);
        printf("%s",buf);
    }
    return 0;    
}

int sendCmdToChessEngine()
{
    printf( "write to chess engine" );
    write(infp, "uci\n", 4);
    return 0;    
}

int initChessEngine()
{
    if (popen2("./Linux/rodent-32-ja", &infp, &outfp) <= 0)
    {
        printf("Unable to exec sort\n");
    return -1;
    }
    *buf = '\0';    
   ufds.fd = outfp;
   ufds.events = POLLIN | POLLPRI;

   printf("Chess engine link started");
   return 0;
}

void StartPlugin(void)
{
   MEngine * engine = MEngine::getInstance();
   MScriptContext* script = engine->getScriptContext();

   initChessEngine();

   script->addFunction("initChessEngine", initChessEngine);
   script->addFunction("readChessEngine", readChessEngineOutput);
   script->addFunction("commandChessEngine", sendCmdToChessEngine);
}

void EndPlugin(void)
{
    close(infp);
    close(outfp);
}

Re: Maratis Chess

So milestone!

Beta UCI protocol interaction completed!
Now you can play a match as white aganist an uci engine that plays as black!!!

Re: Maratis Chess

Hi heartseed! smile
Thanks for the consideration !!!

(You re an artist! So you can help me with graphics!!! XD)

Thanks for trying the game! At the moment it works only on linux, bring it to windows and macosx soon...
Actually I'm a coder and I'm pretty confident with maratis system.
Before of maratis I used many other engines smile so I'm not so new to game ambient...
At the state of art the game took me about 12 hours.

I haven't uploaded yet the latest version, cause it works only on linux at the moment.
I will finish it on linux, then port it to windows and then to macosx.

The pre-pre-pre-alpha version haven't the AI integrated yet.
Lua based AI are too weak beacuse lua is a bit slow for intensive computation.
So I have integrated C based strong AIs with UCI.

I will upload tonight the 0.1 version I'll try to port it on windows.
I haven't done it yet on windows cause I have to compile C plugin on windows,
I'm not sure if windows has all the library that I used in C
or if they are linux-specific libraries.

The problem of making a game is that we always overthink about what to do smile
we are atracted by big titles and we want to make big-title-games too...
in the end we finish with too much work to do and... give up...
I think that you should go with simple projects espacially if you are all alone to work on it...

Anyway hope you'lll give a try to my game soon smile
I'll upload it asap!

Re: Maratis Chess

OK gotcha wink

Yes, big projects and being alone is bad combo..dream big , aim reasonable I guess wink

Sounds good, look fwd to it.

AS a case study, what have you found kewl in maratis that you left behind in other engines..

Like ogre3d as a comparison, often I hear its difficult to integrate other libraries..

cheers
hs

Re: Maratis Chess

Actually I love maratis cause you can do more with less...
If you use complex libraries, it's painfull to learn everything, even simple things takes a lot of work...
maratis is very easy and usually most common things has a lua function,
and anyway having a tool like the maratis editor makes the job done faster.

All libraries in maratis are already togheter: audio, graphics and physics... this make it a complete game engine

So why do I like maratis?
-cause is _easy_ ,
-is fast for _prototyping ideas_
-no complex setup, just download the zip e start lua code
-perfectly compatible with blender ( which works good on linux )
-easy plugin system to extend the game engine with new funcitons
-good builtin editor

smile

Last edited by SadWolf (2013-08-29 20:36:25)

Re: Maratis Chess

SadWolf wrote:

Actually I love maratis cause you can do more with less...
If you use complex libraries, it's painfull to learn everything, even simple things takes a lot of work...
maratis is very easy and usually most common things has a lua function,
and anyway having a tool like the maratis editor makes the job done faster.

All libraries in maratis are already togheter: audio, graphics and physics... this make it a complete game engine

So why do I like maratis?
-cause is _easy_ ,
-is fast for _prototyping ideas_
-no complex setup, just download the zip e start lua code
-perfectly compatible with blender ( which works good on linux )
-easy plugin system to extend the game engine with new funcitons
-good builtin editor

smile

I agree! I have been through hundreds of software, even old software no one probably knows of. I think the first game engine I messed around with some time ago was the cube engine with a game named Saubraten or something. It was terrible.

Anyhow, all the things you have mentioned are the reason I like this engine so much. BTW, nice job!.

Re: Maratis Chess

heartseed wrote:

Cube 2 is pretty decent overall actually, though the 'editing' in some ways leaves alot to be desired, but overall the editing is pretty amazing in what you can do. Never tried just cube engine itself per se, but platinum arts sandbox engine isn't half bad actually in some ways and they are actually working on improving it.

It was a long time ago when I used it. Hopefully it is much better. It looked like Doom 95 then. hehe

Re: Maratis Chess

@Tutorial doctor thanks!

Updated with the last game version,
I disabled UCI for now , and enabled a simple LUA based AI
enjoy

still missing a menu and a decent graphics smile

Last edited by SadWolf (2013-09-01 18:40:06)

Re: Maratis Chess

I am going to play around with this and add another board style (maybe several) and perhaps an environment? We will see.

First one:
https://sites.google.com/site/maratisfiles/files/Screenshot%20%28917%29.png
Need to get my normal map working though.

Last edited by Tutorial Doctor (2013-12-07 04:47:03)

Re: Maratis Chess

Hey big_smile it looks very good! I'd like to add something like animated pieces smile

Last edited by SadWolf (2013-12-09 12:15:13)

Re: Maratis Chess

SadWolf wrote:

Hey big_smile it looks very good! I'd like to add something like animated pieces smile

That is the thing about Maratis, Marstis meshes can't be edited directly. Id have to have the original 3d files, and then open them in blender. Also, each one would have to be rigged because Maratis only accepts armature animation and not key frame animation.

I thought about using ASSIMP, but I have not been able to get an animated collada file out of Blender (I think the ASSIMP importer can handle animated collada files, but I'm not sure if Maratis can).

Re: Maratis Chess

Here we are again! smile

Working now on graphics... here is draft ( to improve )
http://www.misadev.com/p/maratisChess/screens/test3.jpg

Last edited by SadWolf (2013-12-13 21:28:43)