• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

143 Neutral

About AntP

  • Rank
  1.   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!
  2. 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.:   Detect input to destroy tile. Gamestate is updated - tile is removed and all tiles are shifted down. Gamestate notifies view of state change for each tile. 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.
  3. I'm looking at writing a simple iOS game. I'm a .NET developer by trade but have only ever dabbled in writing games before. The game I'm writing is a relatively straightforward tile-based puzzle game. Since I have little experience of videogame architectures, I've done some Googling around for similar open source games and tutorials, to find out what the common design patterns are. I am looking, in particular, for the way the relationship between the physical, visual entities and their abstract, logical counterparts is managed. What I tend to see is something like this (pseudocode):   class Tile { public int PosX; public int PosY; public string Value; public SpriteClass Sprite; }   Now, when I see this, my architectural brain tells me that something smells bad. Tile is, in this instance, a logical representation of the individual Tile on a board. Its X and Y coordinates are graph coordinates, rather than physical screen coordinates. Its "physical" counterpart is its Sprite property.   I can't help but feel that Sprite should not - in fact - be managed by Tile at all, but that Tile should be exposed to some kind of independent manager that interprets the Tile object's position and creates the appropriate Sprite object, removing this tight coupling and making the Tile and the Sprite completely ignorant of each other.   Are my concerns unfounded? Is the above common practice in well-architected games? If not, can anyone provide any insight, tutorials or examples of a better way of managing the relationship between the physical and the logical?  
  4. [quote name='simshon' timestamp='1317820901' post='4869392'][b]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,[/b] [b]how i can improve this maybe?[/quote][/b] How about: [pre]fitness = fitnessBeforeCollisions / timeInContactWithWalls[/pre]
  5. 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.
  6. "Mouse Tail" Geometry

    Hi, I have a simple sprite to represent a mouse and behind the mouse are a chain of overlapping circles to represent the mouse's tail. I currently have the following update method for the mouse and its tail: [code] public void Update() { Velocity.X = (float)Speed * (float)Math.Cos(Angle); Velocity.Y = (float)Speed * (float)Math.Sin(Angle); if ((Position.Y + Velocity.Y < StageHeight - 24) && Position.Y + Velocity.Y > 0) { Position.Y += Velocity.Y; } if ((Position.X + Velocity.X < StageWidth - 24) && Position.X + Velocity.X > 0) { Position.X += Velocity.X; } // Update tail positions { Tail[0].Position.X = 8 + Position.X - 12 * (float)Math.Cos(Angle); Tail[0].Position.Y = 8 + Position.Y - 12 * (float)Math.Sin(Angle); for (int i = 1; i < Tail.Count; i++) { Tail[i].Position.X = Tail[i - 1].Position.X - 4 * (float)Math.Cos(Tail[i - 1].Angle); Tail[i].Position.Y = Tail[i - 1].Position.Y - 4 * (float)Math.Sin(Tail[i - 1].Angle); } Tail[0].Angle = Angle; for (int i = Tail.Count - 1; i > 0; i--) { Tail[i].Angle = Tail[i - 1].Angle; } }[/code] Tail is an ArrayList of TailSegment objects, which are basically just simple sprites. This has the effect of curling the tail nicely as the mouse moves and turns, but it has a couple of problems. Particularly when the mouse is moving slowly or is stationary, turning causes the tail to whip around and end perfectly straight as this code results in the tail being lined up behind a mouse after Tail.Count frames. I'd like the tail to move a little more realistically with respect to the movement of the mouse, so turning on the spot or stopping while turning will leave the tail curved, the tail will straighten up more gently if the mouse is moving slowly etc., but as I think about it it starts to sound a little more complex than I initially thought. Can anyone help point me in the right direction when it comes to modelling something like this? Thanks.
  7. 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.
  8. Why would you expect -1 % 5 to equal 4?
  9. Where to start?

    This reminds me of the time when I took a cow to Ascot and said, "I want to enter a race. How do I ride this thing?"
  10. Programming for babies.

    Buy this: http://www.amazon.co.uk/Beginning-Python-Novice-Professional-Professionals/dp/1590599829/ref=sr_1_1?ie=UTF8&s=books&qid=1282576577&sr=8-1 Problem solved.
  11. Trouble with A* Pathfinding

    I don't really have time to look through all that code (seems like a lot for a straightforward A* execution) but I will point out that A* is only guaranteed to produce an optimal path if it uses an admissible heuristic, which, if diagonal movement is allowed, neither straight line distance nor Manhattan distance are.
  12. Get the factorial of a number

    Quote:Original post by dmatter You either need some kind of big-num construct that won't overflow with massive factorials or, perhaps most simply, something like this: *** Source Snippet Removed *** I'm guessing that this is beyond the scope of the exercise in the book, somehow.
  13. Get the factorial of a number

    That is a perfectly sound way of calculating a factorial, yes. Another (arguably more elegant) way is to use recursion: int factorial(int in) { if (in > 1) return (in*factorial(in-1)); else return 1; } Although, while this is a little neater, it's actually less spatially-efficient due to the fact that each recursive call requires extra memory.
  14. why B/W heightmaps (not color)

    Quote:Original post by Bromordra Think about it, at the kind of resolution you're talking about, r=24, b=5, g=3 would be 60,025 less units of height than 24,5,4, but to my eyes, those are the exact same color, which really hurts usability. This. With increments in each colour representing wildly differing changes in height it would be impossible to work with.
  15. Data duplication

    Pass references to corresponding Rigid_body instances instead of copying the values across?
  • Advertisement