Autor Beitrag
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Do 17.04.08 20:32 
Hi,

In meinem Schachprogramm will ich eine KI einbauen; diese wird wohl rekursiv arbeiten und nun geht es mir um die Laufzeitoptimierung der einzelnen Schritte.

Ich habe mir überlegt, für einen kurzen Zugmustertest(grundlegende Validität des Zugfeldes) ein Array[Figurentypen(ohne Bauer), 0..7, 0..7] of Boolean anzulegen, welches mir diesen Check mit minimalem Rechenaufwand erledigt(zuerst hatte ich kurze Formeln).

Nun ist dieses Array aber 5 * 8 * 8 = 320 Werte und damit, wenn ich das mit dem "kein Zugriff auf Bits" richtig verstanden habe, 320 Byte, ein drittel KB, groß :?

Nun weiß ich nicht, wie der Compiler mit const arbeitet: Kopiert er die werte sowieso immer an die Stelle, wird zur Laufzeit eine Kopie erzeugt...

Letzteres wäre fatal, da dann bei jedem Durchlauf der Prozedur 320 Byte beschrieben würden. Insofern meine Frage: Wo muss ich diese Konstante deklarieren, um ein Optimum an Laufzeit zu erhalten? Zu Beginn der Unit(global), im implementation-Teil oder einfach in der Prozedur?

mfG,

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Do 17.04.08 20:59 
Konstanten werden immer über data-Segment der Anwendung addressiert, sei denn, sie passen in ein CPU-Register und sind semantisch von der CPU direkt verarbeitbar. Ansonsten werden sie direkt im Compilat abgebildet.

Auf dem Stack wird eine Konstante nicht kopiert (sei denn, man schreibt ne explizite Zuweisung einer Variablen ...

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Hidden Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Do 17.04.08 21:05 
Danke :D

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)