Author Topic: [Axe] Tableau dynamique  (Read 11609 times)

0 Members and 1 Guest are viewing this topic.

Offline Jagang

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 10
  • Rating: +0/-0
    • View Profile
[Axe] Tableau dynamique
« on: October 23, 2010, 04:42:34 pm »
(Re) bonjour,
J'ai de nouveau un problème pour mon jeu Mario Sokoban
Je charge mes cartes dans des GBD comme ceci :
Code: [Select]
Data(0,1,1,1,1,0,0,0,1,1,0,0,1,1,1,1,1,0,0,0,0,0,0,1,1,0,3,3,1,2,0,1,1,1,1,0,0,2,0,1,0,0,1,1,1,0,0,1,0,0,0,0,1,1,1,1)->GBD1Étant donné qu'il y a plusieurs cartes, j'ai utilisé des condition, comma ça :
Code: [Select]
If L=1
    Data(...)->GBD1
End
If L=2
    Data(...)->GBD1
End
etc ...
Le problème, c'est que quand je lance la compilation, ça marche pas ...
Je ne peux pas utiliser un GBD par map puisque j'ai plus de 10 maps ...
Dans la version TI-Basic de mon programme, à chaque nouveau niveau, j'allais changer la valeur de la matrice [A].
En Axe, je pensais que c'était pareil ... dommage
Comment faire alors ?

Merci d'avance
Cordialement
Jagang

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: [Axe] Tableau dynamique
« Reply #1 on: October 24, 2010, 11:06:53 am »
I don't speak French, but using Google Translate I can tell that you seem to be misunderstanding how "->GDB1" works.
(DJ or another French speaker, please translate my response.)
GDB1 etc. are not dynamic like in BASIC. Instead, when you use "->" with them, the data you store to them is placed in the compiled program. To use it like you would in BASIC, you have to use L1 or another place to store your data. However, this does bring up another problem; you still have to store the original data somewhere. You can use one GDB for each map, and you can add another digit to each. (You can use GDB10, GDB56, and so on, and maybe even another, like GDB623. However, I'm not sure about two extra digits.)
Another solution exists, though. If each set of data is the same size, rather than using GDB01 to access the first, GDB02 for the second, and so on, you can use GDB1 for the first, GDB1+56 for the second, GDB1+112 for the third, and so on, storing them like in the code box below. (assuming each set map is 56 bytes) (If you are using it with L like you were above, you could actually just use L-1*56+GDB1 to access the L'th set of data, indexed from 1.)
Code: [Select]
Data(...)->GDB1
.Data for map 1
Data(...)
.Data for map 2
Data(...)
.Data for map 3
.And so on
Thinking over it, I've realized that, if you're using maps, they are static and their content does not change. This means that you won't have to use L1 for that purpose. Rather, you can have a line like
Code: [Select]
L-1*56+GDB1->MM now contains the address of the map data, and you can index from there. If, however, you would rather use L1 (perhaps for convenience?) you would have to copy the data to L1 like so: (You can use any free RAM area, not just L1)
Code: [Select]
Copy(L-1*56+GDB1,L1,56Feel free to ask more if you are still confused; I doubt I've clarified everything.
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline Jagang

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 10
  • Rating: +0/-0
    • View Profile
Re: [Axe] Tableau dynamique
« Reply #2 on: October 25, 2010, 05:39:30 am »
Thank you, but, my maps are dynamics...
So, how load my maps in L1 ?
Code: [Select]
Data(0,2,2,2,3,1,4,1,..)->L1 ?
Because, I need the same pointer/variable in the main program (where I test if an action is possible).

Sorry, I don't speak English very well (though I should), but it's always better than Google  Translate (I think ...)

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: [Axe] Tableau dynamique
« Reply #3 on: October 25, 2010, 09:56:54 am »
Okay. My suggestion was that, instead of, say, L1+5 you use M+5, where M is the pointer to the map created by the code I gave above.
To load the maps into L1, you can use Copy(. For example, to copy X bytes from GDB1 to L1, you can use Copy(GDB1,L1,X).
A more complete line of code was that which was given above:
Code: [Select]
Copy(L-1*56+GDB1,L1,56This code assumes you store 56-byte maps in the way I suggested in my previous post.
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline Jagang

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 10
  • Rating: +0/-0
    • View Profile
Re: [Axe] Tableau dynamique
« Reply #4 on: October 25, 2010, 10:33:59 am »
Ok, I understand, thank you.
So, I create a Data like that :
Code: [Select]
Data([map 1],[map 2],[map 3] ...) ->GBD1And to load one map I use :
Code: [Select]
Copy(L-1*128+GDB1,L1,128)Where L is the level starting at 1 and 128 is the size of the map.
But my maps have different size.
Can I use an other GDB with the size of each map ?
For example :
Code: [Select]
Data([map 1, 56],[map 2, 42] ...)->GDB1
Data(56,42 ...)->GDB2
And to load :
Code: [Select]
0->A
For(I,0,L)
    A+{I+GDB2}->A
End
Copy(A+GDB1,L1,{L+GDB2})
Does it work ?

How to access at the different case of L1 ?
Like GDB ?
Code: [Select]
If {D+L1}=3
    2->{D+L1}
End

Thank you

Jagang

EDIT: Someone know an Axe editor for PC ? Actualy, I use TI-Graph Link 83+ and it hasn't the instruction of Axe.
Personne ne connaitrais un éditeur pour l'Axe sur ordi ? J'utilise TI-Graph Link 83+ en ce moment, mais il n'a pas les instruction d'Axe et en plus il est francisé (Str1 = Chaîne1 ...)
« Last Edit: October 25, 2010, 10:47:34 am by Jagang »

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: [Axe] Tableau dynamique
« Reply #5 on: October 25, 2010, 10:46:04 am »
GDB2 wouldn't be the size of each map but rather the sum of the sizes of all the maps before it.
So instead of Data(56,42 ...)->GDB2 you would have Data(0,56,98 ...)->GDB2. 98 is 56+42, of course.
To map L indexed from 1 you would then use
Code: [Select]
Copy(GDB1+{L+GDB2-1},L1,{L+GDB2}-{L+GDB2-1})Note that you'd have to add to the end of GDB2 an extra entry that is the sum of the sizes of all the maps.
You could use your method too, but L should be L-1 in both places where it appears. It will also be somewhat slower ;)
Code: [Select]
0->A
For(I,1,L
  A+{I+GDB2-1}->A
End
Copy(A+GDB1,L1,{L+GDB2-1})
This is the fixed version of yours.

What do you mean by "How to access at the different case of L1. Like GDB?"
Edit: You can use TI-Graph Link, you just need to know to use conj( instead of Copy(, expr( instead of Exch(, and so on.
« Last Edit: October 25, 2010, 10:47:27 am by calcdude84se »
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline Jagang

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 10
  • Rating: +0/-0
    • View Profile
Re: [Axe] Tableau dynamique
« Reply #6 on: October 25, 2010, 10:57:44 am »
I prefer my method because I think to use GDB2 for the real size of the map, the size on X and on Y :
Code: [Select]
Data(7,8 |size of the first map| ...) ->GDB2So, to load :
Code: [Select]
.Size of the map in X
    {L+BDG2-1 }->U
    .Size of the map in Y
    {L+BDG2 }->V
   
    0->A
    For(I,1,L
        A+{I+GDB2-1}*{I+GDB2}->A

        .To add 2 on each loop
        I+1->I
    End
   
    Copy(A+GDB1,L1,U*V)
No ? I can use a While loop too.
« Last Edit: October 25, 2010, 11:06:20 am by Jagang »

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: [Axe] Tableau dynamique
« Reply #7 on: October 25, 2010, 11:07:21 am »
Hm... that code is almost good. I think it would be better to use a While loop, though.
Also, there is no "order of operations" and your data for each map is now two bytes.
Code: [Select]
0->A
L*2+(GDB2->I)->E
.E is the end of the size data which we're scanning
Repeat I=E
  {I}*{I-1}+A->A
  .No order of operations, so we have to make the multiplication come first.
  I+2->I
  .Add 2
End
Copy(A+GDB1,L1,{E-1}*{E-2})
.I would work too instead of E
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline Jagang

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 10
  • Rating: +0/-0
    • View Profile
Re: [Axe] Tableau dynamique
« Reply #8 on: October 25, 2010, 11:11:38 am »
I don't understand your code, sorry :(
Can you explain it please ?

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: [Axe] Tableau dynamique
« Reply #9 on: October 25, 2010, 11:23:19 am »
Code: [Select]
[b]Edit:[/b] Annoying code tag bug. Try to ignore x.x
Okay :)
So, one line at a time:
[code]0->A
Initialize A, like we've been doing
Code: [Select]
L*2+(GDB2->I)->EYou can store to variable inside expressions. We need I to point to the beginning of the data containing the size, so it is stored.
Since the size data for each map is 2 bytes, we multiply L by 2, then add it to the beginning of the size data to get the end where we stop.
Code: [Select]
Repeat I=EJust repeat until we reach the end.
Code: [Select]
 {I}*{I+1}+A->AI points to the X-size of the current map, and I+1 points to the Y-size of it. (I had had I-1, but I fixed it.)
We multiply these to get the total size of the current map, and add it to A. The multiplication comes first because otherwise it would evaluate as (A+{I})*{I+1} and not A+({I}*{I+1})
Code: [Select]
 I+2->IAdd 2 to move on to the next set of data.
Code: [Select]
End/code]
Finish our loop
Copy(A+GDB1,L1,{E-1}*{E-2})[/code]
A is the correct offset, so we add it to GDB1 to get to the start of the map data.
Alternatively, we could have done GDB1->A at the beginning and just A on this line instead of A+GDB1.
L1 is the destination.
E is the end of the size data we've scanned. The data for the map you're loading is right before it. So {E-1} is the Y-size and {E-2} is the X-size. We multiply those to get the size of the map which we're copying.
« Last Edit: October 25, 2010, 11:25:33 am by calcdude84se »
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline Jagang

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 10
  • Rating: +0/-0
    • View Profile
Re: [Axe] Tableau dynamique
« Reply #10 on: October 25, 2010, 11:37:39 am »
Ok, thank you.
But I have an other problem, yet ...
Code: [Select]
0->A
L*2+(GDB2->I)->E
.E is the end of the size data which we're scanning
Repeat I=E
    {I}*{I-1}+A->A
    .No order of operations, so we have to make the multiplication come first.
    I+2->I
    .Add 2
End
Copy(A+GDB1,L1,{E-1}*{E-2})
.I would work too instead of E

.Size of the map in X
{E-2}->U
.Size of the map in Y
{E-1}->V

Fixe 5

0->O
For(A,0,U*V-1)
    If {A+L1}=3
        O+1->O
    End
    Text(45,40
    Text AåDec,{A+L1}åDec
    DispGraph
    Pause 500
End

All case are 2 !!!

Code: [Select]
Data(0,1,1,1,1,0,0,0,1,1,0,0,1,1,1,1,1,0,0,0,0,0,0,1,1,0,3,3,1,2,0,1,1,1,1,0,0,2,1,1,0,0,1,1,1,0,0,1,0,0,0,0,1,1,1,1)->GDB1
Data(8,7)->GDB2

Why ?

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: [Axe] Tableau dynamique
« Reply #11 on: October 25, 2010, 11:43:39 am »
Is L set to 1?
If so, that should work...
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline Jagang

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 10
  • Rating: +0/-0
    • View Profile
Re: [Axe] Tableau dynamique
« Reply #12 on: October 25, 2010, 11:48:00 am »
I add the total code in attachment.

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: [Axe] Tableau dynamique
« Reply #13 on: October 25, 2010, 12:31:57 pm »
{I}*{I-1}+A→A
You still have the unfixed code in your file. Could you fix it to {I}*{I+1}+A→A and try again? :)
Edit: Just tried it; it still says "2"... I'll keep looking.
Edit 2: There was a problem with my code. L*2+(GDB2→I)→E should be L-1*2+(GDB2→I)→E. Trying that now.
« Last Edit: October 25, 2010, 12:35:13 pm by calcdude84se »
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline Jagang

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 10
  • Rating: +0/-0
    • View Profile
Re: [Axe] Tableau dynamique
« Reply #14 on: October 25, 2010, 05:22:45 pm »
J'ai remplacé {I}*{I-1}+A->A par {I}*{I+1}+A->A mais ca ne change rien.
Puis j'ai remplacé L*2+(GDB2->I)->E par L-1*2+(GDB2->I)->E mais la ca ne fonctionne plus du tout, il n'y a plus qu'une seule case qui s'affiche...
Merci
Cordialement
Jagang

PS : je suis sur mon téléphone donc je suis obligé d'écrire en français.