Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 586 587 [588] 589 590 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 882963 times)

TheBiggerFish

  • Bay Watcher
  • Somewhere around here.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8805 on: January 16, 2016, 07:22:17 am »

Anyone who uses tabs is a filthy heathen. Deus vult.
Spaces is heresy. If someone suggested that we replace periods in sentences with "aaaa" we'd think they were crazy. 1 tab == 1 indent, the way God intended.
Because "." and "aaaa", they don't have the same function.
Whereas tabs and spaces are both whitespace characters, meant to separate and indent and all.
Logged
Sigtext

It has been determined that Trump is an average unladen swallow travelling northbound at his maximum sustainable speed of -3 Obama-cubits per second in the middle of a class 3 hurricane.

Antsan

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8806 on: January 16, 2016, 10:15:58 am »

I would be interested in a good argument for spaces over tabs, because I just don't see the benefit of using spaces. The only reason you should ever be messing with source code is because you want to change what it does, not that you need to change how it looks. I get the feeling it has more to do with OSes historically freaking the fuck out if they find tabs in text files, causing this superstitious aversion to tabs.
Common Lisp has such strict indenting guidelines that they can be and are applied automatically while coding. The are never just in increments of tabs but rather in relation to their, uhm, parent node in the source tree. So they are either placed aligned with the arguments on the first line of the node:
Code: [Select]
(some-stuff foo (bar quux)
            baz)  ; note how this kind of indentation not only highlights how this belongs to some-stuff
                  ; but also enhances the visibility of the arguments on the previous line
or, if there are no arguments on the first line, just to the right of the enclosing paren:
Code: [Select]
(yay
 boo)
or, in some special cases one space further to the right, because these special constructs expect something multi-line there:
Code: [Select]
(progn
  (one call)
  (another thing to do))

(let ((a 2)  ; variable definitions line up nicely
      (b 3))
  (+ a b))   ; the code is also easily distinguishable by the way it is less indented
This reads very nicely, lines up things that belong together and so on. This wouldn't be possible with tabs.

For C++ emacs also does auto-indenting and uses different indent widths for different contexts. It makes code more readable because the offset conveys additional information.
So, the big advantage of spaces is the variability and thus readability. I don't want always 2 or always 4 or always 8 spaces for an indent level.
« Last Edit: January 17, 2016, 09:19:31 am by Antsan »
Logged
Taste my Paci-Fist

GiglameshDespair

  • Bay Watcher
  • Beware! Once I have posted, your thread is doomed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8807 on: January 16, 2016, 02:59:05 pm »

I wrote a quick shitty program for Taricus in C#.
It could certainly be improved (error handling, etc), but it does the job.
Haven't programmed anything in months, so it's something at least?

Code: [Select]
int die = 0;
            int noOfDice = 0;
            int check = 0;
            int noOfSuccess = 0;
            int rolledResult= 0;

            Console.Write("GigDice v0.1.5 \nEnter die: ");
            Console.ForegroundColor = ConsoleColor.Red;
            die = Convert.ToInt32(Console.ReadLine());
            Console.ForegroundColor = ConsoleColor.Gray;

            Console.Write("\nEnter number of dice to roll: ");
            Console.ForegroundColor = ConsoleColor.Red;
            noOfDice = Convert.ToInt32(Console.ReadLine());
            Console.ForegroundColor = ConsoleColor.Gray;

            Console.Write("\nEnter number to score to succeed: ");
            Console.ForegroundColor = ConsoleColor.Red;
            check = Convert.ToInt32(Console.ReadLine());
            Console.ForegroundColor = ConsoleColor.Gray;

            Random r = new Random();

            for (int i = 0; i < noOfDice; i++)
            {
                rolledResult = r.Next(1, die);
                Console.WriteLine("Roll was: " + rolledResult);

                if (rolledResult == check || rolledResult > check)
                {
                    Console.WriteLine("Success");
                    noOfSuccess = noOfSuccess +1;
                }
                else
                {
                    Console.WriteLine("Failure");
                }
                noOfDice = noOfDice--;

            };
            Console.Write("\nNumber of successes was: ");
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write(noOfSuccess);
            Console.ForegroundColor = ConsoleColor.Gray;

            Console.WriteLine("\nPress any key to exit");
            Console.ReadKey();

Output looks like:
Spoiler (click to show/hide)
Logged
You fool. Don't you understand?
No one wishes to go on...

cerapa

  • Bay Watcher
  • It wont bite....unless you are the sun.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8808 on: January 16, 2016, 03:55:38 pm »

Code: [Select]
    int a[10] = {10};
    while (a[0] --> 1) a[1[a-1]] = (a>a)[a];

This is perfectly valid C++ code. Can you guess what it does without compiling it?
Logged

Tick, tick, tick the time goes by,
tick, tick, tick the clock blows up.

TheBiggerFish

  • Bay Watcher
  • Somewhere around here.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8809 on: January 16, 2016, 03:57:12 pm »

Code: [Select]
    int a[10] = {10};
    while (a[0] --> 1) a[1[a-1]] = (a>a)[a];

This is perfectly valid C++ code. Can you guess what it does without compiling it?
Nope...
Logged
Sigtext

It has been determined that Trump is an average unladen swallow travelling northbound at his maximum sustainable speed of -3 Obama-cubits per second in the middle of a class 3 hurricane.

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8810 on: January 16, 2016, 04:47:39 pm »

Code: [Select]
    int a[10] = {10};
    while (a[0] --> 1) a[1[a-1]] = (a>a)[a];

This is perfectly valid C++ code. Can you guess what it does without compiling it?
It initializes an array of integers with the values 0 to 9.

Spoiler (click to show/hide)
Logged

TheBiggerFish

  • Bay Watcher
  • Somewhere around here.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8811 on: January 16, 2016, 04:58:13 pm »

It's a code puzzle.  It's supposed to be obfuscated?
Logged
Sigtext

It has been determined that Trump is an average unladen swallow travelling northbound at his maximum sustainable speed of -3 Obama-cubits per second in the middle of a class 3 hurricane.

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8812 on: January 16, 2016, 05:24:59 pm »

i like --> there

that's silly

while a[0]-- > 1 is a more... not dumb way to put it

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8813 on: January 16, 2016, 05:49:02 pm »

Haha I see what putnam means, I somehow thought that --> was some fancy new operator I hadn't heard of.
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.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #8814 on: January 17, 2016, 01:14:59 pm »

It seems like I will need to learn how to implement PID controllers!

And then connect them together to steer my space ships! :/

Maybe I should have left them with simple behaviour...


Edit: so it seems that multiple-in, multiple-out PID controllers are really hard to design.  What now..
« Last Edit: January 18, 2016, 12:26:41 am 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

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8815 on: January 19, 2016, 01:52:42 am »

I created a game where you have to slash shapes along their lines of symmetry. Now that all the basic mechanics are down, I just have to create about 50-80 shapes so that the game doesn't get too repetitive... Does anybody else suddenly get intensely bored and frustrated with projects that reach this stage?
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.

EnigmaticHat

  • Bay Watcher
  • I vibrate, I die, I vibrate again
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8816 on: January 19, 2016, 02:01:53 am »

Sounds like you prefer creating mechanics to creating content.
Logged
"T-take this non-euclidean geometry, h-humanity-baka. I m-made it, but not because I l-li-l-like you or anything! I just felt s-sorry for you, b-baka."
You misspelled seance.  Are possessing Draignean?  Are you actually a ghost in the shell? You have to tell us if you are, that's the rule

Orange Wizard

  • Bay Watcher
  • mou ii yo
    • View Profile
    • S M U G
Re: if self.isCoder(): post() #Programming Thread
« Reply #8817 on: January 19, 2016, 02:23:18 am »

The solution is collaboration!
Logged
Please don't shitpost, it lowers the quality of discourse
Hard science is like a sword, and soft science is like fear. You can use both to equally powerful results, but even if your opponent disbelieve your stabs, they will still die.

Antsan

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8818 on: January 19, 2016, 11:22:39 am »

The solution is to create a shape generator.
Logged
Taste my Paci-Fist

i2amroy

  • Bay Watcher
  • Cats, ruling the world one dwarf at a time
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8819 on: January 19, 2016, 12:59:22 pm »

The solution is collaboration!
The solution is to create a shape generator.
Both of these are wonderful solutions. :P The first is ideally something you do pretty early in the project to make the whole thing go easier; the second is nifty for letting you have an "infinite mode" to your game. :P
Logged
Quote from: PTTG
It would be brutally difficult and probably won't work. In other words, it's absolutely dwarven!
Cataclysm: Dark Days Ahead - A fun zombie survival rougelike that I'm dev-ing for.
Pages: 1 ... 586 587 [588] 589 590 ... 796