• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Programming |OT| C is better than C++! No, C++ is better than C

Slavik81

Member
I'm staring at all these square brackets in ObjectiveC wondering what they mean. Any suggestions for a crash course on the iOS SDK for someone familiar with other GUI toolkits?
 

Massa

Member
I'm staring at all these square brackets in ObjectiveC wondering what they mean. Any suggestions for a crash course on the iOS SDK for someone familiar with other GUI toolkits?

Play with Smalltalk for a week and Objective-C will instantly make sense.
 

hateradio

The Most Dangerous Yes Man
Have any of you who have been developing for several years (7+) encountered fatigue?

I want to go more into product management, but shit's annoying if I have to start at another location in a few months.
 
Have any of you who have been developing for several years (7+) encountered fatigue?

I want to go more into product management, but shit's annoying if I have to start at another location in a few months.

Yea but for me it just means it's time to move to a new project or new company
 

diaspora

Member
I've been getting this exception on some AVDs but not others. Anyone else run into this issue in Android Studio?

edit: nvm, just kept building and cleaning until it started working again
 
So I'm trying to do a project for my intro to coding class, but im not exactly sure how to accomplish it. Its Java. I need to make the yellow character move when i click and drag it, but only it. I have no idea how to do this and a lab instructor i asked just made it worse lol. I basically tried to limit the mouseDragged function to a 'box' around the character which makes it not work away from the character but as a result it wont drag outside of the box. Any help?

https://www.khanacademy.org/computer-programming/follow-the-mouse/3037220411

I know barely anything about programming so dont get too complicated
 

NotBacon

Member
So I'm trying to do a project for my intro to coding class, but im not exactly sure how to accomplish it. Its Java. I need to make the yellow character move when i click and drag it, but only it. I have no idea how to do this and a lab instructor i asked just made it worse lol. I basically tried to limit the mouseDragged function to a 'box' around the character which makes it not work away from the character but as a result it wont drag outside of the box. Any help?

https://www.khanacademy.org/computer-programming/follow-the-mouse/3037220411

I know barely anything about programming so dont get too complicated

1. That is Javascript. And while it does have a similar name, Java is as similar to Javascript as a car is to carpet. As in, not very similar at all.

2. Try having another two variables to keep track of the last mouse position (the initial values should probably start at the cat). And when the mouse is dragged, compare the mouse coordinates to those variables instead of static values.
 

Two Words

Member
Man, I keep getting TAs that make mistakes grading my project assignments. It's really frustrating to work hard to make sure all of your cases are covered, and they say "This doesn't work with X" when it clearly does. I know I can just get it corrected, and I do, but it is something that just bugs me. I am guessing these TAs just churn out grading these things too fast to do a proper testing job.
 

Koren

Member
Man, I keep getting TAs that make mistakes grading my project assignments. It's really frustrating to work hard to make sure all of your cases are covered, and they say "This doesn't work with X" when it clearly does. I know I can just get it corrected, and I do, but it is something that just bugs me. I am guessing these TAs just churn out grading these things too fast to do a proper testing job.
That's strange, I've barely seen any issues with automatic bug testing in school projects. I'd be curious to know what kind of mistakes you've encounered...
 

Zoe

Member
Since people in the web dev thread only seen to care about the front end...

What is considered the best C# PDF library these days, particularly for forms? I've been using iTextSharp, but it's probably time to move on.
 

Chris R

Member
If you find something better, let me know. I've been using iTextSharp for some time as well, but it is a bit of a hassle to use sometimes.
 

JeTmAn81

Member
1. That is Javascript. And while it does have a similar name, Java is as similar to Javascript as a car is to carpet. As in, not very similar at all.

2. Try having another two variables to keep track of the last mouse position (the initial values should probably start at the cat). And when the mouse is dragged, compare the mouse coordinates to those variables instead of static values.

You don't have to keep track of coordinates manually, HTML5 made drag and drop standard:

http://www.w3schools.com/html/html5_draganddrop.asp
 

NetMapel

Guilty White Male Mods Gave Me This Tag
Woooo 70% through Python in CodeAcademy :)

Anybody got some good material for me to continue learning Python after I complete CodeAcademy ? Would really appreciate it !

Also, just curious... just exactly how useful is Python in the tech industry ? I'm learning Python now because I work in the computer graphics visual effects industry. We use many softwares that allow us to build toolset and such using Python. For example, Autodesk Maya and Foundry Nuke use Python for me to build tools to automate things to make my life easier as an artist. However, how applicable is Python in the actual tech industry. Is it a transferrable skill if I were to think about transitioning to a more tech-oriented job ? Thanks in advance for answering :)
 
I found this website of problems to solve for last year's Christmas, one per day. Seems interesting, so I took it on myself to learn Rust by solving them.

Kind of fun. Maybe my time would be better spent doing C++, but eh. Maybe next time.

Advent of Code
My solutions so far

I was doing it too until the 9th or so day but then things got super hectic and work and couldn't be bothered to beat the rest.

Here's a random JS solution for #2

Code:
const defaultInput = "your_input";

function getMaterialTotal(input) {
    let total = {wrappingPaper: 0, ribbon: 0};

    input.split(" ").forEach((box) => {
      const dimensions = box.split(/\D/gi);
      const [l, w, h] = dimensions;
      const lw = l * w;
      const wh = w * h;
      const hl = h * l;

      const smallestArea = Math.min.apply(null, [lw, wh, hl]);
      let perimeter = null;
        
      switch (smallestArea) {
          case lw: 
              perimeter = 2 * l + 2 * w;
              break;
          case wh:
              perimeter = 2 * w + 2 * h;
              break;
          case hl:
              perimeter = 2 * h + 2 * l;
              break;              
      }
    
      const boxSize = ((2 * lw) + (2 * wh) + (2 * hl) + smallestArea);
      const bow = l * w * h;
      total.wrappingPaper += boxSize;
      total.ribbon += (bow + perimeter);
    });
    
    return total;
}
console.log(getMaterialTotal(defaultInput));
 

Chris R

Member
Figured this might be of interest to people in the programming community.

http://www.neogaf.com/forum/showthread.php?t=1194959

Tonight Google will make history by (hopefully!) defeating Lee Sedol in the first of 5 even matches of Go, a challenge which most thought would be impossible for at least another 2 generations.

If successful, it will be a monumental breakthrough in AI.

I'll be watching, even though I know nothing about how Go is played.
 

JeTmAn81

Member
Figured this might be of interest to people in the programming community.

http://www.neogaf.com/forum/showthread.php?t=1194959

Tonight Google will make history by (hopefully!) defeating Lee Sedol in the first of 5 even matches of Go, a challenge which most thought would be impossible for at least another 2 generations.

If successful, it will be a monumental breakthrough in AI.

An addendum concerning how Go is different from Chess from an AI perspective:

https://en.wikipedia.org/wiki/Computer_Go#Techniques_in_chess_that_cannot_be_applied_to_Go
 
I'll be watching, even though I know nothing about how Go is played.

The basic idea is that the goal is not to capture your opponents pieces (although you can), but rather to create areas of territory on the board that are impenetrable. But to do it in the least amount of moves possible, because obviously while you're busy securing your areas of territory, the opponent may be trying to secure his. So you have to decide how strong yours is versus how strong his is. You can play anywhere on the board at any time, there is literally only 1 rule about where you can place stones, and that is that you can't place your stone in a square that would instantly be captured.

A game like chess is 60% strategic planning, 40% tactical calculation. But a game like Go is 95% strategic planning and 5% tactical calculation.

Go is ranked on a system of kyus and dans. A person who doesnt know the rules is 30kyu, as they get better they get LOWER, until 1kyu. This is usually abbreviated 10k, or 1k, for example. After 1kyu you become 1 dan, then up to 9dan. These are usually written 1d-9d. But those are "amateur" dan ratings. Professionals play at the professional dan level, which are usually denoted with a p, so 1p - 9p.

A more standardized rating system is the ELO scale, and if I remember correctly the highest professional (Lee Sedol, 9p) plays at about the 2950 ELO level, a 1p plays at about 2700 ELO, a 1d plays at about 2100 ELO, and a 15k plays at about 600 ELO.

A general rule of thumb is that a gap of 300 ELO points will result in the weaker player losing 100% of the time. So in a sense, you can think of 300 ELO points as roughly "an order of magnitude"

Until DeepMind, the strongest Go AI was CrazyStone, which I believe plays at about 3d, or 2300 ELO.

So putting this all together, if you find the weakest person who can beat CrazyStone 100% of the time, Lee Sedol could beat that person 100% of the time.

Now, back to DeepMind. It shocked the Go world by coming out of nowhere and beating a 2p 100% of the time 3 months ago. This means it could already beat CrazyStone 100% of the time so it was an order of magnitude better. The interesting thing is that nobody knows how strong it *actually* was, since it won 100% of the games it played against the 2p. Maybe it could have already beaten a 3p, or a 5p, or a 9p. And it's still had months to improve since then. Normally months isn't a long time in the computer go world, but given how fast it came out of nowhere, it's possible they have a system in place that can learn at an extremely rapid pace.
 
Done with Intro to Programming with an 82.3%. I'm moving directly into Programming fundamentals. I messed up my final pretty bad. I should have left myself more time to review .
 

Slavik81

Member
Figured this might be of interest to people in the programming community.

http://www.neogaf.com/forum/showthread.php?t=1194959

Tonight Google will make history by (hopefully!) defeating Lee Sedol in the first of 5 even matches of Go, a challenge which most thought would be impossible for at least another 2 generations.

If successful, it will be a monumental breakthrough in AI.
A Go AI from Google? I hope it's written in Go.
 

Einherjar

Member
Hey guys, I'm trying to think of a good design to replicate tab targetting in MMOs.

So lets say I boot up a random MMORPG and I'm in the middle of a map. I can press tab to select the nearest enemy.

Let's say that the game doesn't offer this functionality anymore.

So now I want to write a function that will click the point on the screen where an enemy is, and make this generic enough to work in any game.

So now I'm thinking how do humans instantly recognize an enemy on screen? It stands out from the surroundings... but how does this translate to code logic?
 
Hey guys, I'm trying to think of a good design to replicate tab targetting in MMOs.

So lets say I boot up a random MMORPG and I'm in the middle of a map. I can press tab to select the nearest enemy.

Let's say that the game doesn't offer this functionality anymore.

So now I want to write a function that will click the point on the screen where an enemy is, and make this generic enough to work in any game.

So now I'm thinking how do humans instantly recognize an enemy on screen? It stands out from the surroundings... but how does this translate to code logic?

Sounds like any solution you use is going to be error prone and not work that well. I'd start by looking for health bars or name plates though
 

luoapp

Member
Sounds like any solution you use is going to be error prone and not work that well. I'd start by looking for health bars or name plates though

or you can check movement of blocks of pixels. Of course, you have to separate enemies from environment elements, (size, repetitive movement, etc.) Or, you check the internal variables where the locations of enemies are stored.

Or you can just borrow Goolge's alpha go. (It's actually Alpha's alpha go, isn't it?)
 

Einherjar

Member
Sounds like any solution you use is going to be error prone and not work that well. I'd start by looking for health bars or name plates though

In this instance health bars don't show up until they are clicked :(

or you can check movement of blocks of pixels. Of course, you have to separate enemies from environment elements, (size, repetitive movement, etc.) Or, you check the internal variables where the locations of enemies are stored.

Or you can just borrow Goolge's alpha go. (It's actually Alpha's alpha go, isn't it?)

I don't want to read from memory as the pointers would be specific to the game. However your movements of blocks of pixels is a good idea! I'll give that a try, might be tough to make it efficient and fast though.
 

Koren

Member
might be tough to make it efficient and fast though.
Assuming you can efficiently grab the display, there's plently of work on optical flows, and it can be made efficient.

Care to tell us more about the game? The solutions can be pretty different depending on many factors (point of view, moving/static background, etc.)
 

Einherjar

Member
Assuming you can efficiently grab the display, there's plently of work on optical flows, and it can be made efficient.

Care to tell us more about the game? The solutions can be pretty different depending on many factors (point of view, moving/static background, etc.)

It's Breath of Fire 6. I just realized however that my AI party members are also moving around on the screen which makes this more difficult.

Breath-of-Fire-VI-2.jpg


For capturing the screen I was thinking of using the GDI Plus api (GdipCreateBitmapFromHBITMAP), so capture it at two points in time and scan areas for large differences in pixel values, but with friendly characters on screen that's more difficult. Even in other games, other players may be walking by.
 

luoapp

Member
It's Breath of Fire 6. I just realized however that my AI party members are also moving around on the screen which makes this more difficult.

Breath-of-Fire-VI-2.jpg


For capturing the screen I was thinking of using the GDI Plus api (GdipCreateBitmapFromHBITMAP), so capture it at two points in time and scan areas for large differences in pixel values, but with friendly characters on screen that's more difficult. Even in other games, other players may be walking by.

Is this game sprite based ( not 3D polygon)? If so, then each character only has limited sprites, which shouldn't be too hard to match if you can grab them all from the game.
 
Yea that's what I was going to say. The character sprites probably have many different frames of animation depending on what the character is doing. If you can get the game's data files and extract the sprite bitmap, you could take the bitmap intersection of all frames. Most likely you will have a fair number of pixels remaining in the intersection. Those can be your "triggers" that you have a particular NPC
 

Einherjar

Member
I'd rather not have the code be specific to sprite based games (and I can't seem to find the sprite files). At the same time, there doesn't seem to be an easy solution to this for differentiating monsters from other players walking by.
 

Koren

Member
I'd rather not have the code be specific to sprite based games (and I can't seem to find the sprite files). At the same time, there doesn't seem to be an easy solution to this for differentiating monsters from other players walking by.
Obviously not, and I don't think you'll be able to find anything like an "universal" solution.

If you *really* want to create something quite universal, I think the best solution is to create a set of tools, modular if possible so that you can add other tools, and allow the user to choose the tools, change strategies and so on depending on the game. You can provide presets for each game, but not a fully automated solution...


It's Breath of Fire 6. I just realized however that my AI party members are also moving around on the screen which makes this more difficult.

Breath-of-Fire-VI-2.jpg


For capturing the screen I was thinking of using the GDI Plus api (GdipCreateBitmapFromHBITMAP), so capture it at two points in time and scan areas for large differences in pixel values, but with friendly characters on screen that's more difficult. Even in other games, other players may be walking by.
You may be able to identify all "active blobs" on screen, assuming there's not too many effects on screen (magic can really mess things). Once you've done that, you can probably identify your partners by doing a color identification of the blobs. It usually works pretty well, and you can use unsupervised learning using k-means or something.

That being said, that's a huge project you're getting into...
 

Koren

Member
Some stupid idea... Instead of guessing where to click, wouldn't the other way around simpler? Track your own character, click in a spiralling curve around it, and stop when you detect that a you've a lock by detecting the health bar?
 

Skinpop

Member
Just getting into podcasts, any good programming (or related) ones?

I've been looking around for some time and sadly there aren't that many options for pure programming podcasts. Most tend to focus on the industry or high level discussions about tech.

I recommend trying these:

Programming Throwdown
Casual programming talk. Each episode features a tech or programming language. Unfortunately they usually spend most of the time talking about personal life and tangential things, leaving the main topic to 10-15 minutes at the end but it's still fairly enjoyable I guess.

Cppcast
As the name hints, this podcast is focused on c++. Since I only found out about it a few weeks ago I haven't had a chance to listen to many episodes yet but production seems to be of high quality. They often have high profile guests which some might find interesting.

Jeff and Casey show
I like this show because it's fun and entertaining. It's the least focused on programming out of these three - some episodes don't even touch on the subject. Also I think it might be discontinued or put on hold but there's still an archive of many episodes available.
 

Einherjar

Member
Some stupid idea... Instead of guessing where to click, wouldn't the other way around simpler? Track your own character, click in a spiralling curve around it, and stop when you detect that a you've a lock by detecting the health bar?

Then my character would move randomly spazzing and be very bot-like haha.
 

NotBacon

Member
I've been looking around for some time and sadly there aren't that many options for pure programming podcasts. Most tend to focus on the industry or high level discussions about tech.

I recommend trying these:

Programming Throwdown
Casual programming talk. Each episode features a tech or programming language. Unfortunately they usually spend most of the time talking about personal life and tangential things, leaving the main topic to 10-15 minutes at the end but it's still fairly enjoyable I guess.

Cppcast
As the name hints, this podcast is focused on c++. Since I only found out about it a few weeks ago I haven't had a chance to listen to many episodes yet but production seems to be of high quality. They often have high profile guests which some might find interesting.

Jeff and Casey show
I like this show because it's fun and entertaining. It's the least focused on programming out of these three - some episodes don't even touch on the subject. Also I think it might be discontinued or put on hold but there's still an archive of many episodes available.

Awesome thanks. Cppcast is very informative and........ soothing.
 
I thought I understood polymorphism but it appears I don't. I'm in a bit of a pickle.

I have the Room class.

Rooms have a pointer to another room.

So lets say I have the generic room.

Code:
Room

has a private member variable. A pointer to another room.

Room *roomPoint; 

And these functions

getInfo()
{
cout << "This is a generic room" << endl;
}


nextRoom()
{

return roomPoint;
}

Now I have the bathroom. Its the same as the above. But the getinfo displays "this is a bathroom".

The trouble is if I do this in main

Code:
int main()

Room r1;
Bathroom b1;

Room* currentRoom;

r1's roomPointer set to point to b1. 

currentRoom = r1.

currentRoom->getInfo(). This couts the generic message.

Now if I do

currentRoom = currentRoom->nextRoom();

currentRoom should now be pointing to the bathroom. In fact I have confirmed it DOES point to the bathroom.

but if I do

currentRoom->getInfo() it still couts the generic message. It isn't using the overwritten "getInfo" function

So yeah... somehow I'm making a mistake and I'm not getting polymorphic behavior despite working with pointers.
 

Zoe

Member
Why is it so hard to find database people who know how to create stored procedures. Are sprocs really that rare?
 

Kalnos

Banned
I wrote sprocs at my first job but ever since then I have worked with ORMs. No idea why a dba(?) wouldn't be able to write a sproc.... but I only use them if they're legacy or the query is really complex.
 
Top Bottom