Working with global variables is even more difficult because you have to keep global state in your mind all the time. When you don't really know what you're doing, global variables => guaranteed epic fail.Originally Posted by Adam Rinkleff
Working with global variables is even more difficult because you have to keep global state in your mind all the time. When you don't really know what you're doing, global variables => guaranteed epic fail.Originally Posted by Adam Rinkleff
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Can you explain, because I really don't understand. I don't really have a global state to keep track of, I think you are overestimating the amount of skill that I possess. I'm just trying to write a chess program (I'm a chess player, not a programmer), and I find that just about every function I make wants to know the color, along with about 50'000 other variables, so I've just made everything global.
When you write code, you want to be able to use the same techniques for tiny program as for large ones. Global variables are something that are somewhat easy to use in tiny programs, but for even moderately sized programs they are harder to work with. Someone can probably give you a good link to explain why in detail.
Passing variables as function arguments is easy for both large and small programs.
It is too clear and so it is hard to see.
A dunce once searched for fire with a lighted lantern.
Had he known what fire was,
He could have cooked his rice much sooner.
It looks like you do have global state. I suggest that you mitigate this by grouping variables into structs, then pass the structs around (through passing pointers to them).Originally Posted by Adam Rinkleff
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Creating a chess program that plays against you is relatively easy. Creating a chess program that plays well against you is more difficult.
The basic problem is that chess is most effectively played as a strategic game: a strategic player will easily beat a tactical player. Computers are good at doing things tactically (or repetitively searching through a set of possible tactics for a "best" option) but not generally good at strategy. Most of the programs that have beaten professional players are implemented using some combination of smart heuristics and brute-force search involving large amounts of computing power. Deep Blue, for example, was a 30-node super-computer capable of evaluating 200 million moves per second and, even then, could not consistently beat a professional chess player (Kasparov) who, as a human, presumably does not examine 200 million moves every second.
I think that a strategic player will lose to a tactical player: strategy is useless when there is no material to execute it. In practice, strategic players are also tacticians, so the notion of a purely strategic player is fantasy.Originally Posted by grumpy
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
I play an awful lot of chess, and I rather think that the debate over 'strategic' versus 'tactical' players is a little bit exaggerated. The fact of the matter is that strategy and tactics are really the same thing. Strategic players are simply very good tactical players, who are thinking a bit more deeply. Someone who says they understand strategy, but ignores tactics, is going to get crushed -- and vice-versa.
Last edited by Adam Rinkleff; 06-23-2011 at 01:58 PM.
The field of chess AI is well researched. It is not hard to create a good chess program, it's been done, and the known effective algorithms can be implemented. With modern resources it is not hard to write an AI that will beat most players.
You can tweak heuristics and the amount of game tables to beat the better players.
It is too clear and so it is hard to see.
A dunce once searched for fire with a lighted lantern.
Had he known what fire was,
He could have cooked his rice much sooner.
That sounds like an over-simplification, e.g., "thinking a bit more deeply" in the same way as one would to say calculate a combination would not necessarily work in the development of a plan as the horizon effect also applies to human players.Originally Posted by Adam Rinkleff
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)