« first day (267 days earlier)      last day (4223 days later) » 
00:00 - 21:0021:00 - 00:00

9:00 PM
Yes. Can you tell me the rules of your CA in short?
When the center is white, when does it stay white?
 
so
cell==0 white the is white when the numbers of black cell= numbers of red cell
 
Exaclty
Did you see, that you need exactly one If condition for this?
 
the is black if numbers of black cell > red cell
 
If[numRed==numBlack && cell==White, White]
 
then is red of numbers of red cell>black cell
yes ok
 
9:04 PM
When the center is red what happens then?
 
if cell==1 and number of black cell > red cell then is balck
black
if cell==red and number of red cell > black cell then is red
if cell== red and number of red cell==black cell then is red
but her there is a problem
 
But then your whole automaton is really simple: If the number of Red cells is equal to the number of Black cells, then the center cell stays as it is. Otherwise the center gets the color Red, if we have more Red cells and Black if we have more Black cells.
Or not?
 
but in the case in which we have center cell red, two red cell and three black cell as neighbors
 
it stays red
 
the result should be white
 
9:13 PM
oh
 
because i have 3 cell red (including the center) and 3 black cell that interact and die
 
So let me repair my algorithm:
 
If the number of Red cells is equal to the number of Black cells, then the center cell gets White. Otherwise the center gets the color Red, if we have more Red cells and Black if we have more Black cells.
 
only one question: but number contain also the center?
so number means 9 neighbors or 8?
 
9:15 PM
Yes, because you defined the getNbhd this way ;-)
 
ah ok
so
@halirutan this is in the case of cell==1 or cell==2
while
@halirutan if cell==0
isn't it?
so the code will change in
 
What do you think about this here:
countRedBlack[a_, i_Integer?Positive, j_Integer?Positive] :=
 With[{nb = Flatten@a[[i - 1 ;; i + 1, j - 1 ;; j + 1]]},
  Count[nb, #] & /@ {1, 2}]

evaluateCell[a_, i_, j_] := Module[{numRed, numBlack},
  {numRed, numBlack} = countRedBlack[a, i, j];
  Which[numRed == numBlack, 0, numRed > numBlack, 1,
   numBlack > numRed, 2]
  ]
Let's test the examples above:
evaluateCell[{{1, 1, 1}, {1, 2, 1}, {1, 1, 1}}, 2, 2]
Returns 1 as desired
evaluateCell[{{2, 2, 2}, {2, 2, 0}, {0, 0, 0}}, 2, 2]
Returns 2 as desired
 
ok perfect
so from my code
i have to delete from
>getNbhd[A_, i_Integer?Positive, j_Integer?Positive] := A[[i - 1 ;; i + 1, j - 1 ;; j + 1]];

evaluateCell[A_, i_, j_] := Module[{nbhd, cell = A[[i, j]], numNeighbors},

If[i == 1 || j == 1 || i == Length[A] || j == Length[A[[1]]], Return[0]];

nbhd = getNbhd[A, i, j]; numNeighbors = Apply[Plus, Flatten[nbhd]];

If[cell == 2 && numNeighbors - 2 >= 4 ||
numNeighbors - 2 == 3 && numNeighbors - 1 <= 3 ||
numNeighbors - 2 == 2 && numNeighbors - 1 <= 2 ||
numNeighbors - 2 == 1 && numNeighbors - 1 <= 1 ||
 
You delete everything except the evaluateAll function
 
and put instead of all that staff your code
ok i will try, one second :)
 
9:24 PM
I go pee pee
 
running the code, i have this error:
Part::take: Cannot take positions 0 through 2 in {{2,1,2,1,2,1,2,2,1,1},{1,1,1,0,0,2,0,1,1,0},{2,2,2,0,0,2,0,2,0,2},{2,0,2,0,1,2,2,0,1,1},{2,2,2,0,0,1,0,2,0,1},{0,2,1,0,1,2,2,0,1,1},{0,0,0,2,0,0,1,2,0,1},{2,1,1,0,1,0,1,1,2,0},{1,0,2,0,2,0,2,1,0,0},{1,2,1,1,1,1,1,0,2,2}}. >>

Part::take: Cannot take positions 0 through 2 in {{2,1,2,1,2,1,2,2,1,1},{1,1,1,0,0,2,0,1,1,0},{2,2,2,0,0,2,0,2,0,2},{2,0,2,0,1,2,2,0,1,1},{2,2,2,0,0,1,0,2,0,1},{0,2,1,0,1,2,2,0,1,1},{0,0,0,2,0,0,1,2,0,1},{2,1,1,0,1,0,1,1,2,0},{1,0,2,0,2,0,2,1,0,0},{1,2,1,1,1,1,1,0,2,2}}. >>
 
Can you give me your sample input?
 
randomLife = makeFrames[RandomInteger[2, {10, 10}], 10]
animate[randomLife]
 
Your evaluateAll makes a mistake!
Your table starts at 1
which calls evaluateCell[A,1,1]
This goes wrong because you cannot take the neighbors at the border.
What is a good choice for the border? 1?
 
or 0 or the cell itself
 
9:37 PM
When you pad one row of zeroes around your data:
evaluateAll[A_] := With[{paddedA = ArrayPad[A, 1]},
  Table[evaluateCell[paddedA, i, j], {i, 2, Length[A] + 1}, {j, 2,
    Length[A[[1]]] + 1}]
  ]
it should work
Holy cow!
 
perfect
thank you very much
 
I write up an answer..
no problem. You're welcome
 
can you tell me your name?
 
Patrick
 
i want to thank you in my thesis
really
it's almost one month
 
9:42 PM
When is your deadline?
 
half of november
that i was on this topic
it was the last part of my thesis
 
Send me you thesis. I may have a look it.
 
if you write me your address e-mail
i will do it
 
Or better, when you have a running notebook with the code you'll use in the thesis send this one.
Maybe we can improve some of it.
 
thank you so much
address e-mail?
 
9:45 PM
got it?
 
yes perfect
anyways I leave in Munich
 
You could have tell me this earlier that a private chatroom in German would have been a lot easier!
 
can you write it again?
but i don't speak german
 
Oh..
Kind of hard in Munich ;-)
But in Munich the people don't speak German too!
 
ahahah right
here everyone speck english
 
9:48 PM
(This is probably a joke only a German can get)
 
there are not a lot of german people here a the one living here speak bavarian
:)
may you write me only the first par of your e-mail?
 
Right. You got it!
 
@halirutan Heh, I thought the ribbing on Bavaria was universal knowledge :)
 
thank you so much Patrick
 
@DanieleRicci Whats your email?
ok, have it
 
9:52 PM
perfect
have a nice night
and thank you again
 
Delete your e-mail!
ok
 
as soon i will implement all the code i will send you an e-mail
see you
bye
 
see you
 
@halirutan Since you've already done most of the work, might as well throw it in as an answer for the bounty :)
 
@rm-rf I haven't planned to solve it because I haven't read the question carefully until today.
But yes, I'm writing up an answer.
This was btw a question of the kind which is solved in 10 seconds if you got through the many Ifs and the big excel file..
 
9:59 PM
@halirutan Hehe, yes. I didn't bounty it because it was hard... more so because she was distraught that the question hadn't received attention (been nearly 3 weeks) despite getting some votes, and to be fair, she had done some effort to the best she can. What good is ~28k in rep if I can't put it to some use to help someone :)
 
Oh.. it's a she
2
;-)
 
@halirutan That explains everything
 
@belisarius Girls always get me to help them..
But I though Daniele could be a guy too? It sounds spanish or so.
Never mind
 
@halirutan Probably French
 
I was here, he/she asked and I had no better plans.
 
10:02 PM
@halirutan Oh, I assumed it was. I don't know for sure... Daniele can be a guy, but Danielle is a girl. I always get confused, so tossed a coin and picked female :)
 
toadelle
 
@halirutan Probably Italian.
Speaking of which, I did have an office mate from Italy who called himself Daniel, but his name was written Daniele.
@belisarius toadette? toadabelle? toadita?
 
 
1 hour later…
11:06 PM
@LeonidShifrin (Damn, smarter than me and better looking.)
 
Hi @Mr.Wizard , I just got your comment. This is my first time in the chat so I have no idea if you're around...
 
@Amatya yes, I am. Welcome.
 
cool.. thanks so much for all your help
 
No problem. Do you want to ask any questions or shall I just start rambling?
 
@Amatya Look at the icons in the upper right corner of this page.. Everyone which is shown there is probably here
 
11:13 PM
so right now I am using Table[nuff[list[j],number[j], {j,1,100}]
 
@halirutan I have to disagree; I often forget to formally leave.
 
oh cool just 6 people
 
Amatya : again, do you have specific questions or shall I just start babbling about the topic?
 
@Mr.Wizard Yep, that's why I wrote "probably"..
 
@Mr.Wizard I dont have a specific question. I am using the command you wrote inside Table so you should start talking cuz I dont understand this stuff.. btw I am at work and I may have to exit in 15 mins soI could find you later if you think thats better
 
11:18 PM
Not a problem. I'll make some comments now and later you can ask more specific questions. halirutan, if you see me spouting too much nonsense please step in. ;-)
 
@Mr.Wizard sweet thanks
 
First, the function Nearest has two different forms, and you should make sure you understand the difference. The basic form take a list and a value, and finds the nearest element. This is quite fast for what it does, in a one-off manner. The other form simply takes a list, and builds a new function that is optimized for that specific list, which an internal look-up table.
(sorry, I think slow and type slower...)
Second, "memoization" is a method of storing the results of a computation for a specific set of arguments, so that this cached result can be used again in the future rather than having to be recalculated. The obvious trade-off is memory consumption. In Mathematica this is most conveniently done by writing a function like this:
f[x_] := f[x] = (* calculation *)
 
@Mr.Wizard I see. My lists right now are anywhere from 100x6 to a 1000x6 and right now I am searching for 10 to 20 values.. so I'm guessing I don't need to create an internal table for something this small
 
Because of the order of operations (precedence) this parses as:
f[x_] := ( f[x] = (* calculation *) )
@Amatya Quite possibly not, but I'll continue, if you wish.
 
@Mr.Wizard yes please.. I just wanted to comment in the middle because I wanted you to not think that you were talking to a wall
 
11:25 PM
No problem.
This then is a SetDelayed (:=) definition of f for any argument matching the pattern x_, which on matching creates a Set (=) definition of f for that specific argument. Mathematica automatically orders these definitions (accessible with DownValues) by apparent specificity. This not completely unambiguous, but in this case it is clear: the actual argument (e.g. 5) is more specific than the parameter pattern x_, so this rule (definition) will be tried first.
 
btw @Mr.Wizard I am copying and pasting this chat so I can read it again later cuz I wont remember and understand everything. I hope thats ok with you.
 
Of course. Know also that there is a permanent record of this chat available as well.
 
@Mr.Wizard oh cool. thx
 
What this means is that if we call f[5] we get f[5] = (* our calculation *) the first time, and the second time we get whatever the result of that calculation was.
(just a moment)
In this answer I describe this pattern as well as uses beyond memoization for it:
20
A: What is "x := x =" trickery?

Mr.WizardMemoization is perhaps the most common application, but it is not the meaning of that construct. More generally it is a construct for a function that redefines itself. This has many uses beyond memoization. Consider this function: f[y_] := (f[y] = Sequence[]; y) This function is used to r...

Now, as I said earlier, the trade-off with memoization is the memory consumed to store the cached values. Here is a simple example. We will create a recursive definition for the Fibonacci numbers and use memoization to make it efficient.
ClearAll[fib]
fib[0] = 0; fib[1] = 1;
fib[n_] := fib[n] = fib[n - 1] + fib[n - 2]
fib[10]
Output: 55
Now if we look at the DownValues we see the result of the memoization :
{HoldPattern[fib[0]] :> 0, HoldPattern[fib[1]] :> 1,
 HoldPattern[fib[2]] :> 1, HoldPattern[fib[3]] :> 2,
 HoldPattern[fib[4]] :> 3, HoldPattern[fib[5]] :> 5,
 HoldPattern[fib[6]] :> 8, HoldPattern[fib[7]] :> 13,
 HoldPattern[fib[8]] :> 21, HoldPattern[fib[9]] :> 34,
 HoldPattern[fib[10]] :> 55,
 HoldPattern[fib[n_]] :> (fib[n] = fib[n - 1] + fib[n - 2])}
Notice that the primary definition is shown last in the list; this is the automatic ordering I mentioned; these definitions are tried in sequence until one that matches is found, then the rest are ignored (for a particular evaluation).
Clearly while using a method like this you could end up running out of memory if too many values are cached. The most simplistic way to deal with this is to just evaluate the definition code again, including the ClearAll, setting everything back to the initial state.
 
Hey @Mr.Wizard my boss is here.. can you please continue and I will come back and read the chat log and ask you further questions when I can catch you. Thanks a lot! seeya later
 
11:38 PM
I'll just continue later. See you then. :-)
 
@Mr.Wizard cool thx. catchya later
 
00:00 - 21:0021:00 - 00:00

« first day (267 days earlier)      last day (4223 days later) »