image
Everything should be stated as simply as possible, but not simpler.
 - Albert Einstein
To make the game entertaining and interesting, it is not necessary to make computer-controlled opponents smarter. In the end, the player must win. However, letting him win only because the manager of the opponents of AI is badly designed, is also unacceptable. Interest in the game can be increased if the mistakes made by the enemy are intentional. Carefully adjusting the mistakes of opponents, making them intentional, but believable, programmers will allow opponents to look smart and at the same time ensure the victory of the player. In addition, by monitoring AI systems and appropriately controlling them, you can turn situations in which opponents look silly into an interesting gameplay.

A common mistake in the development and implementation of AI systems in computer games is in too complex a design. The AI ​​developer can easily get carried away by creating an intelligent game character and losing sight of the ultimate goal, namely, creating an entertaining game. If a player has the illusion that a computer opponent is doing something clever, then it does not matter how the AI ​​(if any) creates this illusion. A sign of a good AI programmer is the ability to resist the temptation to add intelligence to where it is not needed, and to recognize situations in which more "cheap" and simple solutions are enough. Programming AI is often more like art than science. The ability to distinguish between moments in which cheap tricks are enough, and those where more complicated AI is required, is not easy. For example, a programmer, having full access to all structures of game data, can easily cheat by making the NPC omniscient. NPCs can know where the enemies are, where the weapons or ammunition lies, without seeing them. However, players often recognize such cheap stunts. Even if they can not determine the very nature of cheating, they may have a feeling that the behavior of the NPC is not like the natural.
MeLavi 29 september 2017, 12:02

image How does the JVM create new objects? What exactly happens when you write a new Object ()?
At conferences, it is periodically told that the allocation of objects uses the thread-local allocation buffer (TLABs): memory areas allocated exclusively to each thread, creating objects in which is very fast due to the lack of synchronization.
But how correctly to choose the size of TLAB'a? What to do if you need to allocate 10% of the size of TLAB'a, but only 9% is free? Can an object be allocated outside TLAB? When (if) is the allocated memory set to zero?
Having asked these questions and did not find all the answers, I decided to write an article to correct the situation.
Before reading it, it's useful to remember how some garbage collector works
MeLavi 28 september 2017, 8:23

The problem of most disputes about the problem of piracy is that in them "value" is estimated only in "monetary" dollars. Therefore, the problem is formulated like this: "When buying a game from us, the user spends money dollars. A pirated copy costs zero money dollars. So most people will pirate the game if they have a choice, so you need to stop them at any cost. "

image
The dollar is famous for everyone.

This is the error, therefore, at least four currencies, and not one (monetary dollars) should be taken into account here.

I propose the following notation:


($ D) Monetary dollars
($ B) Temporary dollars
($ D) Headache paints [in the original Pain-in-the-butt-dollars]
($ Ч) Honesty Dollars

The player makes the choice to buy or spiratit game based on how much "each" service (and not product! ) costs in these four currencies, and also depending on the value for the player each of them.
MeLavi 27 september 2017, 13:23

The order of evaluation of expressions is determined by a particular implementation, except when the language guarantees a certain order of calculations. If, in addition to the result, evaluating the expression causes changes in the runtime, then the expression is said to have side effects.
MSDN
In our internal newsletter about C #, a regular question arises, which concerns the correct interpretation of such constructions:

a -= a *= a;
p[x++] = ++x;
In response, I ask:
Yes, who writes such a code with an imperturbable look? It's one thing when you write this, trying to win at the International COC Contest, or if you want to write a puzzle - but in both cases you realize that you are doing something non-standard. That, there really is someone who writes a - = a * = a and p [x ++] = ++ x; and thinks to himself "Shit, yes I write really cool code! "
KlauS 26 september 2017, 9:31

[A Friday translation of the 1999 article by one of the authors of the Thief game engine, Sean Barrett]
Unpleasant situation in "Sapper"
In this situation, I know that there are a lot of mines around me, but I can not determine where they are. Several mines can be in one of two places (pink or blue), a group of mines can be located in one of two combinations (light / dark green). In addition, there is still a difficult situation with "5" and "6" in the upper left corner, which I did not single out.

image
Blue / pink - mutually exclusive pair, light / dark green - mutually exclusive group
"Sapper": logic or probability
In "Sapper" you can play in two ways: as a logical or probabilistic game.

Technically, probability implies logic. If you can logically prove that the mine must be in a certain place, then the probability is 100%. If you can prove that it is not in this place, then the probability is 0%. That is, in a sense, only probabilities are important to us. However, the player uses logical deduction to recognize such 100% situations. Sometimes, especially at low levels of complexity, it is enough to pass a level, no calculation of probabilities is required.

But there are situations when the whole logic of the world can not save you. A simple example is the situation with the "T", which can be seen down the center. It is slightly complicated by additional neighboring mines. (In the simplest case, "2" is replaced by "1", and "5" - by "3", so that the situation is symmetrical.)
KlauS 25 september 2017, 7:07

For testing, the code should be selected and copied directly from tweets . - approx. trans.

I recently found this tweet from <a href="https://twitter.com/FakeUnicode/"> @FakeUnicode < / a>. There was a JavaScript snippet that looked pretty innocuous, but displayed a hidden message. It took me some time to understand what was going on. I think that the record of the steps of my investigation may be of some interest to someone.

Here is the snippet:

image

What would you expect from him?

Here we use the for in loop, which passes through the enumerable properties of the object. Since only the property A is specified, we can assume that the message with the letter A will be shown. Well ... I was wrong. : D
KlauS 23 september 2017, 8:40

An amusing find was shared today by the user fj333 with Reddit . Analyzing Qualcomm Technologies' proprietary code for Android, which appeared one year ago, he found that an unknown programmer decided to use the sorting with a bubble in production-code in order to find ... maximum in the array.

You can view the original file by under the link to Github or under the cut, and any owner of the device with Qualcomm Snapdragon 200 MSM8610 running Android can estimate it in operation.

As anyone who is familiar with sorting algorithms knows, sorting by a bubble is an educational algorithm, and in industrial code it is usually not used due to its inefficiency ; The matter is that in the worst and average cases it has the complexity O (n2) , besides its capacitive complexity in this case - O (n) . Whom it was not convinced - to use the sorting by a bubble does not recommend even Barack Obama .

And this is all not taking into account the fact that to search for the maximum would be enough and a simple search.
v1d0q 22 september 2017, 14:54

image
In this series of articles, I'll talk about the internal Android device - about the boot process, about the contents of the file system, about Binder and Android Runtime, about what they consist of, how the applications are installed, running, interacting with each other, about the Android Framework, and on how Android provides security.
kleop 21 september 2017, 14:37

"I experimented with the tasks of the cubic representation in the style of the previous work of Andrew and Richard Guy. The numerical results were amazing ... "( comment on MathOverflow)
That's how the retired mathematician Allan MacLeod came across this equation several years ago. And it's really very interesting. Honestly, this is one of the best Diophantine equations I've ever seen, but I did not see very many of them.

I found it when it began to spread like a network-nesting picture-pseudomem, invented by someone's ruthless mind ( Sridhar , was it you?). I did not understand right away what it is. The picture looked like this:

image
"95% of people will not solve this riddle. Can you find positive integer values? "

You probably already saw similar pictures-memes. It's always the cleanest rubbish, clickbites: "95% of MIT graduates will not decide it!". "She" is some stupid or poorly formulated task, or a trivial warm-up for the brain.

But this picture is completely different . This meme is a clever or malicious joke. Approximately 99.999995% of people have not the slightest chance to solve it, including a good part of mathematicians from leading universities that do not deal with the theory of numbers. Yes, it is solvable, but at the same time it is really complicated. (Incidentally, it was not invented by Sridhar, more precisely, not completely.) See the story in this comment ).

You might think that if nothing else helps, then you can just make the computer solve it. It is very simple to write a computer program to find solutions to this seemingly simple equation. Of course, the computer will find them sooner or later, if they exist. Big mistake . Here the method of simple computer enumeration will be useless.
xially 20 september 2017, 13:56

In this article, we'll talk about the "magic" constant 0x5f3759df, which lies at the heart of the elegant algorithmic trick for quick calculation of the inverse square root .

Here is the complete implementation of this algorithm:

float FastInvSqrt(float x) {
float xhalf = 0.5f * x;
  int i = * (int *) & x; // represent the float bits as an integer
  i = 0x5f3759df - (i >> 1); // what the hell is going on here ?
x = *(float*)&i;
x = x*(1.5f-(xhalf*x*x));
return x;
}
This code calculates some (fairly good) approximation for the formula

image

Today, this implementation is already well known, and it became so after the appearance in the code of the game Quake III Arena in 2005. Her creation was once attributed to John Carmack, but it turned out that roots go much further - to Ardent Computer , where in the mid-80s it was written by Greg Walsh. Specifically, the version of the code that is shown above (with funny comments) is really from the Quake code.
In this article we will try to understand this hack, mathematically derive this very constant and try to generalize this method to calculate arbitrary degrees from -1 to 1.

Yes, it will take a bit of math, but the school course will be more than enough.
xially 19 september 2017, 9:34
1 2 3 4 5 6 7 ...