Autor |
Beitrag |
Narses
      

Beiträge: 10183
Erhaltene Danke: 1256
W10ent
TP3 .. D7pro .. D10.2CE
|
Verfasst: Mo 16.03.15 17:55
Moin!
Wir haben doch festgestellt, dass man immer N addieren kann, nicht nur dann, wenn x < 0 ist. Also können auf jeden Fall die beiden if-Zeilen raus. Und dann schau mal, ob man da noch was zusammenfassen kann.
cu
Narses
_________________ There are 10 types of people - those who understand binary and those who don´t.
|
|
Nini 
      
Beiträge: 170
Erhaltene Danke: 12
|
Verfasst: Mo 16.03.15 18:24
vielleicht so: Delphi-Quelltext 1: 2: 3: 4:
| function TForm1.LebtNachbar(x, y: Integer): Boolean; begin Result := Feld[(x+N) mod N, (y+N) mod N]; end; |
|
|
Narses
      

Beiträge: 10183
Erhaltene Danke: 1256
W10ent
TP3 .. D7pro .. D10.2CE
|
Verfasst: Mo 16.03.15 18:32
Moin!
Perfekt!
Dann würde ich hier gerne noch das "not" entfernen (zugegeben, mehr aus didaktischen Gründen, als dass es großen Nutzen hätte).
Delphi-Quelltext 1:
| if not ((dx = 0) and (dy = 0)) then |
Was tut "not"? Es negiert die Bedingung. Wenn wir also das not entfernen wollen, müssen wir alle Terme in der Klammer negieren (also das Gegenteil abfragen).
Probier mal.
cu
Narses
_________________ There are 10 types of people - those who understand binary and those who don´t.
|
|
Nini 
      
Beiträge: 170
Erhaltene Danke: 12
|
Verfasst: Mo 16.03.15 18:36
vielleicht funktioniert das ja so
Delphi-Quelltext 1:
| if ((dx<>0) and (dy<>0)) then |
|
|
Narses
      

Beiträge: 10183
Erhaltene Danke: 1256
W10ent
TP3 .. D7pro .. D10.2CE
|
Verfasst: Mo 16.03.15 18:38
Moin!
Probiers doch einfach mal im Programm aus.  (ist schon gar nicht so schlecht  )
cu
Narses
_________________ There are 10 types of people - those who understand binary and those who don´t.
|
|
Nini 
      
Beiträge: 170
Erhaltene Danke: 12
|
Verfasst: Mo 16.03.15 18:47
das programm läuft, aber nicht ganz richtig
|
|
Narses
      

Beiträge: 10183
Erhaltene Danke: 1256
W10ent
TP3 .. D7pro .. D10.2CE
|
Verfasst: Mo 16.03.15 19:01
Moin!
Genau, so ist es. Aber was heißt denn, nicht ganz richtig? (naja, ich weiß es natürlich, deshalb schlage ich vor, wir untersuchen besser nicht, was da im Game of Life schief läuft, das könnte nämlich haarig werden, sondern betrachten das separat)
Quelltext 1: 2: 3: 4: 5: 6:
| a | b | not (a and b) | (not a) and (not b) ------------------------------------------- 0 | 0 | ? | ? 0 | 1 | ? | ? 1 | 0 | ? | ? 1 | 1 | ? | ? |
Bitte mal ausfüllen.
cu
Narses
_________________ There are 10 types of people - those who understand binary and those who don´t.
|
|
Nini 
      
Beiträge: 170
Erhaltene Danke: 12
|
Verfasst: Mo 16.03.15 19:47
ich hab keine ahnung, was ich rechnen muss :/
|
|
Narses
      

Beiträge: 10183
Erhaltene Danke: 1256
W10ent
TP3 .. D7pro .. D10.2CE
|
Verfasst: Mo 16.03.15 20:24
Moin!
OK, das nennt man Wahrheitstabelle.  Hier mal ein paar einfache Beispiele:
Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18:
| a | b | a and b --------------- 0 | 0 | 0 0 | 1 | 0 1 | 0 | 0 1 | 1 | 1
a | b | a or b --------------- 0 | 0 | 0 0 | 1 | 1 1 | 0 | 1 1 | 1 | 1
a | not a --------- 0 | 1 1 | 0 |
Dabei steht 0 für False und 1 für True. Jetzt klarer?
cu
Narses
_________________ There are 10 types of people - those who understand binary and those who don´t.
|
|
Nini 
      
Beiträge: 170
Erhaltene Danke: 12
|
Verfasst: Mo 16.03.15 20:33
dann wäre die erste spalte, wenn ich es richtig verstanden habe
Delphi-Quelltext 1: 2: 3: 4: 5: 6:
| a | b | not (a and b) | (not a) and (not b) ------------------------------------------- 0 | 0 | 1 | ? 0 | 1 | 1 | ? 1 | 0 | 1 | ? 1 | 1 | 0 | ? |
|
|
Narses
      

Beiträge: 10183
Erhaltene Danke: 1256
W10ent
TP3 .. D7pro .. D10.2CE
|
Verfasst: Mo 16.03.15 20:45
Moin!
Nini hat folgendes geschrieben : | dann wäre die erste spalte, wenn ich es richtig verstanden habe |
Jap, hast du.
Und wenn unsere umgewandelte Formel in der letzten Spalte korrekt ist, sollte da genau das Gleiche rauskommen (wir haben ja nur das not in die Klammer gezogen).
cu
Narses
_________________ There are 10 types of people - those who understand binary and those who don´t.
|
|
Nini 
      
Beiträge: 170
Erhaltene Danke: 12
|
Verfasst: Mo 16.03.15 20:51
aaaaaaachso  sowas wie assoziativgesetz also
|
|
Narses
      

Beiträge: 10183
Erhaltene Danke: 1256
W10ent
TP3 .. D7pro .. D10.2CE
|
Verfasst: Mo 16.03.15 21:05
Moin!
Nini hat folgendes geschrieben : | aaaaaaachso sowas wie assoziativgesetz also |
 Wow, ja, genau sowas. (Aber eben nicht ganz  )
cu
Narses
_________________ There are 10 types of people - those who understand binary and those who don´t.
|
|
Nini 
      
Beiträge: 170
Erhaltene Danke: 12
|
Verfasst: Mo 16.03.15 21:06
ie krieg ich das jetzt so umgewandelt, dass das programm wieder richtig läuft?
|
|
Narses
      

Beiträge: 10183
Erhaltene Danke: 1256
W10ent
TP3 .. D7pro .. D10.2CE
|
Verfasst: Mo 16.03.15 21:10
Moin!
Nini hat folgendes geschrieben : | ie krieg ich das jetzt so umgewandelt, dass das programm wieder richtig läuft? |
Indem du das Gehirn einschaltest, die Tabelle ausfüllst, feststellst, dass die Formel nicht korrekt ist, diese korrigierst, die Tabelle auch und dann die Erkenntnis auf die Delphi-Zeile anwendest.
cu
Narses
_________________ There are 10 types of people - those who understand binary and those who don´t.
|
|
Nini 
      
Beiträge: 170
Erhaltene Danke: 12
|
Verfasst: Mo 16.03.15 21:26
ich bin überfordert 
|
|
Narses
      

Beiträge: 10183
Erhaltene Danke: 1256
W10ent
TP3 .. D7pro .. D10.2CE
|
Verfasst: Mo 16.03.15 21:31
Moin!
Ach, das wird schon, nicht aufgeben.
Dann machen wir die erste Zeile mal zusammen:
Delphi-Quelltext 1: 2: 3: 4: 5: 6:
| a | b | not (a and b) | (not a) and (not b) ------------------------------------------- 0 | 0 | 1 | (not 0) and (not 0) = 1 and 1 = 1 0 | 1 | 1 | ? 1 | 0 | 1 | ? 1 | 1 | 0 | ? |
Jetzt klarer? Einfach die Werte einsetzen und ausrechnen.
cu
Narses
_________________ There are 10 types of people - those who understand binary and those who don´t.
|
|
Nini 
      
Beiträge: 170
Erhaltene Danke: 12
|
Verfasst: Mo 16.03.15 21:34
Delphi-Quelltext 1: 2: 3: 4: 5: 6:
| a | b | not (a and b) | (not a) and (not b) ------------------------------------------- 0 | 0 | 1 | (not 0) and (not 0) = 1 and 1 = 1 0 | 1 | 1 | (not 0) and (not 1) = 1 and 0 = 0 1 | 0 | 1 | (not 1) and (not 0) = 0 and 1 = 0 1 | 1 | 0 | (not 1) and (not 1) = 0 and 0 = 0 |
|
|
Narses
      

Beiträge: 10183
Erhaltene Danke: 1256
W10ent
TP3 .. D7pro .. D10.2CE
|
Verfasst: Mo 16.03.15 21:39
Moin!
Passt.  Na, war doch gar nicht schwer, oder?
Leider passt aber unsere Formeltransformation offensichtlich nicht, denn da kommt was anderes als in der Spalte davor...  Vorschlag für eine Korrektur?
cu
Narses
_________________ There are 10 types of people - those who understand binary and those who don´t.
|
|
Nini 
      
Beiträge: 170
Erhaltene Danke: 12
|
Verfasst: Mo 16.03.15 21:47
nein, so logische verknüpfungen find ich total kompliziert 
|
|