Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 679 680 [681] 682 683 ... 796

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

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10200 on: November 23, 2016, 02:32:08 am »

Obama managed a tech reference to compilers in a speech which was unusually non-crap for a non-techie:

Quote
She saw beyond the boundaries of the possible and invented the first compiler, which allowed programs to be written in regular language and then translated for computers to understand.

Which is just about the most elegant way to describe a compiler to a non-techie. Even the phrase "regular language" was cleverly chosen to have a double meaning, for techies vs non-techies.

https://en.wikipedia.org/wiki/Regular_language

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10201 on: November 23, 2016, 02:45:46 am »

Logged

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10202 on: November 23, 2016, 02:53:04 am »

The first thing you want to do is find those repeated sections which only have minor differences, and turn them into a function. The nested switches seem questionable there.

One thing that can really help is to define some constants e.g.

int dirNorth = 1;
int dirSouth = 2;
int dirWest = 4;
int dirEast = 8;

Then, instead of writing "case 13:" you write "case dirEast + dirWest + dirNorth:"
Doing something like that makes it easier read, and to see where you can turn parts of the code can be turned into functions by passing different "dir" values to the function.
« Last Edit: November 23, 2016, 03:17:11 am by Reelya »
Logged

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10203 on: November 23, 2016, 05:34:49 am »

Yeah, I need to make a function to rotate the points that I need, then I can simplify things a lot.
Logged

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10204 on: November 23, 2016, 07:14:10 am »

The first thing you want to do is find those repeated sections which only have minor differences, and turn them into a function. The nested switches seem questionable there.

One thing that can really help is to define some constants e.g.

int dirNorth = 1;
int dirSouth = 2;
int dirWest = 4;
int dirEast = 8;

Then, instead of writing "case 13:" you write "case dirEast + dirWest + dirNorth:"
Doing something like that makes it easier read, and to see where you can turn parts of the code can be turned into functions by passing different "dir" values to the function.
I think it'd be cleaner still to binary OR those values instead of using addition.
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.

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10205 on: November 23, 2016, 11:36:54 pm »

This is what I ended up with:

http://pastebin.com/S4BXcMmZ

Code: [Select]
    [Flags]
    enum Directions
    {
        None = 0,
        NorthWest = 1,
        NorthEast = 2,
        SouthWest = 4,
        SouthEast = 8,

        North = NorthWest | NorthEast,
        South = SouthWest | SouthEast,
        East = NorthEast | SouthEast,
        West = NorthWest | SouthWest,

        All = NorthWest | NorthEast | SouthWest | SouthEast
    }
« Last Edit: November 23, 2016, 11:44:28 pm by Japa »
Logged

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10206 on: November 24, 2016, 12:37:44 am »

Maybe if you made the cardinals the single-bits the whole thing would be less complex? That's just a hunch I have. The good part is that by turning everything into variables, it's a lot less complex to try the other pattern.

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10207 on: November 24, 2016, 02:17:51 am »

I have 4 inputs, and they're all diagonals. The cardinals are only shortcuts to simplify things.
Logged

Gentlefish

  • Bay Watcher
  • [PREFSTRING: balloon-like qualities]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10208 on: November 24, 2016, 02:55:50 pm »

I have 4 inputs, and they're all diagonals. The cardinals are only shortcuts to simplify things.

wh... why is input only diagonals? Is this something in isometric view such that "up" corresponds to "northeast/northwest"?

Spehss _

  • Bay Watcher
  • full of stars
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10209 on: November 24, 2016, 03:16:18 pm »

how do I set up Visual Studio Code to compile C++ programs? Should I follow this process?

If so, I'm missing the vcvarsall.bat and the build.bat isn't being recognized as a batch file, presumably because of the missing vcvarsall.bat file.
Logged
Steam ID: Spehss Cat
Turns out you can seriously not notice how deep into this shit you went until you get out.

eerr

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10210 on: November 25, 2016, 05:54:47 am »

Why on earth would you not use a top of the line IDE that you have presumably just installed?
Logged

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10211 on: November 25, 2016, 07:51:59 am »

Make a project.

Add your files to that project.

Then click compile in visual studio.
Logged

Shadowlord

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10212 on: November 25, 2016, 07:56:48 am »

Visual Studio Code is different.
Logged
<Dakkan> There are human laws, and then there are laws of physics. I don't bike in the city because of the second.
Dwarf Fortress Map Archive

TheBiggerFish

  • Bay Watcher
  • Somewhere around here.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10213 on: November 25, 2016, 12:07:15 pm »

how do I set up Visual Studio Code to compile C++ programs? Should I follow this process?

If so, I'm missing the vcvarsall.bat and the build.bat isn't being recognized as a batch file, presumably because of the missing vcvarsall.bat file.
My suggestion is to just get an IDE that isn't that one.
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.

Spehss _

  • Bay Watcher
  • full of stars
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10214 on: November 25, 2016, 07:11:52 pm »

My suggestion is to just get an IDE that isn't that one.
So helpful. Thanks.

Why on earth would you not use a top of the line IDE that you have presumably just installed?
Define a top of the line IDE then? From what I hear Visual Studio is good, but Visual Studio Professional and Visual Studio Enterprise cost money, Visual Studio Community will not actually finish the installing process on my computer, and Visual Studio Code appears to be shit.

I've been using Code::Blocks but I tried Visual Studio Code based on a recommendation of what's "good to be familiar with" -in this case Visual Studio IDEs- if I want to be "competitive" in the job market for programming.
Logged
Steam ID: Spehss Cat
Turns out you can seriously not notice how deep into this shit you went until you get out.
Pages: 1 ... 679 680 [681] 682 683 ... 796