1. Desynched

    OP Desynched GBAtemp Regular
    Member

    Joined:
    Jan 4, 2017
    Messages:
    107
    Country:
    United States
    I am implementing path finding into snakes.
    This means one thing for now:
    apples are more fair when moved. If the last people alive are in tight spots, it will place it somewhere they can get it... unless, of course, it is TOO tight, in which case it doesn't care, because you obviously goofed up.

    But, if you are in a box bigger than 20 x 20 (in any shape), it will try to place the apple somewhere you could technically get to it, if you're really good :)

    edit: this also opens the possibility up for ai opponents. However, they will probably be very, very stupid.
     
    Last edited: Jan 23, 2017
  2. Desynched

    OP Desynched GBAtemp Regular
    Member

    Joined:
    Jan 4, 2017
    Messages:
    107
    Country:
    United States
    Link to the nightly release here: https://github.com/DDews/Snakes/releases/tag/0.2.4

    So I'm releasing a nightly for 0.2.4 so people who are interested can test it out.
    The autopilot is not perfected. It employs no strategies for survival or killing others, and it doesn't keep memory of where safe places to go are.
    If it is unable to compute a pathway to the apple before it moves a "square" on the grid, it will start over on calculating.

    Right now I am trying to write code so that it remembers the previous pathway it found if it hasn't changed. This should make it so when its aimlessly running around, it will still be able to "think" every frame about where it can go... Kind of like a person, this will allow it to "think" as it moves slowly.

    You can tell if autopilot has failed to find a path in time because it will move mostly erratically, and it will slow down.

    Here is some footage of two 3ds's both using autopilot against one another:



    edit: fixing the "came from" path is proving incredibly difficult...
     
    Last edited: Jan 25, 2017
    Quantumcat likes this.
  3. Desynched

    OP Desynched GBAtemp Regular
    Member

    Joined:
    Jan 4, 2017
    Messages:
    107
    Country:
    United States
    Quick update on where I'm at so far in design.

    Soon there will be ai opponents! However, due to processing times, they won't be playable with other players.

    The apple, when moved, will continue scanning it's area until it finds a player. If it is unable to do this due to obstacles, it will teleport to a new location. This is independent of your Y usage.

    Auto pilot will be allowed, but this will forfeit your score for that round. So if you want to go afk during a round with friends but don't want to kill yourself, you can turn auto pilot on and it will auto-ready for you and play for you. You just won't be able to get a new high score this way. You can also auto pilot against an ai opponent to see which one wins. Spoiler: they will most likely move very similarly to each other, since they both use the same algorithm :P

    Other changes I plan for after this next version release:

    Improve path history by using linked lists to simplify calculations for snake length and screen score.

    Implement true TCP so that connection drops of any size will still be recoverable.

    Rewrite code so it's more modular and professional. Basically stop being lazy.

    Where I'm at as of typing this:

    Autopilot is almost done. This code will be reused for ai opponents. The code will mostly be reused for apple validation as well. Just need to make it so it realizes it's tail movement opens up new paths. I estimate to release 0.2.4 early next week if all goes well.
     
    Last edited: Jan 27, 2017
    Quantumcat and Shaker78 like this.
  4. Desynched

    OP Desynched GBAtemp Regular
    Member

    Joined:
    Jan 4, 2017
    Messages:
    107
    Country:
    United States
  5. Pickpickles

    Pickpickles Member
    Newcomer

    Joined:
    Oct 5, 2016
    Messages:
    39
    Country:
    United States
  6. Desynched

    OP Desynched GBAtemp Regular
    Member

    Joined:
    Jan 4, 2017
    Messages:
    107
    Country:
    United States
    Great! Glad someone finds it interesting. I spent a whole week ironing out the path finding :)

    So, the "ai" should stall a bit if it doesn't find a path to the apple. While it does this, if B is enabled, it will go slow, and continue to scan the screen for a path to the apple, building upon what it's scanned so far. However, if another snake crosses it's planned path, it starts over on it's path finding, starting from scratch. This happens often with multiple ai's as they tend to bunch together and cut each other off. This is why despite being designed to allow multiple ai's in one player, it defaults to just one.

    I made it never use A button as it would be way too good. I plan to leave it as a difficulty option in a later release.
     
    Last edited: Jan 28, 2017
  7. Pickpickles

    Pickpickles Member
    Newcomer

    Joined:
    Oct 5, 2016
    Messages:
    39
    Country:
    United States
    Or have the AI randomly speed up and slow down, that would be exciting.
     
  8. Quantumcat

    Quantumcat Dead and alive
    Moderator

    Joined:
    Nov 23, 2014
    Messages:
    15,114
    Country:
    Australia
    What's your background, @Desynched ? Are you a professional game developer?
     
  9. Desynched

    OP Desynched GBAtemp Regular
    Member

    Joined:
    Jan 4, 2017
    Messages:
    107
    Country:
    United States
    This is a good idea. It might make multiple ai's be a bit more unique :)

    I'm a college student, but I'm projected to graduate in spring of next year if all goes well. I've only coded a simple room server for an indie game at my friend's 3 person game company. If you look at the code for snakes you'll see a big mess, showing how amateur I am. I'm flattered you ask! Hopefully I'll find time to clean it up after this version release.
     
    Quantumcat likes this.
  10. Desynched

    OP Desynched GBAtemp Regular
    Member

    Joined:
    Jan 4, 2017
    Messages:
    107
    Country:
    United States
    tldr; The current nightly release 0.2.4.2 has faulty ai that is incapable of scanning the entire screen for paths. This will be fixed soon. If you have an idea on how to handle another options menu let me know.

    I noticed a couple bugs with the ai.

    The current nightly release doesn't properly build upon previous area scans for it's pathfinding.
    You can easily replicate this by quickly getting to the apple with a higher or tied score against Saad and die wrapped around the apple. Saad should start going on really long paths back and forth, as it chooses the farthest known path and goes to it while scanning more of the area. However, Saad just continually moves in short distances because he never builds upon his previous scanned areas. This means he currently is incapable of finding more complicated routes.

    I am fixing this and implementing a way for Saad to teleport the apple once (like anyone else can) if he can't get to the apple, and dying if he still can't get the apple after thirty seconds.

    All of this is working as I want it to on my private build, except he now doesn't properly avoid people cutting him off. While this makes him more human, it's often ... too amateur. He will sometimes suicidally move straight into your snake many seconds after you cut off his planned path, even about two full snake lengths in front of him. I ran out of time to finish fixing this today, but plan to have it fixed tomorrow. I will also be able to implement a difficulty setting for him soon, which will change how easily he avoids someone cutting him off or how easily he goes through tight spaces. The latter difficulty setting I'm not exactly sure how I'm going to efficiently implement yet, but I hope to. (crazy to think that a perfect ai is simpler to make than an imperfect one)

    I am also thinking about ways to implement game settings that will [most likely] be separate from the game modes menu (select button). I want this new menu for setting things like computer opponent difficulty, etc. I am running out of buttons for options... So I might make the select button first display a menu that you choose between the original game modes or game settings menus. I am still undecided about how to handle it. If you have a suggestion let me know.
     
    Last edited: Jan 29, 2017
    Quantumcat likes this.
  11. Desynched

    OP Desynched GBAtemp Regular
    Member

    Joined:
    Jan 4, 2017
    Messages:
    107
    Country:
    United States
    Just wanting to let you guys know where I'm at.

    I'm experiencing a bug that is proving difficult to track down. It causes the o3ds to freeze, but not the n3ds. I know it's not running out of memory, but that's all I'm sure of.

    This week I'm pretty busy with classes, so it might be a while before I'm able to fix this. I've also decided I will clean up my code in the meantime until I find the bug. So it might be a week longer before the computer opponents are released.
     
    DrFleming and Quantumcat like this.
  12. Desynched

    OP Desynched GBAtemp Regular
    Member

    Joined:
    Jan 4, 2017
    Messages:
    107
    Country:
    United States
    So I'm getting close to finding the bug.

    This is embarrassing to say as a developer, but I'm not sure what caused the problem or why this solution fixes it. Granted, I didn't have much time to work on it.

    Apparently calling the function that redraws the console at the start of one of the pathfinding functions prevents the o3ds from crashing. I'm not completely sure why this happens or why it is needed. as this function is called often anyway. The n3ds doesn't seem to mind either way. Hopefully I will learn the true root of the problem soon, but at least I found a simple solution.

    I didn't have much free time to do much on the game today, and tomorrow I have a lot of classes, so I may not be able to release the version until next week. I'm sorry about that.
     
  13. Pickpickles

    Pickpickles Member
    Newcomer

    Joined:
    Oct 5, 2016
    Messages:
    39
    Country:
    United States
    Take your time on it. After all, you're the one working on the game.
     
  14. Desynched

    OP Desynched GBAtemp Regular
    Member

    Joined:
    Jan 4, 2017
    Messages:
    107
    Country:
    United States
    So the speed of your snake will be different in this next release. The new fast speed is what the original default speed was. The default and slow speeds are adjusted to match the original ratios.

    I hate to do this, but it takes more clock cycles to do the pathfinding, so with the original speeds the game would slow down. This would make it so when the player was holding A to go fast, but the computer opponent was still pathfinding, the player would instead be going close to default speed even when holding A. Then once the computer found the path, the player would go back to fast speed and crash into a wall. I tried making it only use free clock cycles on pathfinding, but when a player went fast, there was literally nothing left to work with, causing the pathfinding to fail, making the computer opponent trivial to beat and severely flawed.

    I can't make it slower just for when people play against a bot because people can still use auto pilot in multiplayer, which would cause a desync. I decided, as well, that the previous fast speed was suicidally fast, while this new speed is more controllable.

    There may be hope for a faster game, though. I'm looking into different ways to draw to the screen, and hopefully I can find a more efficient way to draw the snakes.

    edit: This is old news - I have fixed this problem by refactoring the graphical rendering. Special thanks to Stary and fincs!

    Working on this project really showed me flaws in my programming in general, not just in coding in C. With the help of the 3ds dev community I've discovered many better ways of doing things, including code organization. If I were to redo this game, it would be much more elegant. Because of that, I plan to work on refactoring the code for the release after this next one, meaning the release after this next one will probably take much longer than the previous.

    You can expect 0.2.4 soon. I just want to make an options menu for the computer opponents as well as thoroughly test the game. Hopefully around Feb 8th it will be released. The code will not be refractored until much later.
     
    Last edited: Feb 5, 2017
    Quantumcat likes this.
  15. StarGazerTom

    StarGazerTom GBAtemp Advanced Maniac
    Member

    Joined:
    Feb 2, 2015
    Messages:
    1,935
    Country:
    Curious question, forgive me, coding noob. Why does such a simple 8bit game take so much of the 3ds's power when we've got many 3d games, ala pokemon.

    Sure'll such a huge amount of power being needed is coding issues (Just saying, no offence meant!) or is something else going on?
     
    Desynched likes this.
  16. Desynched

    OP Desynched GBAtemp Regular
    Member

    Joined:
    Jan 4, 2017
    Messages:
    107
    Country:
    United States
    To be honest, I'm not quite sure. You're right, and my code is really inefficient, or something else is going on. I haven't really begun refactoring my code, so I might find something incredibly inefficient when I do.

    My best guess is I'm doing graphics inefficiently.
     
  17. Desynched

    OP Desynched GBAtemp Regular
    Member

    Joined:
    Jan 4, 2017
    Messages:
    107
    Country:
    United States
    I found what was slowing the game down: my ignorance in graphical rendering.

    I was using immediate drawing all wrong, and now I have it using GPU_TRIANGLE_STRIP, which sped things up by a ton.

    Original speeds are back. Ignore the previous post of needing to slow the game down.

    edit: special thanks to fincs and Stary for helping me discover and fix my problem :)
     
    Last edited: Feb 5, 2017
    Quantumcat likes this.
  18. LucarioWolf

    LucarioWolf Advanced Member
    Newcomer

    Joined:
    Jan 14, 2017
    Messages:
    56
    Country:
    United States
    exactly, terrible WiFi at McDonalds

    — Posts automatically merged - Please don't double post! —

    sounds like a great game like the one that used to be on the Nokia phones. by any chance can you make it so that others who dont have the game downloadable via 3DS or DS download play?
     
  19. Desynched

    OP Desynched GBAtemp Regular
    Member

    Joined:
    Jan 4, 2017
    Messages:
    107
    Country:
    United States
    The download play checks to make sure the game is signed by an authentic developer, or so I'm told when I asked a similar question in the 3ds dev community. If that were possible you'd probably be seeing "downloadhax" or some other exploit.

    However, it is possible to transfer a newer version of the game to an older version (if I put in the time to research and implement a version transfer system). Right now I've got enough feature creep to get through before I can start on something like that, so I added a "ghetto" version of it: press x at Snakes' start screen to display the qr code for the cia file of your version of the game. If your friend has the qrcode installer, they can download and install your version quite easily by using your screen. The problem is they have to have the qrcode installer in their 3ds already, and have access to an internet connection. If they don't have those two things, it's kind of useless. The local play doesn't require a wifi connection, but if I implement the transfer system they'd still have to have an older version of snakes already installed... Because of this, I'm not in a hurry to implement it.

    Anyway, thank you for the kind words, and for your post!
     
    Last edited: Feb 5, 2017
    Quantumcat likes this.
  20. LucarioWolf

    LucarioWolf Advanced Member
    Newcomer

    Joined:
    Jan 14, 2017
    Messages:
    56
    Country:
    United States
    cool, and thanks for the feed back
     
Draft saved Draft deleted
Loading...

Hide similar threads Similar threads with keywords - Release], players, Snakes