Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7623913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:49:33+00:00 2026-05-31T04:49:33+00:00

I was just toying around with making a basic chess engine. I was able

  • 0

I was just toying around with making a basic chess engine. I was able to get a lot of advice from http://web.archive.org/web/20070704121716/http://www.brucemo.com/compchess/programming/alphabeta.htm, but the real site is down and not all the pages are archived. (Anyone know where to find a full version of Bruce’s site?)

But now to the real question: how do I communicate with XBoard? I understand it is via stdin and stdout, but I’ve been having problems in code. Basically, to get started, I just want to

  1. receive input from XBoard and print it to the console/screen
  2. Give a move of hard-coded input to XBoard and have it make the move
  3. program utility functions and have a random chess ai which chooses random moves.

After that, I can start implementing real things like alpha-beta searching.

I am stuck on the first two things right now. Here is some code I have tried to write/borrowed.

#include <iostream>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#define STR_BUFF 256

using namespace std;

int main (int argc, const char * argv[])
{
    char input[STR_BUFF];
    char output[STR_BUFF];
    while(true){
        fflush(stdout);
        // read input
        if (!fgets(input, STR_BUFF, stdin)){
            printf("terminated");
            return 0;;
        }

        printf("%s", input);
    }
    return 0;
}

I am just getting back into C after about 6 months break and this is the first project that I have used stdin/stdout pipelines to communicate with another program (minus a few basic programs) so I would appreciate any help and any explanations. I know programming a chess engine is a herculean task, but I have already programmed the rules of chess before and what I can find of Bruce’s site is absolutely amazing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T04:49:34+00:00Added an answer on May 31, 2026 at 4:49 am

    You are doing it almost right: get a command from XBoard with fgets, then report a move with printf and fflush. (One thing is wrong, though: you don’t need to ‘print the command to the console/screen’; you are not communicating with the console/screen; you only read commands from XBoard and send moves back to XBoard).

    Probably, it would be easier to start with some existing code. Try to read sources for GNU Chess. Or download sources for any other chess engine, supporting XBoard protocol.

    And here is other question with lots of information on chess engine programming: “What are some good resources for writing a chess engine?“.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just trying to get my head around Generics by reading this enlightening article by
Just trying to get my head around what can happen when things go wrong
Just trying to still get my head around IOC principles. Q1: Static Methods -
I am just trying to get my head around various pointer concepts and I
I am just trying to get my head around simple view switching for the
I am messing around with a basic CAAnimation example where Im just trying to
I am just starting with MVC, moving from web forms. Lets take for example:
I am currently toying around with android and making a little bit of a
I have trying to get around making my first C# application(that can do more
So, I was just playing around making some page for fun. I cannot seem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.