How to develop a chess program from scratch (for total beginners) Ep. 2

Huo Chess (console edition)

Interested in chess programming? You are interested in philosophy too! What is thinking? Can AI be conscious? What does it mean to do something? Can the AI understand that it does play chess? Explore the AI related articles in Harmonia Philosophica and understand why you are already a philosopher!


[Previous episode]


In the previous episode we set the foundations for starting a chess program. In summary we…

  • Discussed the pre-requisites for the tutorial
  • Created the chessboard
  • Got the first input from the user

Now it is time to start the design of the chess thinking algorithm.

Step 0: Design the main steps on paper

Before making any serious programming attempt, one has to leave the computer and get a piece of paper. There, he can design the algorithm of the program. A good design is invaluable for a good program. There is no need to start writing code without having that design first!

Chess program algorithm outline

One can find above a rough outline of the major steps involved in a chess program algorithm.

Note that this algorithm is an over-simplification, but it will do for now. For example, the algorithm above does not take into account the fact that the thinking of the computer must be conducted in various depths and not only in the initial position. We will elaborate on that in next episodes; for now let us just try to analyze all possible moves in a position and choose the one that leads to the best score.

[Next episode: Scanning the chessboard for moves]

[Previous episode]

Learning Greek for Beginners series


The “Learning Greek for Beginners” series is a series of articles that aim at giving you fast-pace lessons on how to speak Greek. They were originally posted in Google Knol in a contest for articles for ‘Dummies’.

List of Lessons

The list of lessons available can be found below

Please do not hesitate to contact us for any comment and/ or suggestion.

Learning Greek for Beginners – Lesson 4 [Asking for food]

Learning Greek for dummies – Lesson 4: How to order food!

  • This Knol is part of the Learning Greek for Beginners collection.
  • Please ask any question you have regarding Greek by posting comments! I will gladly help you! Post comments and / or send me emails to do so!
  • Learning Greek Tip: Use the daily Harmonia Philosophica Philosophy Wires to learn Greek! Each Philosophy Wire is written in both English and Greek (with the specific goal to convey the same exactly meaning), so by reading both you can have some very good learning guides on Greek language!!! Contact me for any help you might need!

Lesson 4 summary

This lesson will focus on practical Greek. How to speak and manage to ‘survive’ in Greece, i.e. how to order food.

Eating food in Greece is always a delight… (source: eating-everyday)

Dialogue No. 4: Food!

Let’s start with the most important thing: Food!

Greece is know for its great food, so knowing how to order it is vital. Without further adieu…

– Γεια σας. [Geia sas]

– Καλημέρα. [Kalimera]

– Θα ήθελα δύο σουβλάκια παρακαλώ. [Tha ithela dyo souvlakia parakalo]

– Ευχαρίστως. Θέλετε και κάτι άλλο; [Euxaristos. Thelete kai kati allo?]

– Θα ήθελα και ένα μουσακά και μία ντομάτες γεμιστές. [Tha ithela kai ena moussaka]

– Μόνο αυτά; Κάτι άλλο; [Mono auta? Kati allo?]

– Και λίγες πατάτες τηγανητές παρακαλώ πολύ. [Kai liges patates tiganites parakalo poly]

– Ωραία. Θα πιείτε κάτι; [Oraia. Tha pieite kati?]

– Ναι. Λίγο κρασί. Και μια σόδα. [Nai. Ligo krasi. Kai mia soda]

– Ευχαριστώ πολύ. [Euxaristw poly]

In English that same dialogue means:

– Hello.

– Good morning.

– I would like two souvlakia please.

– Gladly. Would you like something else?

– I would also like a moussaka and a portion of stuffed tomatoes.

– Only these? Anything else?

– And some fried potatoes please.

– Good. Will you drink something?

– Yes, some wine. And a soda.

– Thank you very much.

Asking for things

As we saw in the dialogue above, the main verb here is Θέλω (Thelo), which means “I want”. If I wans to say “I want a moussaka” I simply say “Θέλω ένα μουσακά” (Thelo ena moussaka).

Always remember to be polite and say please (parakalo) when asking something.

Lesson Questions & Answers

Do you have any comments or questions? Please post here as comments and I will get back to you!

Translation Help

In case you need any assistance in translating something to or from Greek, contact us directly via email or via comments in the bottom of the page.

The adventure of creating… an adventure! Episode 1: Setting up the images [Quick Basic/ QB64 Tutorial]

First Adventure (in QB64)


Programming is fun!

What does that have to do with a philosophy portal?

Well… I do not know!

But then again…

What do we know about life or death?


The goal of this series of tutorials is to show how to create a small (or big?) adventure game with Quick Basic, so as to disseminate programming knowledge. Even if you do not have prior programming knowledge you will be able to follow the series with some additional effort to clear up some programming details we will encounter along the way.

The source code of the program will always be provided at all steps of the tutorial. Reuse of the code is allowed as long as the source is mentioned properly.

Tools needed

To follow the tutorial you just need the Quick Basic in your computer. Just download the latest QB64 from the relative site here for free.


Before doing any programming one must design what he wants to do. This applies to small as well as big programs.

So what do we want to do?

To create an adventure game!

This game will utilize simple images that we will show to the users as they progress along the game. All the typical adventure game commands will be allowed: Look at, Walk to, Pick up, Use, Talk to, Give, Push, Pull.

The game scenario is something I have not yet thought in its entirety. However I know that the game will start from a room where you are and where you will need to stay alive for at least one day before the rescue team comes and saves you.

The beginning

From where to start from?

Well, from the start (welcome) screen!

To do that we use the PRINT command to print the game title on the screen.

The game will be called…

First Adventure!

Since it is our first adventure.

LOCATE 10, 32: PRINT "First Adventure!"
LOCATE 11, 30: PRINT "Greece, Athens, 2022"
LOCATE 13, 25: PRINT "Seek the moon under the sun…"

The LOCATE commands puts the cursor in a specific line and then we print what we want.

First Adventure – Start image

Setting up the images

Each game takes place in a… place.

To illustrate things we need graphics.

We will use basic graphics in our game, i.e. images we will load into the screen to show things. The first thing is to get the images, right? For the purposes of our tutorial we will use images that are 580×420 pixels in dimension. These images will be shown in a window that is 800×600 in dimensions.

Why these dimensions?

First, for no reason. Just because.

Secondly, I like to have a small window for the program to show small images. You guessed it, the program will not utilize the full screen and will not resize based on the resolution of your screen. Let’s start with the basics and build a bike and we will go to building a spaceship after that…

Images are loaded with the _LOADIMAGE command as it is shown below.

IF GameResolution = 800 THEN
    imgBgrd& = _LOADIMAGE("FA_image_Background_800.png", 32) 'Background image
ELSEIF GameResolution = 1280 THEN
    imgBgrd& = _LOADIMAGE("FA_image_Background_1280.png", 32) 'Background image

You also guessed it right: We have introduced a variable that indicates the resolution of the game. So when I told you that the game will not take into account the resolution of your computer, I lied a bit. Just a bit. We introduce a variable to indicate the resolution used and we will embed it in the code and… we will see how to use it the future.

For now, let’s set the resolution at 800×600…

CONST GameResolution = 800 'Set for resolution 800x600

We repeat the same loading of images for all images of the game. For now, we only have three images: the background image (that is loaded in the beginning and… stays there for ever) and two more images that we put on the background when he game starts.

First Adventure – Background image

The background

The image I have created for background is a black colour image with a white line. This line will be the border between the upper and the lower part of the screen.

  • In the upper part we will show images that are related to the gameplay, e.g. the photo of a room you are in.
  • In the lower part of the screen we will show to the user the possible commands allowed for the game, his inventory of objects (if and when we add one) and any messages.

Simple enough. Yet, nice and effective.

How are those images put in the screen though?

Well, with the PUTIMAGE command…

IF GameResolution = 800 THEN
    _PUTIMAGE (100, 20)-(680, 440), imgStart&, 0
ELSEIF GameResolution = 1280 THEN
    _PUTIMAGE (80, 20)-(660, 500), imgStart&, 0

With the PUTIMAGE command you can set where to place your image upper-left corner (100,20) and where the lower-right corner will be (680,440), which image to load (imgStart&) and where to show it (0 denotes the screen). In that way we can put any of the images we have loaded wherever we want.

First Adventure – Start image

Show the initial messages

When the game starts and the background image is loaded, we print the initial messages to the user. We use the LOCATE command and print the messages in the lower part of the screen, as mentioned above…

'Print text to begin the adventure...
LOCATE 33, 1: PRINT "You are in a room... Alone..."
LOCATE 34, 1: PRINT "There is a snow storm raging outside..."

'Show the trees!
_PUTIMAGE (100, 20)-(680, 440), imgTrees1&, 0

LOCATE 33, 1: PRINT "You must survive for one day..."
LOCATE 34, 1: PRINT "Until the rescue party comes to save the day!"

And as you see in the code, we can load new images whenever we want to show new things. In that case we have loaded a trees picture. After all, we are in a snow storm…

Important Notes

  • Guess what the SLEEP command does. Try to remove it and see what happens.
  • Experiment with the coordinates in the PUTIMAGE command to see how that command can be used. (seek some additional examples commented out in the source code provided)

An epilogue and a promise…

We have just set up the scenery for our game. We have the initial screens and we have understood how images are loaded. We will build on this to expand the game and take it to the next level…

APENDIX I – The source code

Please see below for the full source code of the game.

'Declare variables
DIM imgBgrd&
DIM imgStart&
CONST GameResolution = 800 'Set for resolution 800x600
'const GameResolution = 1280 'Set for resolution 1280x720

LOCATE 10, 32: PRINT "First Adventure!"
LOCATE 11, 30: PRINT "Greece, Athens, 2022"
LOCATE 13, 25: PRINT "Seek the moon under the sun..."

'Load the background from an image in a file
'Load different pictures depending on the resolution we want
'(because the image will be used to set the screen)
'imgBgrd& = _LOADIMAGE("FA_image_Background_800.png", 32) 'Background image

IF GameResolution = 800 THEN
    imgBgrd& = _LOADIMAGE("FA_image_Background_800.png", 32) 'Background image
ELSEIF GameResolution = 1280 THEN
    imgBgrd& = _LOADIMAGE("FA_image_Background_1280.png", 32) 'Background image

'imgStart& = _LOADIMAGE("FA_image_Start_800.png", 32)

'Load images of the game from files
'Images for resolution 800x600 are 580x420
'Images for resolution 1280x720 are 640x480
'Image Start
IF GameResolution = 800 THEN
    imgStart& = _LOADIMAGE("FA_image_Start_800.png", 32)
ELSEIF GameResolution = 1280 THEN
    imgStart& = _LOADIMAGE("FA_image_Start_1280.png", 32)
'Image trees
imgTrees1& = _LOADIMAGE("FA_trees1.png", 32)

'Set the image as destination
'_DEST img1&

'Set the screen mode based on the background image (800x600 png image)
'SCREEN _NEWIMAGE(800, 600, 32)
SCREEN imgBgrd&

'Set background colour to gray
'CLS , _RGB32(127, 127, 127)

'Present the first image of the game on the black screen
'(i.e. put the image2 on top of image1, which is the background loaded initially)

'_PUTIMAGE (10, 10)-(650, 490), imgStart&, 0
'_PUTIMAGE (200, 200)-(400, 400), img2&, 0, (0, 0)-(400, 400)

IF GameResolution = 800 THEN
    _PUTIMAGE (100, 20)-(680, 440), imgStart&, 0
ELSEIF GameResolution = 1280 THEN
    _PUTIMAGE (80, 20)-(660, 500), imgStart&, 0

'Set text colour
'COLOR 7, 5

'Print text to begin the adventure...
LOCATE 33, 1: PRINT "You are in a room... Alone..."
LOCATE 34, 1: PRINT "There is a snow storm raging outside..."

'Show the trees!
_PUTIMAGE (100, 20)-(680, 440), imgTrees1&, 0

LOCATE 33, 1: PRINT "You must survive for one day..."
LOCATE 34, 1: PRINT "Until the rescue party comes to save the day!"

Copy this code in your QB64 IDE and try it out.

In order to use it you must also have the images the program loads in the same folder as the QB64.exe program.

APPENDIX II – The images

Please fine here the images used by the program.

APPENDIX III – Useful resources

One can find many things in the Internet. Information about programming is one of these things. Seek help in the relative QB64 web site or in relevant programming sites to understand how various Quick Basic commands work.

Below I list some resources related to the commands we used.

Feel free to seek knowledge from where you can!

Chess Program thought process analysis article

The goal of this paper is to analyze in a simple way the thought process of a chess program, so as to facilitate understanding among chess programming enthusiasts and to bolster potential improvements in that process.

Huo Chess thinking algorithm (simple)

A new article “Chess Program thought process analysis (Simple) – The Huo Chess example” has been published.

There the thinking process of a chess program is presented in high level in order to help chess programming enthusiasts gain an initial understanding of the general way a chess program works.

One can find the relative article here at Academia.

A new article with more advanced subjects of chess programming will follow.

One can also download the file from below.

Exit mobile version