Rolling a dice makes two generally independent events not quite independent? So I was thinking about a hypothetical situation where the following happens. This situation is confusing my understanding quite a bit.
Lets say there are two jars both containing 10 balls. Jar 1 has 4 green balls, and Jar 2 has 7 green balls.
Lets then define two probabilities B1 and B2 both be balls drawn from the same jar with replacement.
Now here is the kicker.
In order to choose which jar to select from you roll a dice if it gets 4 or lower then both p1 and p2 are based on selecting from Jar 1 otherwise they are selected from Jar 2.
So essentially you have this situation where the probability of B1 being green or B2 being green is based on the probability of rolling a 4 or lower. You would expect the probability of B1 being green to equal B2 being green but I am not sure that is the case.
For simplicity lets define p1 to be the probability that B1 is green and p2 to be the probability that B2 is green.
So heres my conundrum. If you were to ask me whats the probability of p2 given p1 I would tend to shrug off the question and say that they would be equal because they should be independent events. However apon thinking more knowing p1 actually does give me a bit of extra information about p2. You see if we drew a green ball that event is more likely in Jar 2 because it has more green balls. So if we know that B1 is green but not which jar it came from we have some unexpected extra information.
So then the final problem is how do you calculate "If B1 is green what is the probability B2 is green"?
My general technique here would be to say P(B1 is green) = P(B2 is green) and then use the formula (4/10)(4/6)+(7/10)(2/6) to get my answer.
However the following program below would simulate this situation and get a different answer here.
int rep = 400000000;

numdum a;
a.num = 0;
a.den = 0;

for (int i = 0; i < rep; i++) {
    int d1 = randint(0, 6) < 4;

    int E1Green;
    int E2Green;

    if (d1 == 1) {
        E1Green = randint(0, 10) < 4;
        E2Green = randint(0, 10) < 4;
    } else {
        E1Green = randint(0, 10) < 7;
        E2Green = randint(0, 10) < 7;
    }

    if (E1Green == 1) {
        a.den++;
        if (E2Green == 1) {
            a.num++;
        }
    }
}
float probability = (float)a.num / (float)a.den;

This program would compute 0.540052 even for very high n's suggesting that my above technique which would calculate 0.5 is not correct.
What is going on here? How could I have calculated P(E2 is green | E1 is green) exactly as a fraction? E2 is green and E1 is green arent exactly independent here are they?
Note: If possible please explain in terms of Independence, Bayes Rule, Total Law Of Probability/other simple stuff. That is all I have been taught at this time although if it is a more complicated concept that can only be explained with something I dont know yet that is fine too.
 A: Then two events are not independent.  As you say, knowing that the first ball is green makes it somewhat more likely that the ball was drawn from jar $2,$ and so influences our estimate that the second ball is green.
Let $p_i$ be the probability that ball $i$ is green, $i=1,2.$  Then $$p_i=\frac23{4\over10}+\frac13{7\over10}=\frac12,\ i=1,2.$$  However, the probability that both balls are green is$$
\frac23\left({4\over10}\right)^2+\frac13\left({7\over10}\right)^2={27\over100}\neq p_1p_2$$ so the events aren't independent.
Furthermore, the probability that ball $2$ is green, given that ball $1$ is green, is the probability that both are green, divided by the probability that ball $1$ is green or $${.27\over.5}=.54.$$
A: It seems you have a problem to distinguish between simple probabilities of events and conditional probabilities of events. 
What you correctly calculated as 0.5 is the simple probability of B1 being green:
$$P(\text{B1 is green})=0.5.$$
Also correctly, the same is true for B2:
$$P(\text{B2 is green})=0.5.$$
What you program calculated, however, is the probability that B2 is green under the condition that B1 is green:
$$P(\text{B2 is green}|\text{B1 is green})=0.54.$$
The value that your program found is roughly the same, the calculation for the exact value can be found in saulspatz' answer.
The textbook definition of the conditional probability ($E_1, E_2$ being events influenced by a discrete random process) is
$$P(E_1|E_2)=\frac{P(E_1 \cap E_2)}{P(E_2)}$$
Also, the textbook definition of 2 events being independent is
$$E_1,E_2 \text{ are independent:} \iff P(E_1 \cap E_2) = P(E_1)P(E_2)$$
As you can see, the definition of independence is the same as saying $P(E_1|E_2)=P(E_1)$. That can be seen as the 'common sense' definition of independece: Even though I know that $E_2$ happened, it doesn't change my probability of $E_1$ having happened from before I had any information.
As you can see from the calculations you did, 
$$P(\text{B2 is green}|\text{B1 is green}) \neq P(\text{B2 is green}).$$
Those calculations are correct, and they confirm that the events are not independent. The common sense reason is the one you gave yourself: The different jars contain different densities of green balls, so the effect of the dice roll that selects the jar is 'leaked' (in a probabilistic sense) by the information that B1 is green.
It's even clearer when you consider jars with 1000 balls, and jar 1 contains exactly 1 green ball and jar 2 exactly 999. If B1 is green, then the selected jar is with very high probability jar 2, so B2 will also be green with very high probability.
To sum up, your original idea that "B1 is green" and "B2 is green" being indpendent events (coming from the scenario where only one jar exists, where it is correct) has been proven incorrect, and I think you have a hard time accepting this, looking for errors in calculations that are not there.
