Qt3d_chess_Ring

762 views
Skip to first unread message

عزالدين رمال

unread,
Jun 20, 2021, 10:07:03 PM6/20/21
to The Ring Programming Language
Hello Mahmoud
  I'm working on building a 3D chess game with a library QT3D but there are missing functions
Can you add the function 

unproject (const QMatrix4x4 &modelView, const QMatrix4x4 &projection, const QRect &viewport) const   to the class QVector3D
Perhaps a good example of using a class Qt3D
screenshot_21_06_2021_03_00_21.png

عزالدين رمال

unread,
Jun 20, 2021, 10:20:52 PM6/20/21
to The Ring Programming Language
These are screenshots during development

screenshot_21_06_2021_03_12_32.png

CalmoSoft

unread,
Jun 21, 2021, 2:35:12 AM6/21/21
to The Ring Programming Language
Hello  lemsantah,

Congratulations!
Very nice progress.
Have a nice day and good work.

Greetings,
Gal Zsolt
(~ CalmoSoft ~)
Message has been deleted

عزالدين رمال

unread,
Jun 22, 2021, 5:59:29 PM6/22/21
to The Ring Programming Language
Hello  Gal  ,

Thanks for your kind words.

Mahmoud Fayed

unread,
Jun 23, 2021, 2:16:08 AM6/23/21
to The Ring Programming Language
Hello Ezzedine

>> "Can you add the function"


To get this update, use the next command

ringpm update ringqt

Greetings,
Mahmoud

عزالدين رمال

unread,
Jun 23, 2021, 5:22:41 AM6/23/21
to The Ring Programming Language
Hello Mahmoud
Thank you so much
Message has been deleted
Message has been deleted

عزالدين رمال

unread,
Jun 26, 2021, 9:13:45 PM6/26/21
to The Ring Programming Language
Hello Mahmoud and everyone

This is what I have achieved so far
The game is not working properly I need some help
I hope iller and Bert can help me fix it

Bert Mariani

unread,
Jun 26, 2021, 10:28:22 PM6/26/21
to The Ring Programming Language
Hello Ezzedine

First ... Very impressive 3D display of the Board and Chess Pieces !!!

Next step:
Ignore the "Rules" for now.
Try to move a Piece from a  Source square to a Destination square.
Empty out the Source square, draw Piece on Destination square
     Or -  Redraw the All Pieces to their New Position.
Message has been deleted

عزالدين رمال

unread,
Jun 28, 2021, 1:25:10 PM6/28/21
to The Ring Programming Language
Hi Bert
Another problem is the mismatch between the board matrix and the distribution of chess pieces 
If you have a little time, help me

I tried to flip the matrix but that doesn't work

board = [

['R', 'P', ' ', ' ', ' ', ' ', 'p','r'],

['N', 'P', ' ', ' ', ' ', ' ', 'p','n'],

['B', 'P', ' ', ' ', ' ', ' ', 'p','b'],

['K', 'P', ' ', ' ', ' ', ' ', 'p','k'],

['Q', 'P', ' ', ' ', ' ', ' ', 'p','q'],

['B', 'P', ' ', ' ', ' ', ' ', 'p','b'],

['N', 'P', ' ', ' ', ' ', ' ', 'p','n'],

['R', 'P', ' ', ' ', ' ', ' ', 'p','r']

]

عزالدين رمال

unread,
Jun 28, 2021, 1:52:40 PM6/28/21
to The Ring Programming Language
Hello Mahmoud
Why can't I access the object defined inside a conditional statement except within it?

  if piece = 'k' or piece = 'K'

 oking = new Model3d(oPieceEntity, oking, "models/king.obj")

oking.setModelpos(i*17-75, 0, (7-j)*17-42)

oking.setmodelSiz(0.17, 0.18, 0.17)

// oking.removeComponent()

// White piece.

if ascii(piece) < 96

oking{

SetModelTexture("textures/WhitePiece.jpg")

setModelDirection( 0, 1, 0, 90)

}

if selectionI = i and selectionJ = j

oking{

SetModelTexture("textures/WhitePieceCliked.jpg")

}

ok

// Black piece.

else

oking{

SetModelTexture("textures/Black Piece.jpg")

setModelDirection( 0, 1, 0, 270)

}

if selectionI = i and selectionJ = j

oking{

SetModelTexture("textures/BlackPieceCliked.jpg")

}

ok

ok

When trying to access the object from someone else inside the function it returns an error that it is not defined

عزالدين رمال

unread,
Jun 28, 2021, 7:23:02 PM6/28/21
to The Ring Programming Language
Hello Mahmoud and everyone
Another note, there is a memory leak, the application runs smoothly, when I open the task manager in Windows 10, there are alerts that send errors to Microsoft

Ilir

unread,
Jun 28, 2021, 7:59:45 PM6/28/21
to The Ring Programming Language
Hello,

I can confirm memory leak. However, I don't see any alerts reported on Windows 10 Pro 64 bit.

Regarding object access: it can be accessed after it is created. Keep in mind: Ring is dynamically, not statically typed language. In above example, oking object becomes available if piece = 'k' or piece = 'K'.

عزالدين رمال

unread,
Jun 30, 2021, 11:48:25 AM6/30/21
to The Ring Programming Language
Hello iller
For memory, I call the display function, which every time produces new entities and is not deleted
I'll try to fix it by deleting the old entities before calling the view function.
I want to use  QSkyboxEntity   and I can't find examples except in Qml .
 If you can, or one of the team members can give us an example of their use
Thank

عزالدين رمال

unread,
Jun 30, 2021, 12:17:58 PM6/30/21
to The Ring Programming Language
Hello Mahmoud
I wrote this function to delete entity components, but it doesn't work properly and terminates the program


//---------------------Use-------------------------------

// entity = new QEntity(.......)

//DeleteEntityRecursively(entity)

//---------------------------------------------------

 func DeleteComponentRecursively(Entity)

                        ComponentsToDelete = Entity.Components()

                                           for Component in ComponentsToDelete

                                                            Entity.removeComponent(Component)

                                                          Del(ComponentsToDelete, Component)

                                                            Component = Nullpointer()

                                            next

                           ChildrenNodes = Entity.ChildNodes()

                                              for ChildNnode in ChildrenNodes

                                                               del(ChildrenNodes, childNode)

                                              next

                          entity = nullpointer()




I tried to use #    oPieceEntity.deleteLater()   #   but it permanently deletes the entity from memory

عزالدين رمال

unread,
Jun 30, 2021, 5:35:35 PM6/30/21
to The Ring Programming Language
Hello Mahmoud and everyone
I made a handmade skybox waiting for the trumpet  QSkyboxEntity 
when using

 oForwardRenderer = oView.defaultFrameGraph()

oForwardRenderer{

setClearColor(new QColor() { setrgb(000,204,000,255) })  This works

setFrustumCullingEnabled(false)   This does not work

setGamma(2.5) This does not work

}


I want to stop Frustum Culling to be able to enlarge the cube in QT document in class QskyboxEntity  this is required

عزالدين رمال

unread,
Jun 30, 2021, 5:47:55 PM6/30/21
to The Ring Programming Language
screenshot_30_06_2021_22_40_10.png

Bert Mariani

unread,
Jun 30, 2021, 7:54:42 PM6/30/21
to The Ring Programming Language
Hello Ezzadine

Made these changes to try to understand your code

SetModelTexture("textures/BlackPiece.jpg")  <<<  removed space in "Black Piece.jpg"
Do the same in your jpg name.

Global definition for the degree of tilt
   degreeW = 45       //  90
   degreeB = 45 +180  // 270
The tilt of the wooded board and the tile shows opposite directions ??!!
See screen capture

Removed all the "elseif"  for the Piece drawing to simplify the look
Just using  if..ok  to match a piece.

Added "SEE" to show  tile that was clicked on.
Get wrong position I-J being reported every 2nd tile.

Attached modified file -- QD3d_Chess.ring.txt   (remove .txt after download)

In your display ... please remove the "Event i:5 and j:7 .."  --- too messy looking
Add it to the top title bar for readability  

Note:
White pieces go on the bottom of the board
Black pieces go on the top of the board.

Chess-3D.png


Qt3d_Chess.ring.txt

Ilir

unread,
Jun 30, 2021, 7:58:00 PM6/30/21
to The Ring Programming Language
Hello,

it seems setting frustum culling flag works (only?) for QSkyboxEntity.

You don't have to worry about it, just change your camera far plane position from 1000 to 10000 for example.

Bert Mariani

unread,
Jun 30, 2021, 8:47:32 PM6/30/21
to The Ring Programming Language

More readable when displayed in 3D screen


func mouseInput(i,j)
....
   oText3d.setText3D("IJ: " +i +"-"+ j + " B: " + board[i][j] )

Main problem with the 3D is that the Mouse Click does not give the proper I-J co-ordinate

Bert Mariani

unread,
Jun 30, 2021, 9:15:15 PM6/30/21
to The Ring Programming Language
Observation:
The White and Black Knights face different directions when these values are used !!
Board and Tile also point id different directions ??

   degreeW = 30      //  90
   degreeB = 210     // 270

Chess-3D-Knight.png

Bert Mariani

unread,
Jun 30, 2021, 9:22:01 PM6/30/21
to The Ring Programming Language

   degreeW = 30      //  90
   degreeB = 210     // 270

Knight-2.png

عزالدين رمال

unread,
Jun 30, 2021, 9:36:04 PM6/30/21
to The Ring Programming Language
Hello Bert and ilir
Thanks Burt for the great advice, I will study the attached code and try to use it
As for the determination QObjectPicker   it is not very accurate and determines what is under the cursor by about half a centimeter
There is a lot missing from the ring, mouse control, animation..etc.
  I hope Mahmoud will add it in future releases
  The problem in transplanting the plate is opposite to the transplanting of cutting
Although the implant is based on the matrix board[][]
By me ###oText3d.setText3D ( "IJ:" + i + "-" + j + "B:" + board [i] [j])###   this is for tracking errors and it will be removed in the end
========================================================

 oboard = new Model3d(oRootEntity, oboard, "models/board.obj"){

setmodelsiz(0.23, 0.2, 0.23)

setmodelpos(0, 0, 0)

SetModelDirection(0,1,0,degreeW)

SetModelTexture("textures/chessboard_wood.jpg")

SetModelDirection( 0, 1, 0, 90)

}

===========================================

In your opinion, what is the cause of the reflection between the plate and the pieces?

Thanks 

عزالدين رمال

unread,
Jul 1, 2021, 12:47:22 AM7/1/21
to The Ring Programming Language
Good morning Bert
After careful tracking, I found the error in the equation for distributing the pieces

setModelpos(i*17-75, 0, (7-j)*17-42)

The correct equation is

for white pieces

 setModelpos(i*17-75, 0, 37-(j*17-42))

for black pieces

setModelpos(i*17-75, 0,(j*17-42)-33)


There is another problem when selecting the pieces, he only sees 7 original pieces, the cloned copies cannot be retextured according to my understanding

screenshot_01_07_2021_05_21_30.png

Qt3d_Chess2.ring.txt

Bert Mariani

unread,
Jul 1, 2021, 3:54:44 PM7/1/21
to The Ring Programming Language
Hello Ezzedine 

Can you tell me what these 3 variables mean for these statements.
What do the variables represent ?
Some of the constant/repetitive  values can be defined as Globals

   oboard = new Model3d(oRootEntity, oboard, "models/board.obj"){
                  setmodelsiz(0.23, 0.2, 0.23)
                  setmodelpos(0, 0, 0)
                  SetModelDirection(0,1,0,degreeW)                   // 90
                  SetModelTexture("textures/chessboard_wood.jpg")
                  SetModelDirection( 0, 1, 0, degreeW)                     // 90
            }


 oking = new Model3d(WhitePEntity, oking, "models/king.obj"){
                           setModelpos(i*17-75, 0, 37-(j*17-42))
                           setmodelSiz(0.17, 0.18, 0.17)
                           SetModelTexture("textures/WhitePiece.jpg")
                           setModelDirection( 0, 1, 0, degreeW)
                        }

Bert Mariani

unread,
Jul 1, 2021, 4:42:52 PM7/1/21
to The Ring Programming Language

When trying to rotate the Tiles using 45 degrees to match the Board rotation at 45 degress
See screen capture.
The individual Tiles rotate, but the placement is not correct

-------------------------------------
         aTile[i][j][:oTileTransform] = new  QTransform(aTile[i][j][:oTile]){
                                             setTranslation(new QVector3D(i*TILE_SIZE-76, 0.05, j*TILE_SIZE-76))
                                             
                                   oQ = new  QQuaternion(0,0,0,0)
                                             SetRotation(oQ.FromAxisAndAngle(new QVector3D(0, 1, 0), 45 ))  // 180
                                  
                                        }


Tiles-1.png
Qt3d_Chess3.ring.txt

عزالدين رمال

unread,
Jul 1, 2021, 6:45:31 PM7/1/21
to The Ring Programming Language
Hello Bert

The equation setModelpos(i*17-75, 0,(j*17-42)-33) is for distributing the boards, where each board represents a square, either white or black

It is the same for the black and white board. I made a mistake in the previous post when I said that here one is for the white board and the other is for the black.


Can you tell me what these 3 variables mean for these statements.
What do the variables represent ?

 oboard = new Model3d(oRootEntity, oboard, "models/board.obj"){
                  setmodelsiz(0.23, 0.2, 0.23)      <<<       To adjust the size of the object
                  setmodelpos(0, 0, 0)       <<<      To adjust the position of the object
                  SetModelDirection(0,1,0,degreeW) // 90     <<<        To adjust the orientation of the object
                  SetModelTexture("textures/chessboard_wood.jpg")          <<<<       To put  Texture  on the object
                
            }

It's all about  Attributes  in the  object3D class included with the files

As for the problem I raised in the previous post
It's when you select the pieces only sees 7 
There is another problem when selecting the pieces, he only sees 7 original pieces, the cloned copies cannot be retextured according to my understanding

oboard = new Model3d(oRootEntity, oboard, "models/board.obj")

When cloning from an object, this name oboard must be unique
Problem solved
As for the memory leak issue
It wasn't a leak but an overload where I was calling the update function in FrameAction()
Now I moved it to the function  HandleNewSelection( i, j)
And the app is working fine

The step of transferring the pieces from the previous board to the target board is over
Now I'm up for the rules
I changed in different files
Because Google does not accept uploading large files in posts, please download the project from the following link
screenshot_01_07_2021_23_16_42.png

Bert Mariani

unread,
Jul 1, 2021, 9:37:24 PM7/1/21
to The Ring Programming Language
Hello Ezzeddine,

Much improved !!!
- I see every Piece has  its own Object.
- Moves can be made 
- The Knight now face each other and in their own forward direction

- The Texture for the Knights covers only the bottom half of the piece. Will need to cover the entire Knight

=========
This msg repeats constantly in "Debug" run mode window

Qt3D.Renderer.OpenGL.Backend: Unable to find suitable Texture Unit
Qt3D.Renderer.OpenGL.Backend: Unable to find suitable Texture Unit
Qt3D.Renderer.OpenGL.Backend: Unable to find suitable Texture Unit

Ilir

unread,
Jul 2, 2021, 6:40:05 AM7/2/21
to The Ring Programming Language
Hello,

nice improvement. Still, memory leaks. For example, move two white figures (each move leaks few megs), then move black figure (leaks approx 50 megs, several times more than white figure).

عزالدين رمال

unread,
Jul 2, 2021, 9:58:59 AM7/2/21
to The Ring Programming Language
Hello iller
Can you tell me how to measure memory leaks on Windows

Ilir

unread,
Jul 2, 2021, 11:39:50 AM7/2/21
to The Ring Programming Language
Hello,

you can do it visually by looking at task manager, ring.exe (like I did), or you can use tools like Dr. Memory or Valgrind which I haven't used (Dr. Memory having some issue, Valgrind haven't tried).

عزالدين رمال

unread,
Jul 2, 2021, 6:03:36 PM7/2/21
to The Ring Programming Language
hello Bert
Can you help me rewrite the rules

Bert Mariani

unread,
Jul 2, 2021, 9:05:21 PM7/2/21
to The Ring Programming Language
Hello Ezzeddine

You are welcome to use the  "moves and rules" from my program: 
Ring->Applications->Chess->AA-ChessBoard.ring

عزالدين رمال

unread,
Jul 7, 2021, 12:10:06 PM7/7/21
to The Ring Programming Language
Hello Bert
In fact, I built these rules in short from your game, big thank you, but it still has a slight bug, which I will address later
I am not building a game of chess, it was built by hundreds of programmers, including you, I study a library ِQt3d
I still don't know how to get rid of the reserved memory while playing and even when I close the game the memory remains reserved unless I remove it manually
How do I delete the memory stored by a program before closing it?

Bert Mariani

unread,
Jul 7, 2021, 6:10:36 PM7/7/21
to The Ring Programming Language
Hello Ezzeddine

You might try calling the Garbage Collector , in between the moves. 
Mahmoud should be able to confirm if this will fix the memory leak, and releasing memory before closing

      CallGC()                  // FIX SPEED SLOWING DOWN  

Mahmoud Fayed

unread,
Jul 8, 2021, 8:15:30 AM7/8/21
to The Ring Programming Language
Hello Bert

>> "Mahmoud should be able to confirm if this will fix the memory leak, and releasing memory before closing"

(1) When we close a Windows applications, The Operating System will free all of the memory allocated by this application
If you still see the memory allocated (Through the Task Manager) --> This means the application is not closed yet

if we have something like : oApp = new QApp
Then using oApp.Quit() will close the application

(2) With respect to Memory Management in Ring, We have two types of memory allocations

* Memory Allocated by Ring VM for Ring Normal Code (Strings, Numbers, Lists, Objects)
In this case, the memory will be deleted after the end of the function scope (if it's allocated in the local scope)
Or it will stay forever while the application is running until we delete it using assignment (if it's allocated in the global scope)

* Memory Allocated by Ring Extensions (Libraries like RingAllegro, RingRayLib, RingQt, etc.)
In this case, we have Three different situations

Number(1) : For some objects, the memory is managed by the library itself (automatically) - For example in RingQt - when we create a window widget (QWidget) then we create a QPushButton as a child of this widget, Qt will manage the memory of the QPushButton, and will delete it automatically when we close the window.

Number(2) : For some objects, we have functions that create the object, and other functions that delete this object, In this case we control when to delete the memory by calling the appropriate functions, for example in RingAllegro we have

al_load_bitmap(cFileName) ---> object (C Pointer)

al_destroy_bitmap(Object)

Number(3) : For some objects, the Ring Extension manage the memory automatically and delete the memory when the object is no longer used/available/accessible through Ring code

For example the next classes in RingQt are managed classes (Ring will delete the memory automatically when the objects go out of scope)
QFont
QIcon
QDir
QSize
QString2
QStringList
QKeysequence

Greetings,
Mahmoud

Mansour Ayouni

unread,
Jul 8, 2021, 8:32:54 AM7/8/21
to Mahmoud Fayed, The Ring Programming Language
A nice lesson!
Thanks Mahmoud.
Best,
Mansour

--

---
You received this message because you are subscribed to the Google Groups "The Ring Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ring-lang+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ring-lang/db7990d5-b2a6-457e-96d3-921f40199d9bn%40googlegroups.com.

Mahmoud Fayed

unread,
Jul 8, 2021, 10:26:54 AM7/8/21
to The Ring Programming Language
Hello Mansour

>> "A nice lesson! Thanks Mahmoud."

You are welcome :D

Greetings,
Mahmoud
Message has been deleted

عزالدين رمال

unread,
Jul 9, 2021, 11:37:12 PM7/9/21
to The Ring Programming Language
Hello Mahmoud
Thanks for the explanation
When i use   oApp.Quit()   the application close.
 but when I close it from the buton close (x) at the top right of the window, the window closes and the application remains running in the background

عزالدين رمال

unread,
Jul 11, 2021, 6:53:49 AM7/11/21
to The Ring Programming Language
Hello Mahmoud

Hello Mahmoud
I changed the repository to this new repository https://github.com/azzeddine2017/Chess3d-Qt3D

Mahmoud Fayed

unread,
Jul 11, 2021, 7:24:16 AM7/11/21
to The Ring Programming Language
Hello

>> "I changed the repository to this new repository"

Please update the (package.ring) file to avoid errors when installing/running the package

(1) Change
:run = "Qt3d_Chess.ring",

To

:run = "ring Qt3d_Chess.ring",

(2) Change
:name = "guilib.ring",

To

:name = "ringqt",

(3) Change
:name = "stdlibCore.ring",

To

:name = "stdlib",

Greetings,
Mahmoud

عزالدين رمال

unread,
Jul 11, 2021, 9:43:11 AM7/11/21
to The Ring Programming Language
  Hello Mahmoud

Please update the (package.ring) file to avoid errors when installing/running the package
Done  thanks

عزالدين رمال

unread,
Jul 11, 2021, 11:29:37 AM7/11/21
to The Ring Programming Language
Hello Mahmoud
Possible moves have been added
screenshot_11_07_2021_15_15_47.png
screenshot_11_07_2021_16_15_50.png

Bert Mariani

unread,
Jul 11, 2021, 6:00:27 PM7/11/21
to The Ring Programming Language
Hello Ezzeddine

Nice partitioning of the code into separate modules. Makes it easier to follow !

Observation:
These message show up the the start of the program --- Texture will be invalid for this frame
Then the second set of message are forever repeated --- Unable to find suitable Texture Unit

I think this has to be fixed.
It is probably interfering with the performance of the program.


========================

[Qt3DRender::GLTexture] No QTextureData generated from Texture Generator yet. Texture will be invalid for this frame
[Qt3DRender::GLTexture] No QTextureData generated from Texture Generator yet. Texture will be invalid for this frame
[Qt3DRender::GLTexture] No QTextureData generated from Texture Generator yet. Texture will be invalid for this frame

----------------------------

Qt3D.Renderer.OpenGL.Backend: Unable to find suitable Texture Unit
Qt3D.Renderer.OpenGL.Backend: Unable to find suitable Texture Unit
Qt3D.Renderer.OpenGL.Backend: Unable to find suitable Texture Unit
Qt3D.Renderer.OpenGL.Backend: Unable to find suitable Texture Unit
Qt3D.Renderer.OpenGL.Backend: Unable to find suitable Texture Unit
Qt3D.Renderer.OpenGL.Backend: Unable to find suitable Texture Unit

Bert Mariani

unread,
Jul 11, 2021, 6:02:56 PM7/11/21
to The Ring Programming Language
It is also easier to play and view from the perspective of your 2nd screen shot that is tilted at 30 degrees.
Rather than the view sitting right behind the pieces.

عزالدين رمال

unread,
Jul 11, 2021, 10:24:18 PM7/11/21
to The Ring Programming Language
Hi Bert
Nice partitioning of the code into separate modules. Makes it easier to follow !
Thanks. You can contribute if you want to suggest something
Observation:
I think this has to be fixed.
It is probably interfering with the performance of the program.

It is a logical error in the process of hiding the bulletin board
chess.png
      At the beginning of the game
I called the pad without Texture , and as soon as the mouse focus moved to the screen, the pad appeared and the game started, but the ad was still under the pad and in memory
To fix the error I will raise the level of the bulletin board and when the focus shifts to the screen I will destroy it
I only need it once at first

It is also easier to play and view from the perspective of your 2nd screen shot that is tilted at 30 degrees.
Rather than the view sitting right behind the pieces.


To control the position of the camera in relation to the panel, press the right mouse button in the center of the panel to change the mode
Then you choose the movement. With the keyboard arrows, you can rotate the camera left and right, and let the player freely choose the viewing angle

Mahmoud Fayed

unread,
Jul 12, 2021, 11:05:58 AM7/12/21
to The Ring Programming Language
Hello Ezzeddine

Some comments

(1) Remove the image/photo of the chess players in the start of the game (Usage of Magnus Carlsen photo  and other chess players needs a permission - They sell these things, so don't use it)

(2) The Rules of the game needs revision, when I play at some point it says (Check) and prevent me from playing, while no Check exist, this happens when when you start playing, move pieces, eat some of them, etc.

(3) It will be nice to set Bert suggestion as the default "easier to play and view from the perspective of your 2nd screen shot that is tilted at 30 degrees"

Greetings,
Mahmoud

عزالدين رمال

unread,
Jul 12, 2021, 12:29:49 PM7/12/21
to The Ring Programming Language
hello Mahmoud

(1) Remove the image/photo of the chess players in the start of the game (Usage of Magnus Carlsen photo  and other chess players needs a permission - They sell these things, so don't use it)

I deleted it ,I thought that intellectual rights were required if the use was commercial

(2) The Rules of the game needs revision, when I play at some point it says (Check) and prevent me from playing, while no Check exist, this happens when when you start playing, move pieces, eat some of them, etc.

I'm working on fixing it

(3) It will be nice to set Bert suggestion as the default "easier to play and view from the perspective of your 2nd screen shot that is tilted at 30 degrees"

Adjusted to the desired angle 30 degrees

Bert Mariani

unread,
Jul 12, 2021, 5:44:51 PM7/12/21
to The Ring Programming Language
Hello Ezzedine

2 Observations

First: The rotating World picture --- The continents are reversed
Africa.png

Second:
By 30 Degrees,  I mean ---- White pieces on the Left. The Board slight tilt up on the Left

W30degrees.png

عزالدين رمال

unread,
Jul 12, 2021, 8:41:19 PM7/12/21
to The Ring Programming Language

Hello Bert

First: The rotating World picture --- The continents are reversed

This is because the texture loader displays the images in reverse
It must be given to him in reverse to display it correctly
Example:
chess1.png

I plan to cancel the planets and stars to reduce memory consumption, the view of space_skybox is enough


Second:
By 30 Degrees,  I mean ---- White pieces on the Left. The Board slight tilt up on the Left

The side view was from my suggestion and you told me in this post

So I changed it to what you suggested

Now I will take it back to the side By 30 Degrees
I will change the position of the text3d so that it is always opposite the camera
I have put three colors for the sky box, blue, red and light blue, which one best suits the background ?


عزالدين رمال

unread,
Jul 12, 2021, 10:36:21 PM7/12/21
to The Ring Programming Language
screenshot_13_07_2021_03_28_38.png

Hi Bert
Does this look good

Bert Mariani

unread,
Jul 13, 2021, 11:36:22 AM7/13/21
to The Ring Programming Language

Sorry Ezzeddine,
I messed up the Left and Right  words

Use the picture I sent.  
White on the  Right  -->
Black on the Left  <---

عزالدين رمال

unread,
Jul 14, 2021, 8:28:56 AM7/14/21
to The Ring Programming Language
Hi Bert
I think it is so excellent
screenshot_14_07_2021_13_20_53.png

Mahmoud Fayed

unread,
Jul 17, 2021, 10:05:53 AM7/17/21
to The Ring Programming Language
Hello Ezzedine

What to do/press in the application to get the possible moves in a special color as in your screen shot

This one
v1.png

Greetings,
Mahmoud

عزالدين رمال

unread,
Jul 17, 2021, 11:24:39 AM7/17/21
to The Ring Programming Language
Hello Mahmoud

I'm checking in the update function that the selected board is
  Among the possible movements with a function validMove(.....)
If the condition is met
It will change the texture of the board to a green image that you have modified in Photoshop

 if selectionI > 0 and selectionJ > 0

          if validMove(board, selectionI, selectionJ, i, j, turn)

                      aTile[i][j][:oLoader].setSource(new QUrl("file:///"+currentdir()+"/textures/valid.png") )

        ok

ok

عزالدين رمال

unread,
Jul 17, 2021, 5:41:32 PM7/17/21
to The Ring Programming Language
Hello Mahmoud
I don't seem to understand your question, sorry
  When I downloaded the game through the package manager it did not load the image --valid.png
  This image is placed in the textures file, which is why it does not appear in the game
valid.png

عزالدين رمال

unread,
Jul 17, 2021, 5:52:41 PM7/17/21
to The Ring Programming Language
Hello Mahmoud
What is the alternative available in the ring for a topic?
Qt Signals and Slots Work.
How Qt Signals and Slots Work

Mahmoud Fayed

unread,
Jul 18, 2021, 10:46:58 AM7/18/21
to The Ring Programming Language
Hello Ezzedine

>> "What is the alternative available in the ring for a topic?
Qt Signals and Slots Work."

We provide methods in each class to set the event function (As a simple replacement for Signals/slots)

Like setClickEvent() method in QPushButton

Greetings,
Mahmoud

Mahmoud Fayed

unread,
Jul 18, 2021, 11:03:08 AM7/18/21
to The Ring Programming Language
Hello Ezzedine

>> "When I downloaded the game through the package manager it did not load the image --valid.png
  This image is placed in the textures file, which is why it does not appear in the game"

Please update the package file (package.ring)

(1) Change valid.jpg to valid.png in this line : https://github.com/azzeddine2017/Chess3d-Qt3D/blob/main/package.ring#L77

(2) When you update the code - Update the package version : https://github.com/azzeddine2017/Chess3d-Qt3D/blob/main/package.ring#L12

For example change (1.0.0) to (1.0.1)

So we can update the package using : ringpm update Chess3d-Qt3D
instead of using : ringpm remove Chess3d-Qt3D
then ringpm install Chess3d-Qt3D

Greetings,
Mahmoud

عزالدين رمال

unread,
Jul 18, 2021, 11:52:42 AM7/18/21
to The Ring Programming Language
Hello Mahmoud

(1) Change valid.jpg to valid.png in this line
Thank you, I was not aware of this, 

(2) When you update the code - Update the package version

 do you have to change the version even if the change is simple

Mahmoud Fayed

unread,
Jul 19, 2021, 9:00:29 PM7/19/21
to The Ring Programming Language
Hello Ezzedine

>> "Do you have to change this line as well?"

Yes, it must be changed too

>> "do you have to change the version even if the change is simple"

Yes, just increment the patch number (third number in the version)
1.0.0  = Major.Minor.Patch

You can read about semantic versioning here : https://semver.org/

Greetings,
Mahmoud

عزالدين رمال

unread,
Jul 26, 2021, 8:20:13 AM7/26/21
to The Ring Programming Language
Hello Mahmoud

The error in the rules of the game has been fixed
A distinction has been added in the possible movements between enemy and friend
Next development I want to add a window to start and play the game online via tcp - socket
screenshot_11.png
The cause of memory consumption was also discovered
It was caused by the use of a very large image of the black pieces

عزالدين رمال

unread,
Jul 26, 2021, 11:34:54 AM7/26/21
to The Ring Programming Language
screenshot_26_07_2021_12_39_41.png

Mahmoud Fayed

unread,
Jul 26, 2021, 11:52:30 AM7/26/21
to The Ring Programming Language
Hello Azzeddine

>> "The error in the rules of the game has been fixed"

Thanks for the update, I will do more testing

In the next screen shot, I can't move the White Knight that exist on the right
When I select it (I can select it) - No possible moves exist!
So please revise the Knight rules

Also the game doesn't support the Castle
For now, if you added the (Castle) this will be very nice (and important for a real game play)

castle.png

The point is to support moving the King two steps to the left and the rock to be on the right of the king

Or to move the king three steps to the right, and the rock to be on the left of the king


nice.png

Greetings,
Mahmoud

عزالدين رمال

unread,
Jul 26, 2021, 3:26:47 PM7/26/21
to The Ring Programming Language
Hello Mahmoud

In the following screenshot, I can't move the white knight on the right
When I select it (I can select it) - no motions are possible!
So please check Knight . rules

Because one of the conditions for possible movements is that the piece does not leave its place so that its king will be killed
If the knight in the previous picture was in a place that could influence the black Bishop, the only possible move would have been to kill the black Bishop
In my opinion, the rules are good

Also the game doesn't support the Castle
For now, if you added the (Castle) this will be very nice (and important for a real game play)

 I will work on it 

I need some help on how to send an QByteArray via QTcpSocket

Bert Mariani

unread,
Jul 26, 2021, 6:34:08 PM7/26/21
to The Ring Programming Language
Hello Ezzeddine

The Pawn also has a special  En-Passant  rule that captures a passing pawn that make a 2 square move.

عزالدين رمال

unread,
Jul 27, 2021, 1:59:15 PM7/27/21
to The Ring Programming Language
Hello Bert
Thank you for the information, I will work on it

عزالدين رمال

unread,
Jul 28, 2021, 12:02:31 PM7/28/21
to The Ring Programming Language
Hello Mahmoud
The castle has added to this commit add Castle King
And they started working on En-Passant rule

Mahmoud Fayed

unread,
Jul 28, 2021, 7:33:55 PM7/28/21
to The Ring Programming Language
Hello Azzeddine

>> "The castle has added to this commit add Castle King"

Thanks for the update, Very nice :D

>> "started working on En-Passant rule"

Very nice, after finishing the En-Passan rule, it will be nice to add the Pawn promotion to Queen|Rock|Knight|Bishop (When it reach the last row)

For example, In the next screen shot we have a White Pawn that reach the end of his way and deserve a nice promotion


promotion.png

Greetings,
Mahmoud

عزالدين رمال

unread,
Jul 29, 2021, 4:44:15 AM7/29/21
to The Ring Programming Language
Hello Mahmoud and Bert and all
  I have added capture En-Passan in this commit add En-Passant

عزالدين رمال

unread,
Jul 29, 2021, 5:51:34 PM7/29/21
to The Ring Programming Language
Hello Mahmoud and all
The pawn  promotion  has been added when it reaches the end of the path
screenshot_29_07_2021_18_27_15.png
screenshot_29_07_2021_19_06_46.pngscreenshot_29_07_2021_19_07_03.pngscreenshot_29_07_2021_19_07_14.png

عزالدين رمال

unread,
Jul 29, 2021, 6:41:59 PM7/29/21
to The Ring Programming Language
hello
Changes have been made to the following commitments
Some photos have also been deleted and some photos have been added

Bert Mariani

unread,
Jul 30, 2021, 6:39:10 PM7/30/21
to The Ring Programming Language
Hello Ezzeddine

Tested:
 Castle - King Rook  side  = ok
 En-Passant capture = ok
 Pawn promotion to Queen  =  ok

Well Done !!!

After a while I get tired of seeing the rotating board after each move.
Is is possible to have the option to let the board stay in a fixed position ?

عزالدين رمال

unread,
Jul 30, 2021, 7:34:57 PM7/30/21
to The Ring Programming Language
Hello Bert

Tested:
 Castle - King Rook  side  = ok
 En-Passant capture = ok
 Pawn promotion to Queen  =  ok

Well Done !!!
Thanks for your support and testing

After a while I get tired of seeing the rotating board after each move.
Is is possible to have the option to let the board stay in a fixed position ?
As for the rotation process, what do you think if we make it in the keyboard arrows

Bert Mariani

unread,
Jul 31, 2021, 2:18:34 PM7/31/21
to The Ring Programming Language

Hello Ezzeddine

Yes, you could have the User use the Arrow Keys if he wants to rotate the board, 
or just leave the board in place.

I play faster than the time it takes the board to rotate, so I would leave the board in place.
I would rotate it when I prefer to play as the Black Player

Mahmoud Fayed

unread,
Aug 2, 2021, 5:10:02 PM8/2/21
to The Ring Programming Language
Hello Ezzedine

Very nice updates :D

It will be nice to add a Menu with some options like
(1) (Enable/Disable Rotation) as suggested by Bert
(2) Restart the Game to put each piece in it's original position

Keep up the GREAT WORK :D

Greetings,
Mahmoud

عزالدين رمال

unread,
Aug 14, 2021, 3:58:06 PM8/14/21
to The Ring Programming Language
screenshot_14_08_2021_16_53_55.pngscreenshot_14_08_2021_16_54_53.png

عزالدين رمال

unread,
Aug 14, 2021, 6:33:53 PM8/14/21
to The Ring Programming Language
Hello Mahmoud and everyone

I made some changes to the game
The first image of the window has options:
1 Playing with a human or a friend
2 Playing online - temporarily I'll make it peer to peer
3 Playing with the machine - I used the Minimax algorithm with trees
The code still has bugs, I will upload it, when it is cleared of bugs

عزالدين رمال

unread,
Aug 14, 2021, 7:43:15 PM8/14/21
to The Ring Programming Language

Load "Chessboard.ring"


class MinimaxTree


Aiboard

TreeChildren = []

TreeChild = self

//---------------------------

func init(Chboard)


Aiboard = Chboard

//----------------------------------

func DistroyList(alist)


for item in alist

item= null

next

//----------------------------------

func IsImptyList(alist)


for item in alist

if isobject(item) != null

return false

ok

next

return true

//------------------------------

func MakeMove( move)

newTree =null

for TreeChild in TreeChildren

thisMove = TreeChild.Aiboard.getLastMove()

// if this is the move we're making, reuse the subtree

if thisMove = move

newTree = TreeChild

else

TreeChild = null

ok

next

if newTree != NULL

?newTree

Aiboard = newTree.Aiboard

TreeChildren = newTree.TreeChildren

DistroyList(newTree.TreeChildren)

newTree =null

else

Aiboard.MackeMove(move)

ok

//--------------------------------------------------

func getBestMove( isTurnAI , depth)

MakeChildren(isTurnAI)

maxAdvantage = -1000000

BestMove = new Move

for TreeChild in TreeChildren

Advantage = TreeChild.minimax(isTurnAI, !isTurnAI, depth)

if Advantage > maxAdvantage

maxAdvantage = Advantage

BestMove = TreeChild.Aiboard.getLastMove()

ok

next

return BestMove

//-------------------------------------------------------

func minimax( isTurnAI, toMove, steps)

// no more steps

if steps <= 0

return Aiboard.getAdvantage(isTurnAI)

ok

MakeChildren(toMove)

result = 0

//------ opponent to move, so minimize

if toMove ^ isTurnAI

result = 1000000

for TreeChild in TreeChildren

Advantage = TreeChild.minimax(isTurnAI, !toMove, steps - 1)

if Advantage < result result = Advantage ok

next

//------ player to move, so maximize

else

result = -1000000

for TreeChild in TreeChildren

Advantage = TreeChild.minimax(isTurnAI, !toMove, steps - 1)

if Advantage > result result = Advantage ok

next

ok

return result

//------------------------------------

func MakeChildren(isTurnAI)

? "IsImptyList :"+IsImptyList(TreeChildren)+":" +len(TreeChildren)

//---- only run if nothing has been added to list

if IsImptyList(TreeChildren)

for LegalMove in Aiboard.getLegalMove(isTurnAI)

Tree = new MinimaxTree(Aiboard)

Tree.makeMove(LegalMove)

TreeChildren + Tree

next

ok

? "len TreeChildren 2 :"+len(TreeChildren)

عزالدين رمال

unread,
Aug 14, 2021, 8:08:04 PM8/14/21
to The Ring Programming Language

Hello Mahmoud

  I had asked you how to send a list or attribute of an object I just developed a little function  List2Code

We can now put the attributes of an object in a list

Convert it to string and then send it when it is received Execute it in memory using the eval function


//--------------------------

func ListToCode(aList)

cCode ="["

lStart = True

for item in aList

if !lStart cCode += "," +Windowsnl() else lStart = False ok

if isString(item) cCode += char(39)+ item +char(39)

but isnumber(item) cCode += ""+item

but islist(item) cCode += ListToCode(item)

but isobject(item)

aAttribut = attributes(item)

cCode += '['

lStart = True

for attribut in aAttribut

if !lStart cCode += "," else lStart = False ok

value = getattribute(item,attribut)

cCode +=':'+ attribut + '='

if isString(value)

cCode += '"' + value + '"'

but isNumber(value)

cCode += value

but isList(value)

cCode += ListToCode(value)

but isobject(value)

cCode += ListToCode(value)

ok

next

cCode += " ]"

ok

next

cCode += "]"+Windowsnl()

return cCode

//-------------------------

func writeMessage(cStr)

Message ="aCommand="

Message += cStr

if networkMode

oClient.sendMessage(Message)

else

oServer.sendMessage(Message)

ok

Mahmoud Fayed

unread,
Aug 14, 2021, 9:37:18 PM8/14/21
to The Ring Programming Language
Hello Azzeddine

>> "I just developed a little function  List2Code"

Thanks for sharing :D

Note: We added Chess3D-Qt3D to Ring Website (News Section), Also an information about the package are added to documentation (What is new in Ring 1.15?)

Keep up the GREAT WORK :D

Greetings,
Mahmoud

عزالدين رمال

unread,
Aug 16, 2021, 12:36:59 PM8/16/21
to The Ring Programming Language

Hello Mahmoud 

Note: We added Chess3D-Qt3D to Ring Website (News Section), Also an information about the package are added to documentation (What is new in Ring 1.15?)


Thank you very much for the good presentation
I feel like I'm part of your team, I hope I can improve my ranking in the future
By the way, I encountered a random selection between strings values and I did not find any function for this in the documentation
I hope someone can benefit from this function

alist = "a" : "z"

alist2 = 0 : 1

alist3 = [4 ,8 , "a" , "z" ,"A" , "Z",10 , 100]

? RandomList(alist)

? RandomList(alist2)

? RandomList(alist3)


//------------------------------------

func RandomList(aInput)

alist = aInput

aOutput = null

while len(alist) > 1

nIndex = random(len(alist)-1)

nIndex++

aOutput = alist[nIndex]

del(alist,nIndex)

end

return aOutput

Mahmoud Fayed

unread,
Aug 16, 2021, 8:30:13 PM8/16/21
to The Ring Programming Language
Hello Azzeddine

The RandomList() function is used in the next applications




And more!

This is  a mistake!  - It will be added to StdLib (functions) in Ring 1.15 - And all of these applications will be updated to use it and avoid code duplication

Greetings,
Mahmoud

عزالدين رمال

unread,
Aug 16, 2021, 11:08:45 PM8/16/21
to The Ring Programming Language
Hello Mahmoud
If you check the observation of the described functions, you will find that their output is a list, meaning that it randomly mixes the order
I am talking about choosing from the list one element at random and the output of the function is from the origin of the type of the list elements, either numbers or strings...
Greetings,
Azzeddine

Mahmoud Fayed

unread,
Aug 17, 2021, 4:12:19 AM8/17/21
to The Ring Programming Language
Hello Ezzeddine

>> "I am talking about choosing from the list one element at random"

Very nice, Could you rename it to RandomItem() instead of RandomList()

Also using a simple implementation

aList = 1:5
? RandomItem(aList)
func RandomItem aList
    if ! isList(aList) raise("Error: The function expect a list!") return ok
    if len(aList) <= 0  raise("Error: No items in the list") return ok
    return aList[ random( len(aList) - 1 ) + 1 ]

Greetings,
Mahmoud

عزالدين رمال

unread,
Sep 6, 2021, 7:42:56 PM9/6/21
to The Ring Programming Language

Hello Mahmoud Bert and all
I tried to add features like playing against the machine
Playing via socket but it is unstable
I re-split the code and added folders
The code is in this repository

Bert Mariani

unread,
Sep 6, 2021, 8:22:33 PM9/6/21
to The Ring Programming Language

Hello Ezzedine

RE: --- We can install it using the Ring Package Manager

       --- ringpm install Chess3D-Qt3D    ,      ringpm run Chess3D-Qt3D


c:\ring\bin>ringpm install Chess3D-Qt3D
Installing Chess3D-Qt3D (master)
Error(10): Package doesn't exist

If I download from Github  as a Zip File,  
Which file to I click on to start the game.  ( ChessBosrd.ring  --- Not running for me ) 

عزالدين رمال

unread,
Sep 6, 2021, 11:24:51 PM9/6/21
to The Ring Programming Language

Hi Bert
to install : ringpm install Chess3D-Qt3D from Azzeddine2017
to run : main.ring

Bert Mariani

unread,
Sep 7, 2021, 9:35:01 AM9/7/21
to The Ring Programming Language
Hello Azzedine


Could not create pixmap from C:\ring\game engine\qt_3d_chess\Qt3d_chess_core\textures\SpaceLightblue.png
Could not create pixmap from C:\ring\game engine\qt_3d_chess\Qt3d_chess_core\textures\SpaceLightblue.png
Could not create pixmap from C:\ring\game engine\qt_3d_chess\Qt3d_chess_core\textures\SpaceLightblue.png
Could not create pixmap from C:\ring\game engine\qt_3d_chess\Qt3d_chess_core\textures\SpaceLightblue.png

Line 14547 Bad parameter type!
In qmainwindow_addtoolbar_2() In method addtoolbar_2() in file C:\ring\libraries\guilib\classes/ring_qt.ring
called from line 16  In function open_window() in file C:\ring\libraries\objectslib\objects.ring
called from line 25  In function openwindow() in file C:\ring\libraries\objectslib\objects.ring
called from line 10  In function main() in file C:/MyStuff/Chess-3D/Chess3d-Qt3D-main/main.ring
called from line 5  in file C:/MyStuff/Chess-3D/Chess3d-Qt3D-main/main.ring



عزالدين رمال

unread,
Sep 9, 2021, 6:22:11 AM9/9/21
to The Ring Programming Language
Hello bert

II fixed the first mistake in these lines
As for the camera rotation, it's so slow that you won't even feel the movement
I think it is a compromise
I have a problem that I could not solve, which is when playing a set of moves, the game stops without any error and I cannot determine the reason
I tried to use an algorithm MinMax in the game, but it gives wrong results, so I just wrote a simple function based on filtering movements
As for playing online, I could not test it on my weak device, it could not open the game twice at the same time
I hope you will read the code and help me with the correction

عزالدين رمال

unread,
Sep 9, 2021, 6:13:23 PM9/9/21
to The Ring Programming Language
Hello bert

I have a problem that I could not solve, which is when playing a set of moves, the game stops without any error and I cannot determine the reason
I fixed the error

عزالدين رمال

unread,
Sep 10, 2021, 9:48:08 AM9/10/21
to The Ring Programming Language
Hi Bert
I started experimenting with online gamingscreenshot_10_09_2021_14_38_34.png

Mahmoud Fayed

unread,
Sep 11, 2021, 5:15:42 AM9/11/21
to The Ring Programming Language
Hello Azzedine

>> " I fixed the error"

Very nice, this what happens during programming sessions and problem solving, Continue :D

>> "I started experimenting with online gaming"

This will be GREAT :D

For now, I copied your previous work to this package : https://github.com/ringpackages/Chess3D-Qt3D
As a stable version that we talked about in (Ring 1.15 documentation)
So this command :  ringpm install Chess3D-Qt3D
Will install the old version

While this command : ringpm install Chess3D-Qt3D from azzeddine2017
will install the new version (under development)

Keep up the GREAT WORK :D

Greetings,
Mahmoud



عزالدين رمال

unread,
Sep 11, 2021, 5:55:18 AM9/11/21
to The Ring Programming Language
Hello Mahmoud
  I was thinking about how to solve the package manager problem where the old command ( ringpm install Chess3D-Qt3D ) is not working great solution
  Thank you so much

Mahmoud Fayed

unread,
Sep 11, 2021, 6:41:31 AM9/11/21
to The Ring Programming Language
Hello Azzedine

>> "I was thinking about how to solve the package manager problem where the old command ( ringpm install Chess3D-Qt3D ) is not working great solution"

You are welcome :D

Greetings,
Mahmoud

Reply all
Reply to author
Forward
0 new messages