Slow display of game board in Othello

Want to move your code and projects to LiveCode but don't know where to start?

Moderators: FourthWorld, heatherlaine, Klaus, robinmiller

Post Reply
KRY_M
Posts: 14
Joined: Sat May 04, 2019 3:43 pm

Slow display of game board in Othello

Post by KRY_M » Wed Nov 27, 2019 10:33 pm

Hello, I have another problem with the application speed. It redraws my board very slowly, I can see some circles redrawn when i make a move. I tried and optimized as best I could, but I don't know witch part is the slowest to fix it. The game is uploaded on Livecodeshare=runrev=com and it is caled Othello. I can't work on the computer logic because it is already too slow to use. The exe file is slow too. Can anybody confirm that is slow on their PC ?
Thank you.
Passionate developer :D

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Slow display of game board in Othello

Post by bogs » Wed Nov 27, 2019 10:38 pm

I haven't tried the program, but am curious if you used 'lock screen' or not in the code. If not, it can dramatically improve the speed at which boards get redrawn, since it is not allowing the screen to be updated until the 'unlock screen' shows up.
Image

Klaus
Posts: 13793
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Slow display of game board in Othello

Post by Klaus » Wed Nov 27, 2019 10:50 pm

Hi Kry,

I added a lock screen and it looked way better!
After a quick look, in the card script in handler "play_g" just add these marked lines:

Code: Select all

command play_g  x,y //the core of the game
   local lturn
   //we need current turn to test for valid moves
   if gTurn is "h" then put 1 into lturn else put 2 into lturn
   
   ## This one:
   lock screen
   //if it empty space then test it for valid move
   if a[x][y] = 0  and ValidMove (x,y,lturn ) = 1 then     
      MutaPiesa x,y,lturn                                    //move if it is a valid move only
      ChangeTurn
      afis  //redraw board

      ## and this one:
      unlock screen
   else
      answer "Wrong move !"
   end if
end play_g
Please try and tell us if that works for you.


Best

Klaus

KRY_M
Posts: 14
Joined: Sat May 04, 2019 3:43 pm

Re: Slow display of game board in Othello

Post by KRY_M » Thu Nov 28, 2019 9:58 pm

Thank you !
It is very fast now in displaying the board, I should remember this trick.
I am working on making this app more interesting by making the PC to think and move against humans :) not so easy that I believed ..
Passionate developer :D

Post Reply

Return to “Converting to LiveCode”