Jump to content

  • Log In with Google      Sign In   
  • Create Account


AntP

Member Since 09 Jan 2010
Offline Last Active Jun 02 2013 03:06 PM

Posts I've Made

In Topic: Separation of concerns in game architecture

30 May 2013 - 02:38 PM

I think AntP is suggesting that the tile's position on the game board is part of the model, but the sliding/dropping animation might just be considered part of the graphical representation of the underlying game state - a transitioning animation between two game states.

 

Precisely this. What matters to the gamestate are the board coordinates of each tile; the model should not be concerned with how the state - or changes in state - are represented, so the physical screen coordinates are the responsibility of the view (the view being a logical abstraction of the actual rendered information). In theory, I should be able to plug in a completely different view without the gamestate model knowing any different.

 

It seems that it might not be possible (or - at least - conceptually straightforward) to separate these concerns completely in this case. Your first suggestion is something I was beginning to conclude myself, in that this not being a strictly turn-based game might mean that it is insufficient to store simple grid coordinates for each tile. For example, move 2 can be initiated while move 1 is still "in progress." Supposing move 1 causes a large "cascade" of tiles dropping, scoring, breaking, dropping... for multiple iterations, a second move initiated by the player long before move 1 is complete might actually affect the outcome of move 1 if some tile that would be destroyed later in move 1's tile cascade is prematurely removed by an earlier iteration of move 2's cascade.

 

With this in mind, controlling the transition speed in the view would mean that a theoretically read-only representation of the gamestate could actually directly influence the way a set of moves plays out. This suggests that a coordinate-based gamestate model is insufficiently dynamic and that I do - in fact - need to make real-time positioning a part of my model. It seems that my current domain model is limited to a turn-based incarnation of what I want, where moves are completed one at a time and I could simply prevent the view from accepting further input until it has finished animating the previous move.

 

Thanks - this has provided real food for thought!


In Topic: Separation of concerns in game architecture

26 May 2013 - 04:04 AM

Thanks for the responses, all. I've decided to go ahead and use logical "Board" and "Tile" classes that are independent of their visual representations and hold the gamestate in an abstracted layer in its entirety.

 

This does lead me to another question, though.

 

Suppose my game has a Bejeweled-like mechanism in which a tile can be destroyed and all of those above it must drop. Then, again, in a manner similar to Bewjeled (or even Tetris), the tiles surrounding the "moved" tiles are checked for some match-3-esque 'success' condition and, based on this, points are scored and flashed on-screen at the point at which they were scored (probably with a random offset) and the cycle then repeats - checking success conditions, destroying tiles, dropping them and so on until no success condition is found.

 

I am having trouble envisaging how to implement this with the MVC/observer pattern, i.e.:

 

  1. Detect input to destroy tile.
  2. Gamestate is updated - tile is removed and all tiles are shifted down.
  3. Gamestate notifies view of state change for each tile.
  4. View "slides" each tile down (including the new tile at the top).

Now, the problem I'm having is that - after the tiles are moved - the gamestate should also be checking if there are any success conditions and repeat the point-scoring process. But how do I make sure the view "keeps up" with these changes? I can't make the gamestate wait for the view because that would make the model dependent upon the view. Do I just let the gamestate steam on ahead, notifying the view as it goes and then queue updates up in the view? But this seems like - because the gamestate and view are out of sync - it will cause problems where a second "move" is taken before the tiles have finished dropping and breaking for the first one (as I'd like the player to be able to complete moves elsewhere on the board while the "chain" of moves is still occurring for their first move).

 

Alternatively, do I simply perform one iteration of point checking with the gamestate and then let it exist in an invalid state until the controller says, "hey, the view's done, check your points again?"

 

Thanks.


In Topic: train neural network with genetic algorithms

06 October 2011 - 08:15 PM

this situation cant be,because it the car collides i dont allow to move the car into the wall, so from the step the car collide ,it will continue to collide till end of the generation,
how i can improve this maybe?



How about:

fitness = fitnessBeforeCollisions / timeInContactWithWalls

In Topic: Theory - ultimate AI, at atomic level

09 September 2011 - 06:13 PM

I would suggest that an atomic representation of a brain is entirely unnecessary (for the purposes of artificial intelligence) when it is theoretically possible to create a completely functional model of the brain at a cognitive/architectural level. What we lack is a sufficient understanding of said architecture (and, more trivially to a theoretical discussion, sufficient storage). In fact neural modelling seems to be more useful as an aid in neuroscience research than in artificial intelligence research.

In Topic: Does anyone know how modulus (%) in Java works?

06 September 2010 - 02:13 AM

Quote:
Original post by Hodgman
Hmm. The way I've always simulated it is to divide -1 by 5, take the fractional part and multiply it by 5, which gives me Java's result.
However, wikipedia says "When either a or n are negative, this naive definition breaks down and many programming languages differ in how these values are defined" among other things.


This is the definition I had always assumed, too. It seems that the ACTUAL definition, is something along the lines of:

(a % n) is defined as the amount by which a exceeds the largest multiple k of n such that k <= a.

k, in this case, would be -5, meaning that a % n = 5 - 1 = 4.

Interesting. Though, from the Wiki article, it seems that the vast majority of languages use Java's definition.

PARTNERS