Game Development Reference
In-Depth Information
Did you notice that the commands sent from the human view and the AI view to the
game logic are exactly the same? While it might take a little more thinking to con-
vince yourself that the inputs to the game view, namely the game status and game
events, are exactly the same, I assure you it is true.
I mentioned before that this game architecture is flexible. You
ve probably already
surmised that a particular game logic can have any number of views, both human
and AI. If the interfaces for the human and AI views are exactly the same, it is a
trivial matter to swap a human player, or even all human players, with AI players.
But wait, it gets better.
You could create a special DVR game view that does nothing but record game events
into a buffer and play them back. In a sense, the game logic is entirely short circuited,
but since the game state changes and events are exactly the same, they can be pre-
sented in the DVR view with very little recoding. Of course, if you want a rewind
feature, you
'
'
ve got some extra work to do because the game events don
'
t necessarily
go equally back in time as they go forward!
You could also create a special game view that forwards game status and events to a
remote player across the Internet. Think about that: The game logic doesn
t have to
care whether the players are local or separated by thousands of miles. The remote
view should be pretty smart about collecting game states and events, compressing
them into as few bytes as possible, and shipping them via TCP or UDP to the remote
player. The game commands received from the remote player should go through a
verification filter, of course. You can never be too sure about remote players, or
remote game logics, for that matter.
One thing to note
'
players with different views can be advantaged or disadvan-
taged. For example, those who play on 4:3 screens can
tseequiteasmuchas
those playing on 16:9 screens. Taken a step further, you can easily see that any dif-
ferences in view definitions can give any consumer of that view a huge edge or take
it away. Be cautious with your view definitions, whether it has to do with some-
thing obvious like screen size or the types of events the view receives from the game
logic.
I hope I ' ve convinced you that this architecture is a good way to go. I ' ll be quite hon-
est and tell you that it isn
'
'
t an easy architecture to code, especially at first. You
'
ll go
through a phase where you are sure there is an easier way, and you
ll want to aban-
don this event-driven architecture where game logic is completely separate from the
view. Please be patient and resist the urge. Given some time, you ' ll never go back to a
simpler, but less flexible design.
'
Search WWH ::




Custom Search