Ludii Forum
store precalculated data - Printable Version

+- Ludii Forum (https://ludii.games/forums)
+-- Forum: Questions (https://ludii.games/forums/forumdisplay.php?fid=13)
+--- Forum: About the Ludii Grammar (https://ludii.games/forums/forumdisplay.php?fid=15)
+--- Thread: store precalculated data (/showthread.php?tid=1014)

Pages: 1 2


store precalculated data - noobby - 06-14-2022

To save the run-time of very complex calculations (in each move!) :


#1)  Is there an official way (or trick, see#2)  to store pre-calculated  DATA  (in arrays or something) ?

#2)  Is it possible to have a HIDDEN Board ?   (could store info nicely)

and:
#3)  Can the distance between stacked pieces be (slightly) reduced ?


RE: store precalculated data - Michael - 06-14-2022

(06-14-2022, 12:15 PM)noobby Wrote: #3)  Can the distance between stacked pieces be (slightly) reduced ?

The stackType ludeme has a float-paramterer for scaling the distance between the pieces. E.g.:
Code:
(stackType Default 0.8)



RE: store precalculated data - Eric Piette - 06-14-2022

To hide the board, you can use

(no Board)

In the graphics metadata. See Rock-Paper-Scissors for an example.

----

For the question about pre-computed, I am not sure exactly what you mean.
If you mean to compute a data once in the beginning of the legal moves and then compute them, the short answer is not in the description, but our code will detect automatically if this ludeme can be pre-computed (so not dependent of dynamic variables like (to), (from), (level) etc...)). So even if you call many times the same computation of a ludeme which could be pre-computed, Ludii will compute it only once.


RE: store precalculated data - noobby - 06-14-2022

Thanks a lot for both answers!
Now I understand, how to use 'pieceStackType'!, makes sense.

ad precomputed data: sorry that I didn't describe it more carefully, one word would have made it more clear, like:  additional  hidden board. (not possible, i guess.)  

A cleaner way to store some precomputed data would be if I simply could put a named array in the equipment  section! 
I would like that feature a lot, like with region. easy and direct access.
But my tries in this direction didn't work.

And I also did some tests with calculations in a (do ..calculate..  next:  moves... ) construction before a player makes the first move. 
(maybe do..next isn't meant for this, i realize now.)

But it was interresting: a dice-roll in the (do.. ) was executed and shown on the board immediately, but setting a variable or make a note (even before the roll, with the new seq{}) was not done before the game.
So i found no way to compute something before the first move happens.


RE: store precalculated data - Eric Piette - 06-15-2022

Hi,

I understood "hidden board" (if you mean graphically), but I am not sure what you mean by "additional hidden board".
Do you mean like 2 boards, e.g. a board in which we can see the board and another which is hidden and of course no connection between these boards? If this is what you mean, yes, you can do that (I believe). I would just colour all the cells, vertices and edges in white, and your board should be hidden.

I think by "pre-computed" data with this array, you could use a bunch of (define ...) to describe each of these values. Easy to call them and if they can be pre-computed, Ludii will compute them only once.

For the (do ...), whatever moves you put in the first part, they will be done (and computed) before to compute the real legal moves available to the player. For the dice, that's just a special case in which the GUI is printed their values before the move is really played (that's just a GUI feature, not a logic feature).

Could you give me an example of a game description of what you expect to do (even if you use ludemes which are not existing (but please explain them :)).

Eric


RE: store precalculated data - noobby - 06-15-2022

ok, so the additional hidden board would just be used as an internal logical structure, which is in no way visible in the GUI, because there's the real board where some action might happen. in short, it would be only a surrogate to store a 3D array (with two input variables x,y i.e.'the hidden board') of precalculated lists (= the z-dimension, values stored as piece-values of hidden stacks placed in the hidden board).
I know this sounds intricately, but it would be some sort of workaround for not having a 3D-array at hand.
 in ludii syntax, it would look like this, maybe:

(arrayValue (array "DataCube") index_x:12 index_y:17)  ->  {1,2,7, ... ,21,24} (the z-collumn), 
which then would need some {..} -> [..] trick to get a region out of it.. ^_^

Named arrays (like regions, and maps!) would be very powerful if they could be put in the equipment, I think. As for the example I dont have a real game descripton yet, just testing and learning the ludii-language. And because my reasoning is used to & seems to be so fixated to arrays, I'm having a hard time with it of course. 
But since I have a few weeks now until the stack:true movement is fixed, I have time to better understand the ludii-language and find out how to encode all the ideas I will have with the existing ludemes.


RE: store precalculated data - Michael - 06-15-2022

Can't you use a bunch of maps? The colums of the matrix are maps called "0", "1", "2", and so on. And the keys of the maps are the row indices. To get a column by index use something like (define "ToString" "#1").


RE: store precalculated data - noobby - 06-16-2022

oh, a self created ToString-function, actually. I didn't think of that yet.
Wouldn't this be some sort of meta-programming i.e. dynamically encoding string-like ludii keywords/defines?
And the result could also be 'stringed' which allows iterative mapping.
This should then also work with regions, right? I have to investigate this..


RE: store precalculated data - noobby - 06-17-2022

There must have been a big misunderstanding (on my side), when I was asking in the first post of this thread if there was a way ".. to store pre-calculated DATA (in arrays or something) ? "
That happened because at the very start of my encounter with ludii I tested some things regarding arrays, and it didn't work.
But that probably was only because i had no experience at all with the syntax or just had a typo in it..
Because now I found:  (define "Data" (array {0 1 2 3 4 5 6 7 8 9  ..  }) )   and then later  (arrayValue "Data" index: 123))   does indeed work pretty fine!
so nothing more needed here (bc even 3D arrays with known dimensions can easily be encoded in a 1D array), except:  
What's the MAX_ARRAY_SIZE ?  ('Integer.MAX_VALUE' on Java, i hope ; )


RE: store precalculated data - Michael - 06-17-2022

Oh, I didn't know about the (arrayValue) ludeme. Nice!

Related maybe-fact: I think I read somewhere that there is no guarantee that the values in (values Remembered) are stored in the order in which they are remembered. (Could this be right?)