Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 74 75 [76] 77 78 ... 91

Author Topic: Programming Help Thread (For Dummies)  (Read 100499 times)

Anvilfolk

  • Bay Watcher
  • Love! <3
    • View Profile
    • Portuguese blacksmithing forum!
Re: Programming Help Thread (For Dummies)
« Reply #1125 on: August 01, 2013, 10:20:44 am »

Aw man, I hope you pull this off :)

It should be relatively simple to find an A* implementation in Python, no? Or find the right datastructures and implement it yourself. The main thing, I think, is keeping track of who is moving so that you can dynamically assign weights to the nodes that are undesirable for that character. This way, zones that are undesirable will simply be avoided.

Of course, depending on the state of the station some poor guy might decide to brave a tile of fire if the alternative is going to Earth on a spaceshuttle and back :P I'm sure a whole lotta !!FUN!! can result from this :D

Girlinhat

  • Bay Watcher
  • [PREFSTRING:large ears]
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1126 on: August 01, 2013, 11:05:41 am »

I'm actually just writing out my own pathfinding function using A*.  Once the step-by-step and the math becomes visible, then the code is obvious.  It's just a matter of refining all the if's and while's.  Once I get the basics, I can start expanding it for creature-specific actions...

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: Programming Help Thread (For Dummies)
« Reply #1127 on: August 01, 2013, 11:52:17 am »

A* is easy enough with wikipedia's pseudocode and lots of online resources c:
Once you get the idea you'll never forget it.
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

Girlinhat

  • Bay Watcher
  • [PREFSTRING:large ears]
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1128 on: August 01, 2013, 12:11:31 pm »

Wikepedia wasn't the most obvious.  This was actually what made it obvious, and I started striking up my own code from scratch:
http://www.policyalmanac.org/games/aStarTutorial.htm

The problem is all the gifs and pngs in the world won't describe the F=G+H or the scaling of movement cost or how it selects the most direct route.  This page actually goes step-by-step and shows how this works at the most basic level, and could work with non-square grids.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: Programming Help Thread (For Dummies)
« Reply #1129 on: August 02, 2013, 10:22:15 am »

Huh. I guess it's personal difference. For me, findLowestF()  was one of the hardest parts.
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1130 on: August 03, 2013, 09:59:56 am »

Can anybody recommend me a good Python tutorial? I used one a few months ago and didn't go trough with it, and now I can't find it anymore :/
Logged

Quote from: NW_Kohaku
they wouldn't be able to tell the difference between the raving confessions of a mass murdering cannibal from a recipe to bake a pie.
Knowing Belgium, everyone will vote for themselves out of mistrust for anyone else, and some kind of weird direct democracy coalition will need to be formed from 11 million or so individuals.

Girlinhat

  • Bay Watcher
  • [PREFSTRING:large ears]
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1131 on: August 03, 2013, 10:54:04 am »

Can anybody recommend me a good Python tutorial? I used one a few months ago and didn't go trough with it, and now I can't find it anymore :/
If you're totally unfamiliar with programming, then you can easily find C++ tutorials.  It's the same thing, just slight variants on how many parenthesis you use.

Code: [Select]
if(x==TRUE)
{
  y=3;
}
is the same as:
Code: [Select]
if x==True:
  y=3

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: Programming Help Thread (For Dummies)
« Reply #1132 on: August 03, 2013, 11:38:00 am »

While the syntax is quite similar, the horrors of compiler errors and templates and types is quite a thing.

Compare
std::mao<std::string, int> dictionary;
and, for Perl (I don't knke the syntax for dictionaries in Python off the top of my head)
$dictionary {"one"->1};

Also, to beginners most compiler errors look like CERROR 39482 SOMETHING BROKE AND YOU CAN'T FIX IT. C++ errors are among the less helpful ones, though it does improve for modern compilers.
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

Anvilfolk

  • Bay Watcher
  • Love! <3
    • View Profile
    • Portuguese blacksmithing forum!
Re: Programming Help Thread (For Dummies)
« Reply #1133 on: August 03, 2013, 12:30:15 pm »

Python is just

myDict = {"one": 1, "two": 2, 5: "anything I want, really, as both keys and values!"}

There are plenty of programming tutorials for Python, including some free online books for programming games using Python, while learning Python. Just google for "free python game programming" or something, and it should get you there :)

lue

  • Bay Watcher
  • [PREFSTRING:missing right bracket
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1134 on: August 05, 2013, 01:23:53 am »

And in Perl 6 it's just

Code: [Select]
my %hash = <one 1 two 2 five stringValue>;
 :D

Also, for C/C++ errors, I highly recommend LLVM and clang. GCC 4.8 just got around to doing the "print code line and point at the problem" that LLVM does. (Don't know if 4.7 did it too, but I know 4.6 didn't.)

Compare, with the following terrible C++ file:

Code: [Select]
#include <iostream>

int factorial(int number) {
    if (number == 0) { return 1 };
    return number * factorial(number - 1);
}

int main() {
    std::cout << "Hello world! " << factorial(4,2) << "\n";
}

Output of g++ 4.8.1:

Spoiler (click to show/hide)

And a somewhat old checkout of the upcoming clang 3.4:
Spoiler (click to show/hide)

Not the best comparison I could whip up quickly, but hopefully gets across the somewhat friendlier nature of clang. (Also, colors. At least for me a generous application of color keeps my brain from seeing a wall of errors as undecipherable. I tend to switch from g++ to clang++ whenever I want easier-to-read errors.)
Logged
Post not guaranteed accurate or pristine for all of time.
Sigtext. Enticing, yes? If you do not know where things I have "sigged" go, this page will explain.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: Programming Help Thread (For Dummies)
« Reply #1135 on: August 05, 2013, 02:17:47 am »

I personally use MSVS. It has the best debugger ever :D
The error messages for non-templated code is also pretty friendly.

... though Clang seems to be hopeful-looking.
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

Girlinhat

  • Bay Watcher
  • [PREFSTRING:large ears]
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1136 on: August 05, 2013, 03:07:46 pm »

While the syntax is quite similar, the horrors of compiler errors and templates and types is quite a thing.

Compare
std::mao<std::string, int> dictionary;
and, for Perl (I don't knke the syntax for dictionaries in Python off the top of my head)
$dictionary {"one"->1};

Also, to beginners most compiler errors look like CERROR 39482 SOMETHING BROKE AND YOU CAN'T FIX IT. C++ errors are among the less helpful ones, though it does improve for modern compilers.
Just want to point out how we're discussing "What's it like to use Python" and you pull up C++ and Perl.  This appears to be fantastically irrelevant.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: Programming Help Thread (For Dummies)
« Reply #1137 on: August 05, 2013, 06:59:54 pm »

I said I didn't know Python enough for dictionary code off the top of my head. Meanwhile, both being scripting languages, Perl and Python have similarly simple syntax. So I said I wrote Perl because I didn't know Python fluently, knowing their syntax won't be so different as to make a difference. The Python someone else posted for me was strikingly similar to Perl, just swapping -> for colons and dropping the sigil. I'd say this is pretty relevant.

As for the second part, it is in line with the purpose of my post, wherein I recommend Python over C++ because of the latter's containers' verbose and generally scary errors.
« Last Edit: August 05, 2013, 07:04:38 pm by Skyrunner »
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1138 on: August 06, 2013, 04:58:18 am »

While the syntax is quite similar, the horrors of compiler errors and templates and types is quite a thing.

Compare
std::mao<std::string, int> dictionary;
and, for Perl (I don't knke the syntax for dictionaries in Python off the top of my head)
$dictionary {"one"->1};

Also, to beginners most compiler errors look like CERROR 39482 SOMETHING BROKE AND YOU CAN'T FIX IT. C++ errors are among the less helpful ones, though it does improve for modern compilers.
Just want to point out how we're discussing "What's it like to use Python" and you pull up C++ and Perl.  This appears to be fantastically irrelevant.
You were the one that said "you can easily find C++ tutorials" when I asked for Python tutorials, tough :P

E: I found the tutorial that I lost, tough, with some more creative google searches.
« Last Edit: August 06, 2013, 05:13:59 am by miauw62 »
Logged

Quote from: NW_Kohaku
they wouldn't be able to tell the difference between the raving confessions of a mass murdering cannibal from a recipe to bake a pie.
Knowing Belgium, everyone will vote for themselves out of mistrust for anyone else, and some kind of weird direct democracy coalition will need to be formed from 11 million or so individuals.

professorlamp

  • Bay Watcher
    • View Profile
    • joereynoldsaudio
Re: Programming Help Thread (For Dummies)
« Reply #1139 on: August 06, 2013, 11:42:33 am »

http://programarcadegames.com/

I used that site when I just started with Python, that was a few months ago, if you stick at it, it doesn't take too long to make surprisingly useful stuff :D

That site above is very good, super user friendly and with a butt-load of videos. Whilst it is more oriented around games programming, nearly all the chapters can be done without a games library.

Logged
I write music for video games!
www.joereynoldsaudio.com
Pages: 1 ... 74 75 [76] 77 78 ... 91