Jump to content
  • Advertisement

AfroFire

Member
  • Content Count

    492
  • Joined

  • Last visited

Community Reputation

471 Neutral

About AfroFire

  • Rank
    Member
  1. AfroFire

    I need coding help please!

    It looks to me like your min and max are not initialized (and thus default to zero)? The seeming consequent of this is that your rightEdgeOfFormation > max is always true, which means that movingRight is false, which means that movingLeft is always true, and that you will thus always be seeming to move left. 
  2. AfroFire

    I am going to start making games

    So, how far did you get?
  3. Checking out GD.Net after being offline for a long while.
  4. I'm new to this too, and this may be more of a bump, but with that said: I've found that designing as much as you can, then when you inevitably can't do that any longer: code. USUALLY the code reignites the passion to design.
  5. I get it!   Thank you for your efforts Paradigm Shifter!   Time for me to whip my e-penis out: Alvaro, my own history on Gamedev extends back to 2000/2001, and it is because of this site that more than a decade later I have two degrees (physics and computer science) and work at a company that EVERYONE knows about. Even your grandmother. You do not know who I am, or who I work with. Your solutions may be correct, but the attitude that you deliver them with is off-putting. I'm probably coming at you a little hard, but it is only because this sense of friction I've always felt when getting 'help' from the so-called 'experts' of GameDev. They're what make this site, and also what ruin it. Anyways, being an expert in this field now means that it is my responsibility to "stand up" to others when they are not making sense, and to make certain that clarity is achieved.    Finally, "You should only believe what I say because it's convincing." -- Which is what I am trying to do. I did NOT find it convincing.   "But I have a decent track record of getting things right." - I don't even know who you are. Why would I know that you have a history of getting it right? You're just a name in an HTML table to me.   "The reputation score in these forums is an imperfect indication of that." -- It's a horrible way to reason that your idea makes sense. At the risk of sounding tautological : The idea makes sense when feel I can implement it. Your reputation is irrelevant.    "For people that have been around here long enough, they probably [hopefully] have had good experiences with my suggestions before" -- Again: Irrelevant to my understanding.   " It's rather annoying that you would claim it can't be done with 49 bits when I think I just explained how it's done." --. I never claimed that it "can't be done", I said "I don't think 49 is enough bits. 56 sounds right though. Unless I am missing something..." which is a lot less than a 'claim' that "This can't quite possibly be done with 49 bits, you faker!"     Please don't vilify me for simply challenging your claims explicitly - just try to make them clearer. If you're as awesome as you think you are, then helping me understand shouldn't take much effort. 
  6. AfroFire

    Academia

    I came to provide some reason to this thread, but I see it has enough already.   Note: There is some serious physics simulation software (see GADGET-2) that has some horribly named variables. It's very readable to a physicist, but makes a CS major bawl. Different area, different rules.   To state the obvious: There just isn't a 'global' set of rules on how we should name variables, even something like 'readability' and understandability differs from group to group. Physics equations fall apart when you start naming things "velocity_x" and then using it all over the place and being able to find an error in the code gets worse the less it looks like an equation and the more like code it looks. Tracking down these kinds of errors is a bitch.   But as someone reasonably stated: The wider the scope, the longer the name should be. Or, fuck, leave a comment that says "Look up the equation in such and such's paper, or book on page x"
  7. No, the bitboard-based representation most likely will consist of two bitboards, one per player, as I showed in the piece of code above (I would probably use an array of 2 bitboards instead of calling them `white' and `black'). The function to hash it could then be the one I posted called `encode'.   Meeehhhh   They're approximately the same. He just uses up an extra top row.   Additionally, you're saying "In each column the highest-set bit tells you how many pieces are in that column" -- one bit can only tell you a maximum of 0-1. You need the highest 3 bits to keep track of the next empty space. I don't think 49 is enough bits. 56 sounds right though. Unless I am missing something...     I don't think you understood what I was saying. "The highest-set bit" means "which bit is the highest one that is set". That is not a single bit of information. 49 bits works just fine. You shouldn't take anyone as an authority on anything, but I have done this type of thing before and I know what I am talking about, so your prior should be that I am probably correct and you need to think about it a little bit more.   Your advice is confusing. I shouldn't call anyone an authority but I should implicitly trust you based on the fact that I don't even know you?   Anyways, this is a place where we should be trying to clarify. I am still not understanding your approach. If we marked the highest bit with a single 1, we couldn't differentiate between each player. If you're feeling threatened/impatient perhaps you could just link to the original implementation? I tried googling around for it, briefly, but couldn't find it.
  8. No, the bitboard-based representation most likely will consist of two bitboards, one per player, as I showed in the piece of code above (I would probably use an array of 2 bitboards instead of calling them `white' and `black'). The function to hash it could then be the one I posted called `encode'.   Meeehhhh   They're approximately the same. He just uses up an extra top row.   Additionally, you're saying "In each column the highest-set bit tells you how many pieces are in that column" -- one bit can only tell you a maximum of 0-1. You need the highest 3 bits to keep track of the next empty space. I don't think 49 is enough bits. 56 sounds right though. Unless I am missing something...
  9. I think hovermonkey and alvaro are suggesting the same solution.   First: recognize that one byte is 8 bits. Each bit is a switch that is either on or off. /* Each COLUMN is a BYTE (8 bits). The last/first (you decide) 3 bits tell you where the empty spot is (this is the parenthesis number). Since you have 3 bits, you can count from 0-7. You need 0-4 to mark where the empty spot is in the rows below. Then you can use whatever information is left to tell you what colored piece is left in the last row (once you've filled up rows 0-4). c5: (0) (0) (0) (0) (0) (0) (0) <-- extra row to mark the first empty spot. c4: 0 0 0 0 0 0 0 c3: 0 0 0 0 0 0 0 c2: 0 0 0 0 0 0 0 c1: 0 0 0 0 0 0 0 c0: 0 0 0 0 0 0 0 Zero can be white or nothing because of the number in the top. If you KNOW where the last available spot is, then you know that any zeros below that point are white pieces and you know that anything above that is empty. For example, imagine this board state: c5: (3) (4) (2) (0) (0) (0) (0) <-- extra row to mark the first empty spot. c4: 0 0 0 0 0 0 0 c3: 0 0 0 0 0 0 0 c2: 1 0 0 0 0 0 0 c1: 1 0 1 0 0 0 0 c0: 0 0 1 0 0 0 0 This is a win for the white player - Can you see why? Look at the 2nd column (the one with (4) at the top.) The 4 tells us that the free spot on this column is at c4, which means c0-c3 are all white pieces since in this case 0 is white. 1 is black. Is this clear? */
  10. "java won't let me to have a long number with 42 digits (even the LONG type).  "   A long is at most 8 bytes -- that's 64 bits. That means you can have 64 zeros or ones. However, you've stated that you need 0, 1 and 2. So we need a base 3 system. The problem with this is you'd need to take up 2 bits a piece to store 0, 1, or 2. So now you can only cram, at most, 32 bits in to a long type. The long just doesn't have enough memory to store the entire board.   There are many different solutions: For example: you could use a multidimensional array to simply store bytes. byte[][] ?   If you want a rather 'tricksy' solution, you could do what I once did in school: Create a table that holds Player 1's pieces (0 = no piece, and 1 is a piece), and create another table for Player 2's pieces (0 = no piece, and 1 is a piece). Since we're now back to using base 2 system, we can hold all of player 1's pieces in a long, and all of player 2's pieces in a long.   THEN if we want to see if we have a valid move, we can go ahead and make the move on the respective player's long and simply do a logical AND compare - if you have two values overlapping the logical AND will return true (at which point, you need to undo the move so that the board is in a valid state).   If you just want to see where the next available space is on a board, then you will logically OR/XOR the two values and anywhere there is a zero is an empty space. I'll leave the finer shifting details to you (or if you make an effort I can lend a hand).   If you want to see if a player has won after their move, if you are feeling super duper excited, you could probably create a dictionary of winning states for the board and logically AND your board against these states (you could systematically remove boards that are definitely not going to happen in a game as well, so that as the game goes on, the number of boards checked for victory goes down).   As I said, there are lots of ways to do what you're asking - this is another one :D   Additionally, if you are not too comfortable with performing bitwise operations -- look in to Java's BitSet.
  11. AfroFire

    Artifictial Society Simulation

    This is a very interesting idea. I've thought some about this as well, and as bluwind suggested: dumb down the graphics, or if you were me...throw them out entirely. What you aim to do is create a model, this is distinct from the visual representations. Try to find alternative ways to probe your data that are non visual as well (that are text based) so that you can be sure things are going right. Finally, when the model is satisfactory: add graphics.
  12. AfroFire

    Simulating a console program?

    Could you tell us what this is for? There is lots of ways to get something that "looks" like a console but functions nothing like one. Is the functionality important?
  13. typedef struct { void* array; unsigned size; } MemberInfo; void AOStoSOA(void* arraybegin, unsigned int arraycount, unsigned int arraystride, MemberInfo outarrays[], unsigned int nummembers) { char* arrayptr = (char*)(arraybegin); unsigned int i = 0; for(i = 0; i < arraycount; ++i) { unsigned offset = 0; unsigned int j; for(j = 0; j < nummembers; ++j) { int *c = arrayptr; memcpy(&(outarrays[j].array[i*outarrays[j].size]), arrayptr + offset, outarrays[j].size); offset += outarrays[j].size; } arrayptr += arraystride; } } // PACKING IS MANDATORY HERE #pragma pack(push) #pragma pack(1) typedef struct { int Test; char Blah; } Foo; #pragma pack(pop) typedef struct { int* TestArray; char* BlahArray; } SOAForm; #define COUNT 3 int main(int argc, char *argv[]) { Foo aos[COUNT]; // EXAMPLE DATA aos[0].Test = 123; aos[0].Blah = 'a'; aos[2].Test = 456; aos[2].Blah = 'd'; aos[1].Test = 789; aos[1].Blah = 'c'; SOAForm soa; soa.TestArray = malloc(sizeof(int) * COUNT); soa.BlahArray = malloc(sizeof(char) * COUNT); MemberInfo arrays[] = { { soa.TestArray, sizeof(int) }, { soa.BlahArray, sizeof(char) } }; AOStoSOA(&aos[0], COUNT, (char*)(&aos[1]) - (char*)(&aos[0]), arrays, 2); printf("Third Blah is '%c'\n", soa.BlahArray[2]); free(soa.TestArray); free(soa.BlahArray); } Here is an updated version of the code. The most important addendum was to the line: memcpy(&(outarrays[j].array[i*outarrays[j].size]), arrayptr + offset, outarrays[j].size); Where there was a problem with the destination parameter (first parameter) of the memcpy. Specifically, it was incrementing in ones when it should have been incrementing in terms of the size of the data being stored in that location. That's pretty much it though, everything else is just nit picky stuff, or the compiler I was using was unhappy with it. Thanks a whole bunch all over again Apoch.
  14. Holy shit, you are the man. This is pretty much exactly what I was going for, you took the freakin' code right out of my mind! Just out of curiosity however, you use the following to get the stride: (char*)(&aos[1]) - (char*)(&aos[0]) Why not just do sizeof(Foo), it's not likely there is padding within the array, right? Additionally, if you'd like to do the macro code it'd be mostly academic, but for people who might need something like this, it would be a good reference post. I think this would be good enough for me though, I don't even know how to convey how grateful I am. Just doing some prelim tests, I am convinced your solution works (if there are any nit picky bugs I could figure them out from here). I "liked" your posts, but I am not sure how the reputation granting works anymore, is this what reputation has become here? Thanks a million more times.
  15. Exactly. Thank you for being aware of this. I am intrigued by the offsetof(...) function however, like if I have a beer I could perhaps just take the time to type up the "offset of" command for the 50 lines of the struct I have, then use that. However, if a more generalized solution exists that'd be fantastic. The packing is also an intriguing idea, I'd have to take the time to study this I feel. To Serapth, this is posted in the For Beginners, but I am not exactly a beginner, which isn't to say that I am an all knowing programming guru... I just thought this was a basic question and that somehow the solution fell out of my brain ages ago. You guys are doing great with this post, thank you so much. Does anyone else have any ideas?
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!