www.digitalmars.com         C & C++   DMDScript  

digitalmars.empire - The computer has no special advantages - yeah right!

reply Stewart Gordon <smjg_1998 yahoo.com> writes:
 From the help file:

"The computer operated players play by the same rules and under the same 
conditions that you do. It has no special advantages, though it may 
appear otherwise at times."

This doesn't seem right.  Firstly, because computers are much faster 
than humans at processing information, the computer can often complete 
several turns in the time it takes the human player to make one move. 
This can be seen by observing that human player is almost constantly ten 
or eleven turns behind the computer-controlled players.  (One 
improvement in my current working version is to bring the turn counters 
properly into view, as they were presumably meant to be.)

Secondly, to add to this effect, it appears that a computer player's 
timeslice corresponds to the time it takes the computer to think of a 
move to make.  On the other hand, the human's timeslices consist merely 
of looking to see if the player has pressed a key and then processing 
it, and are therefore much smaller than the computer's timeslices.

Moreover, am I imagining it, or does the same computer opponent 
sometimes attack two of my units before my move is accepted?  I can't 
see why this would be happening - it would appear on looking at the code 
that in one timeslice, the program receives no more than one move, be it 
from human or computer.

There ought to be a way of making the game fairer from this point of 
view.  MFH claims to have made the improvement "avoiding 100% CPU load". 
  It would be interesting to see how this is implemented, and whether it 
is any step towards this.

I guess a possible approach is to use threads to implement the AI, and 
thereby do away with timeslices.  Of course, it would be necessary to 
design the mechanism for processing the moves to avoid collisions 
between players' moves.  One possibility, on Windows at least, is to use 
a custom message to post the computer's moves to the message queue along 
with the keystrokes that constitute the human's moves.  And so that it 
plays at a more humanistic speed, the AI threads could pause briefly 
before making each move.  Of course, it would take some thinking to 
decide how long the delay should be....

This isn't something I plan to implement right now.  I suppose it would 
be worth seeing MFH's work before coming to any decision on what to do.

Stewart.

-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/M d- s:-  C++  a->--- UB  P+ L E  W++  N+++ o K-  w++  O? M V? PS- 
PE- Y? PGP- t- 5? X? R b DI? D G e++++ h-- r-- !y
------END GEEK CODE BLOCK------

My e-mail is valid but not my primary mailbox.  Please keep replies on 
the 'group where everyone may benefit.
Jul 25 2006
next sibling parent reply Sean Kelly <sean f4.ca> writes:
Stewart Gordon wrote:
  From the help file:
 
 "The computer operated players play by the same rules and under the same 
 conditions that you do. It has no special advantages, though it may 
 appear otherwise at times."
 
 This doesn't seem right.  Firstly, because computers are much faster 
 than humans at processing information, the computer can often complete 
 several turns in the time it takes the human player to make one move. 
 This can be seen by observing that human player is almost constantly ten 
 or eleven turns behind the computer-controlled players.  (One 
 improvement in my current working version is to bring the turn counters 
 properly into view, as they were presumably meant to be.)
But this is a turn-based game. How can the computer opponents (of which there are several) possibly get more turns than the player?
 Secondly, to add to this effect, it appears that a computer player's 
 timeslice corresponds to the time it takes the computer to think of a 
 move to make.  On the other hand, the human's timeslices consist merely 
 of looking to see if the player has pressed a key and then processing 
 it, and are therefore much smaller than the computer's timeslices.
I'm not sure I understand. Do turns automatically expire if you take too long to press a button? I've never seen this happen.
 I guess a possible approach is to use threads to implement the AI, and 
 thereby do away with timeslices.
I suppose if you want the computer to constantly 'think' in the background this might make sense. Though it's worth mentioning that modern versions of this game such as Civilization still use timeslices. Sean
Jul 25 2006
next sibling parent reply Stewart Gordon <smjg_1998 yahoo.com> writes:
Sean Kelly wrote:
<snip>
 But this is a turn-based game.  How can the computer opponents (of which 
 there are several) possibly get more turns than the player?
Read the code and the documentation. It's a cross between a turn-based game and a real-time strategy game. It took me a while to make sense of it too.
 Secondly, to add to this effect, it appears that a computer player's 
 timeslice corresponds to the time it takes the computer to think of a 
 move to make.  On the other hand, the human's timeslices consist 
 merely of looking to see if the player has pressed a key and then 
 processing it, and are therefore much smaller than the computer's 
 timeslices.
I'm not sure I understand. Do turns automatically expire if you take too long to press a button? I've never seen this happen.
No. Look at the unusual message loop and the functions it calls. You'll see that it polls each player in turn to see if a move has been entered. Each player has his/her/its own turn counter. When any player is 11 turns ahead of any other, it simply stops giving the ahead player timeslices for the time being. When I bring out my latest version, you will be able to see this for yourself more clearly. And you will see that, because the computer can play much faster, your turn number will usually be 10 or 11 behind that of your opponents.
 I guess a possible approach is to use threads to implement the AI, and 
 thereby do away with timeslices.
I suppose if you want the computer to constantly 'think' in the background this might make sense. Though it's worth mentioning that modern versions of this game such as Civilization still use timeslices.
You mean think while waiting for the opponent to move? I'm surprised if even the newer Civ incarnations implement this by timeslices. Is this why even turn-based games often stipulate a minimum processor speed - so that the AI can keep up with the human brain? Stewart. -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/M d- s:- C++ a->--- UB P+ L E W++ N+++ o K- w++ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++++ h-- r-- !y ------END GEEK CODE BLOCK------ My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Jul 26 2006
parent reply Sean Kelly <sean f4.ca> writes:
Stewart Gordon wrote:
 Sean Kelly wrote:
 <snip>
 But this is a turn-based game.  How can the computer opponents (of 
 which there are several) possibly get more turns than the player?
Read the code and the documentation. It's a cross between a turn-based game and a real-time strategy game. It took me a while to make sense of it too.
Crazy.
 I guess a possible approach is to use threads to implement the AI, 
 and thereby do away with timeslices.
I suppose if you want the computer to constantly 'think' in the background this might make sense. Though it's worth mentioning that modern versions of this game such as Civilization still use timeslices.
You mean think while waiting for the opponent to move? I'm surprised if even the newer Civ incarnations implement this by timeslices. Is this why even turn-based games often stipulate a minimum processor speed - so that the AI can keep up with the human brain?
I'm not actually certain how Civ works at a code level, but the player and all computer opponents are given an actual turn in which to do whatever. Late in the game the computer turns tend to take at least a few seconds to complete so I suspect much of the work occurs then. Sean
Jul 27 2006
parent Stewart Gordon <smjg_1998 yahoo.com> writes:
Sean Kelly wrote:
 Stewart Gordon wrote:
<snip>
 You mean think while waiting for the opponent to move?  I'm surprised 
 if even the newer Civ incarnations implement this by timeslices.  Is 
 this why even turn-based games often stipulate a minimum processor 
 speed - so that the AI can keep up with the human brain?
I'm not actually certain how Civ works at a code level, but the player and all computer opponents are given an actual turn in which to do whatever. Late in the game the computer turns tend to take at least a few seconds to complete so I suspect much of the work occurs then.
Indeed. I'd never had any impression that in Civ the computer thinks ahead, but I suppose it's easily possible. I imagine that most modern games would use threads to implement it. Indeed, most modern strategy games probably have the computer's thinking always in a thread separate from the main execution thread, so that the program doesn't go into a "not responding" state for seconds or minutes at a time. Stewart. -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/M d- s:- C++ a->--- UB P+ L E W++ N+++ o K- w++ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++++ h-- r-- !y ------END GEEK CODE BLOCK------ My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Jul 27 2006
prev sibling parent reply Walter Bright <newshound digitalmars.com> writes:
Sean Kelly wrote:
 But this is a turn-based game.  How can the computer opponents (of which 
 there are several) possibly get more turns than the player?
Empire was designed to run on a PDP-10, which ran like molasses relative to today's PC. Allowing some "hysteresis" on the turns made for a smoother playing experience.
Jul 27 2006
parent Sean Kelly <sean f4.ca> writes:
Walter Bright wrote:
 Sean Kelly wrote:
 But this is a turn-based game.  How can the computer opponents (of 
 which there are several) possibly get more turns than the player?
Empire was designed to run on a PDP-10, which ran like molasses relative to today's PC. Allowing some "hysteresis" on the turns made for a smoother playing experience.
Makes sense. I'll admit I do remember people playing Empire on Sun or perhaps DEC machines ages ago, but I somehow dodged the addiction until only recently ;-) Sean
Jul 27 2006
prev sibling next sibling parent Stewart Gordon <smjg_1998 yahoo.com> writes:
While debugging, I stumbled upon another bug that might give the 
computer an unfair advantage.  At the beginning of the game, before the 
first unit has been built, computer players advance one turn per 
timeslice, and the human player advances one turn every two timeslices. 
  This could be just what I can see at the moment of yet another cause 
of the computer's turns advancing more quickly.  OK, so the significance 
of this will lessen as the game progresses and there are more units to 
manoeuvre, but it's still there.

Stewart.

-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/M d- s:-  C++  a->--- UB  P+ L E  W++  N+++ o K-  w++  O? M V? PS- 
PE- Y? PGP- t- 5? X? R b DI? D G e++++ h-- r-- !y
------END GEEK CODE BLOCK------

My e-mail is valid but not my primary mailbox.  Please keep replies on 
the 'group where everyone may benefit.
Jul 27 2006
prev sibling parent reply Walter Bright <newshound digitalmars.com> writes:
Stewart Gordon wrote:
  From the help file:
 
 "The computer operated players play by the same rules and under the same 
 conditions that you do. It has no special advantages, though it may 
 appear otherwise at times."
 
 This doesn't seem right.  Firstly, because computers are much faster 
 than humans at processing information, the computer can often complete 
 several turns in the time it takes the human player to make one move. 
 This can be seen by observing that human player is almost constantly ten 
 or eleven turns behind the computer-controlled players.  (One 
 improvement in my current working version is to bring the turn counters 
 properly into view, as they were presumably meant to be.)
The fact that the computer is smarter than you is a perfectly fair advantage!
Jul 27 2006
next sibling parent reply Sean Kelly <sean f4.ca> writes:
Walter Bright wrote:
 Stewart Gordon wrote:
  From the help file:

 "The computer operated players play by the same rules and under the 
 same conditions that you do. It has no special advantages, though it 
 may appear otherwise at times."

 This doesn't seem right.  Firstly, because computers are much faster 
 than humans at processing information, the computer can often complete 
 several turns in the time it takes the human player to make one move. 
 This can be seen by observing that human player is almost constantly 
 ten or eleven turns behind the computer-controlled players.  (One 
 improvement in my current working version is to bring the turn 
 counters properly into view, as they were presumably meant to be.)
The fact that the computer is smarter than you is a perfectly fair advantage!
The most difficult aspect of AI programming isn't making one that can soundly beat a human opponent, but making one that will be engaging and challenging and make "realistic" mistakes. But this rule is just one more that the player must adapt to, and I suspect a seasoned player could play quickly enough to keep up with the computer, given realistic timeslices. Sean
Jul 27 2006
parent reply Walter Bright <newshound digitalmars.com> writes:
Sean Kelly wrote:
 Walter Bright wrote:
 Stewart Gordon wrote:
  From the help file:

 "The computer operated players play by the same rules and under the 
 same conditions that you do. It has no special advantages, though it 
 may appear otherwise at times."

 This doesn't seem right.  Firstly, because computers are much faster 
 than humans at processing information, the computer can often 
 complete several turns in the time it takes the human player to make 
 one move. This can be seen by observing that human player is almost 
 constantly ten or eleven turns behind the computer-controlled 
 players.  (One improvement in my current working version is to bring 
 the turn counters properly into view, as they were presumably meant 
 to be.)
The fact that the computer is smarter than you is a perfectly fair advantage!
The most difficult aspect of AI programming isn't making one that can soundly beat a human opponent, but making one that will be engaging and challenging and make "realistic" mistakes. But this rule is just one more that the player must adapt to, and I suspect a seasoned player could play quickly enough to keep up with the computer, given realistic timeslices.
A lot of game AIs make up for their general suckiness by cheating. Empire's AI doesn't cheat. The 10 turn hysteresis makes things a little more interesting by giving a pseudo-realtime effect, but it doesn't confer any significant or lasting advantage to any player. The hysteresis also applies when you have multiple humans playing.
Jul 27 2006
parent reply Stewart Gordon <smjg_1998 yahoo.com> writes:
Walter Bright wrote:
<snip>
 A lot of game AIs make up for their general suckiness by cheating. 
 Empire's AI doesn't cheat. The 10 turn hysteresis makes things a little 
 more interesting by giving a pseudo-realtime effect, but it doesn't 
 confer any significant or lasting advantage to any player.
Of course, with the speed of today's machines, this pseudo-realtime effect ain't what it used to be. And it may not be a _significant_ advantage, but to claim it's _no_ advantage is silly.
 The hysteresis also applies when you have multiple humans playing.
How does one do this? Or should I ask: Which platform versions have or have ever had such a facility? Stewart. -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/M d- s:- C++ a->--- UB P+ L E W++ N+++ o K- w++ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++++ h-- r-- !y ------END GEEK CODE BLOCK------ My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Jul 28 2006
parent Walter Bright <newshound digitalmars.com> writes:
Stewart Gordon wrote:
 Walter Bright wrote:
 <snip>
 A lot of game AIs make up for their general suckiness by cheating. 
 Empire's AI doesn't cheat. The 10 turn hysteresis makes things a 
 little more interesting by giving a pseudo-realtime effect, but it 
 doesn't confer any significant or lasting advantage to any player.
Of course, with the speed of today's machines, this pseudo-realtime effect ain't what it used to be. And it may not be a _significant_ advantage, but to claim it's _no_ advantage is silly.
It really is no advantage.
 The hysteresis also applies when you have multiple humans playing.
How does one do this? Or should I ask: Which platform versions have or have ever had such a facility?
The PC game does - you can connect other players with the serial port.
Jul 28 2006
prev sibling parent reply Stewart Gordon <smjg_1998 yahoo.com> writes:
Walter Bright wrote:
 Stewart Gordon wrote:
  From the help file:

 "The computer operated players play by the same rules and under the 
 same conditions that you do. It has no special advantages, though it 
 may appear otherwise at times."

 This doesn't seem right.  Firstly, because computers are much faster 
 than humans at processing information, the computer can often complete 
 several turns in the time it takes the human player to make one move. 
 This can be seen by observing that human player is almost constantly 
 ten or eleven turns behind the computer-controlled players.  (One 
 improvement in my current working version is to bring the turn 
 counters properly into view, as they were presumably meant to be.)
The fact that the computer is smarter than you is a perfectly fair advantage!
Smartness is one thing. Speed is another. And if the speed is such that keeping up is well and truly beyond human capability, such as being able to make a million moves within the fastest human's reaction time, you can hardly call it fair except in a _purely_ turn-based game or an implementation designed purely to test computers to the limit. OTOH most games that are released to the public are designed to give us mere mortals a fair challenge. This is also why a lot have multiple skill levels. That said, it gets worse. If you've ever played Duke Nukem 3D in DukeMatch mode, you may have noticed the computer-controlled opponents striking with such speed and accuracy that most human players would never dream of. Sometimes they'd even launch an RPG such that it kills you when they've barely even had time to see that you're there. And no, they're not just firing continuously. Stewart. -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/M d- s:- C++ a->--- UB P+ L E W++ N+++ o K- w++ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++++ h-- r-- !y ------END GEEK CODE BLOCK------ My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Jul 28 2006
parent Walter Bright <newshound digitalmars.com> writes:
Stewart Gordon wrote:
 Walter Bright wrote:
 Stewart Gordon wrote:
  From the help file:

 "The computer operated players play by the same rules and under the 
 same conditions that you do. It has no special advantages, though it 
 may appear otherwise at times."

 This doesn't seem right.  Firstly, because computers are much faster 
 than humans at processing information, the computer can often 
 complete several turns in the time it takes the human player to make 
 one move. This can be seen by observing that human player is almost 
 constantly ten or eleven turns behind the computer-controlled 
 players.  (One improvement in my current working version is to bring 
 the turn counters properly into view, as they were presumably meant 
 to be.)
The fact that the computer is smarter than you is a perfectly fair advantage!
Smartness is one thing. Speed is another. And if the speed is such that keeping up is well and truly beyond human capability, such as being able to make a million moves within the fastest human's reaction time, you can hardly call it fair except in a _purely_ turn-based game or an implementation designed purely to test computers to the limit. OTOH most games that are released to the public are designed to give us mere mortals a fair challenge. This is also why a lot have multiple skill levels.
You shouldn't have any trouble beating the Empire AI. 10 moves isn't going to make any difference.
Jul 28 2006