Type-juggling and (strict) greater/lesser-than comparisons in PHP

PHP’s comparison operators deviate from the computer-scientific definitions in several ways: In order to constitute an equivalence relation == has to be reflexive, symmetric and transitive: PHP’s == operator is not reflexive, i.e. $a == $a is not always true: var_dump(NAN == NAN); // bool(false) Note: The fact that any comparison involving NAN is always … Read more

Solving “Who owns the Zebra” programmatically?

Here’s a solution in Python based on constraint-programming: from constraint import AllDifferentConstraint, InSetConstraint, Problem # variables colors = “blue red green white yellow”.split() nationalities = “Norwegian German Dane Swede English”.split() pets = “birds dog cats horse zebra”.split() drinks = “tea coffee milk beer water”.split() cigarettes = “Blend, Prince, Blue Master, Dunhill, Pall Mall”.split(“, “) # … Read more

What is the optimal algorithm for the game 2048?

I developed a 2048 AI using expectimax optimization, instead of the minimax search used by @ovolve’s algorithm. The AI simply performs maximization over all possible moves, followed by expectation over all possible tile spawns (weighted by the probability of the tiles, i.e. 10% for a 4 and 90% for a 2). As far as I’m … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)