Jump to content

for a quick challenge. Say you have a graph of n points in cartesian. now find the shortest path to cover them all :D (its not nearest neighbour)

"Unofficially Official" Leading Scientific Research and Development Officer of the Official Star Citizen LTT Conglomerate | Reaper Squad, Idris Captain | 1x Aurora LN


Game developer, AI researcher, Developing the UOLTT mobile apps


G SIX [My Mac Pro G5 CaseMod Thread]

Link to post
Share on other sites

What you could teach, although they aren't exactly programs by themselves:

data structures

sorting algorithms

graphs

etc.

 

Another idea :

Maybe a snake game? I tried it myself recently and it works really well with OOP.

http://linustechtips.com/main/topic/472371-snake-game-in-c-and-sfml/

That's going to take more than half an hour probably.

i5 4670k @ 4.2GHz (Coolermaster Hyper 212 Evo); ASrock Z87 EXTREME4; 8GB Kingston HyperX Beast DDR3 RAM @ 2133MHz; Asus DirectCU GTX 560; Super Flower Golden King 550 Platinum PSU;1TB Seagate Barracuda;Corsair 200r case. 

Link to post
Share on other sites

for a quick challenge. Say you have a graph of n points in cartesian. now find the shortest path to cover them all :D (its not nearest neighbour)

I'd have to do test cases of 14 or less ._. 15 goes to a 7 min run time (if I remember correctly)

GIGABYTE Z97MX-G516GB DDR3 | I5 4690k @ 4.4ghz | 1TB SSHD, 500GB HDD, 128GB SSD | GTX 1070 8GB | Corsair Graphite 230 | EVGA 650W | Hyper 212 EVO

 

Cinebench R15: 636(all cores), 127FPS

 

Link to post
Share on other sites

What you could teach, although they aren't exactly programs by themselves:

data structures

sorting algorithms

graphs

etc.

 

Another idea :

Maybe a snake game? I tried it myself recently and it works really well with OOP.

http://linustechtips.com/main/topic/472371-snake-game-in-c-and-sfml/

That's going to take more than half an hour probably.

I actually wanted to do pong earlier, but then I realized I need hit detection, which I don't know yet (Still taking computer graphics).

GIGABYTE Z97MX-G516GB DDR3 | I5 4690k @ 4.4ghz | 1TB SSHD, 500GB HDD, 128GB SSD | GTX 1070 8GB | Corsair Graphite 230 | EVGA 650W | Hyper 212 EVO

 

Cinebench R15: 636(all cores), 127FPS

 

Link to post
Share on other sites

yes, but this program can do it EVEN FASTER!

... Lord Gaben help us all *cowers in fear*

GIGABYTE Z97MX-G516GB DDR3 | I5 4690k @ 4.4ghz | 1TB SSHD, 500GB HDD, 128GB SSD | GTX 1070 8GB | Corsair Graphite 230 | EVGA 650W | Hyper 212 EVO

 

Cinebench R15: 636(all cores), 127FPS

 

Link to post
Share on other sites

I'd have to do test cases of 14 or less ._. 15 goes to a 7 min run time (if I remember correctly)

well if you do it smart, its only O(n22n)... bruteforcing is O(n!)

"Unofficially Official" Leading Scientific Research and Development Officer of the Official Star Citizen LTT Conglomerate | Reaper Squad, Idris Captain | 1x Aurora LN


Game developer, AI researcher, Developing the UOLTT mobile apps


G SIX [My Mac Pro G5 CaseMod Thread]

Link to post
Share on other sites

well if you do it smart, its only O(n22n)... bruteforcing is O(n!)

Funny you mention this though...

I've been thinking about ways to "beat" nearest neighbor... Currently have something that MIGHT work, but has double the run time of NN. (n^2-n)/2 VS n^2-n

But, from the hand drawn tests I've done, it gets the same route OR better. Never worse. Mind you, I've only done test cases with up to 8 nodes because doing 10 nodes by hand is horrid with the method I'm using.

GIGABYTE Z97MX-G516GB DDR3 | I5 4690k @ 4.4ghz | 1TB SSHD, 500GB HDD, 128GB SSD | GTX 1070 8GB | Corsair Graphite 230 | EVGA 650W | Hyper 212 EVO

 

Cinebench R15: 636(all cores), 127FPS

 

Link to post
Share on other sites

Hm...the fractal one could be cool (it's not super hard to do a Koch snowflake if you're reasonably handy with graphs--it's very easy to do with recursion).  I've done that very thing in Python, but it would be cool to see it done in C++ for comparison.

 

A random walk generator in N dimensions, capable of doing multiple walks, and plotting them all over each other as A) actual paths and/or B) a heatmap, color-coded by how often a point was visited by any of the walks.  And then, maybe, a random walk that's weighted so it tends towards, say, a ring or a circle or the like.

Link to post
Share on other sites

Hm...the fractal one could be cool (it's not super hard to do a Koch snowflake if you're reasonably handy with graphs--it's very easy to do with recursion).  I've done that very thing in Python, but it would be cool to see it done in C++ for comparison.

 

A random walk generator in N dimensions, capable of doing multiple walks, and plotting them all over each other as A) actual paths and/or B) a heatmap, color-coded by how often a point was visited by any of the walks.  And then, maybe, a random walk that's weighted so it tends towards, say, a ring or a circle or the like.

Fractal will probably be done in the future.

Not sure what you are suggesting in the second part aside from the heat-map side of it.

GIGABYTE Z97MX-G516GB DDR3 | I5 4690k @ 4.4ghz | 1TB SSHD, 500GB HDD, 128GB SSD | GTX 1070 8GB | Corsair Graphite 230 | EVGA 650W | Hyper 212 EVO

 

Cinebench R15: 636(all cores), 127FPS

 

Link to post
Share on other sites

I actually wanted to do pong earlier, but then I realized I need hit detection, which I don't know yet (Still taking computer graphics).

Snake is really simple and straight-forward.

i5 4670k @ 4.2GHz (Coolermaster Hyper 212 Evo); ASrock Z87 EXTREME4; 8GB Kingston HyperX Beast DDR3 RAM @ 2133MHz; Asus DirectCU GTX 560; Super Flower Golden King 550 Platinum PSU;1TB Seagate Barracuda;Corsair 200r case. 

Link to post
Share on other sites

Snake is really simple and straight-forward.

Aside from the fact that I don't have hit detection yet <.<

GIGABYTE Z97MX-G516GB DDR3 | I5 4690k @ 4.4ghz | 1TB SSHD, 500GB HDD, 128GB SSD | GTX 1070 8GB | Corsair Graphite 230 | EVGA 650W | Hyper 212 EVO

 

Cinebench R15: 636(all cores), 127FPS

 

Link to post
Share on other sites

Aside from the fact that I don't have hit detection yet <.<

You don't need hit detection for snake.

i5 4670k @ 4.2GHz (Coolermaster Hyper 212 Evo); ASrock Z87 EXTREME4; 8GB Kingston HyperX Beast DDR3 RAM @ 2133MHz; Asus DirectCU GTX 560; Super Flower Golden King 550 Platinum PSU;1TB Seagate Barracuda;Corsair 200r case. 

Link to post
Share on other sites

You don't need hit detection for snake.

Walls? Eating the "food"?

I know a way to go around that, but hit-detection would make it so much easier.

GIGABYTE Z97MX-G516GB DDR3 | I5 4690k @ 4.4ghz | 1TB SSHD, 500GB HDD, 128GB SSD | GTX 1070 8GB | Corsair Graphite 230 | EVGA 650W | Hyper 212 EVO

 

Cinebench R15: 636(all cores), 127FPS

 

Link to post
Share on other sites

Walls? Eating the "food"?

I know a way to go around that, but hit-detection would make it so much easier.

Just forward-check the position before moving.

Calculate new position from player inputIf the new position is already occupied by a wall or another snake element , then it's game over.Otherwise: 1.if the new position is occupied by food , then you need to increment the size of the snake and generate a new piece of food.2.Move to the new position

i5 4670k @ 4.2GHz (Coolermaster Hyper 212 Evo); ASrock Z87 EXTREME4; 8GB Kingston HyperX Beast DDR3 RAM @ 2133MHz; Asus DirectCU GTX 560; Super Flower Golden King 550 Platinum PSU;1TB Seagate Barracuda;Corsair 200r case. 

Link to post
Share on other sites

 

Just forward-check the position before moving.

Calculate new position from player inputIf the new position is already occupied by a wall or another snake element , then it's game over.Otherwise: 1.if the new position is occupied by food , then you need to increment the size of the snake and generate a new piece of food.2.Move to the new position

True, but I doubt with my currently limited knowledge that I'd be able to do snake in <30 mins.

GIGABYTE Z97MX-G516GB DDR3 | I5 4690k @ 4.4ghz | 1TB SSHD, 500GB HDD, 128GB SSD | GTX 1070 8GB | Corsair Graphite 230 | EVGA 650W | Hyper 212 EVO

 

Cinebench R15: 636(all cores), 127FPS

 

Link to post
Share on other sites

True, but I doubt with my currently limited knowledge that I'd be able to do snake in <30 mins.

Unless you plan ahead, probably no.

i5 4670k @ 4.2GHz (Coolermaster Hyper 212 Evo); ASrock Z87 EXTREME4; 8GB Kingston HyperX Beast DDR3 RAM @ 2133MHz; Asus DirectCU GTX 560; Super Flower Golden King 550 Platinum PSU;1TB Seagate Barracuda;Corsair 200r case. 

Link to post
Share on other sites

Unless you plan ahead, probably no.

Thing is, aside from pre-defined commands, No code is to be written before hand.

GIGABYTE Z97MX-G516GB DDR3 | I5 4690k @ 4.4ghz | 1TB SSHD, 500GB HDD, 128GB SSD | GTX 1070 8GB | Corsair Graphite 230 | EVGA 650W | Hyper 212 EVO

 

Cinebench R15: 636(all cores), 127FPS

 

Link to post
Share on other sites

Fractal will probably be done in the future.

Not sure what you are suggesting in the second part aside from the heat-map side of it.

Ah, then let's see if I can make a bit more sense.

 

A program that plots a series of random walks in, say, two dimensions.  (Random walk = start at a given location, then take a step of some size in a random direction, rinse and repeat.  in 2D, this usually is taken to mean "move one step up/down/left/right"; usually, this is implemented by starting with an X and Y value of 0 and 0, then randomly selecting one of them and either adding or subtracting 1, then repeating on the new X and Y values).  A program that does a random walk, starting at (0,0), and then plots it, can make some interesting shapes if you make it do a lot of steps.  Then, if you do multiple random walks--one after another--and plot all of them at the same time, you can get yet another pretty cool looking plot out of it for a large number of steps.  Plotting a heatmap of a few walks, rather than plotting them as lines/paths, ends up looking kind of like a galaxy or big old cluster of stars if you do a grayscale colormap.  Then you can think about "weighting" it so that steps in some directions are more likely given some condition, e.g., a step downwards becomes more likely than a step upwards if the current point's Y value is higher than some pre-defined value.

 

If that still makes no sense, then don't worry about it.  It's admittedly just as much a math problem/application as it is a coding one, but that's the sort of stuff I love doing with programming.  (I've done something similar in Python, like with the Koch snowflake, and would just be interested to see how a C++ program compares).  But, there's a reasonable chance it'll spiral out of hand, so take it as more of a light suggestion than a serious request. :P

Link to post
Share on other sites

Thing is, aside from pre-defined commands, No code is to be written before hand.

Not the code , rather how to do things. Like...what is the snake? It's basically a list/vector of "elements". Ok then , what should each element hold? Its position and a texture/color/shape. Anyway, this is if you do it object oriented.

i5 4670k @ 4.2GHz (Coolermaster Hyper 212 Evo); ASrock Z87 EXTREME4; 8GB Kingston HyperX Beast DDR3 RAM @ 2133MHz; Asus DirectCU GTX 560; Super Flower Golden King 550 Platinum PSU;1TB Seagate Barracuda;Corsair 200r case. 

Link to post
Share on other sites

Ah, then let's see if I can make a bit more sense.

 

A program that plots a series of random walks in, say, two dimensions.  (Random walk = start at a given location, then take a step of some size in a random direction, rinse and repeat.  in 2D, this usually is taken to mean "move one step up/down/left/right"; usually, this is implemented by starting with an X and Y value of 0 and 0, then randomly selecting one of them and either adding or subtracting 1, then repeating on the new X and Y values).  A program that does a random walk, starting at (0,0), and then plots it, can make some interesting shapes if you make it do a lot of steps.  Then, if you do multiple random walks--one after another--and plot all of them at the same time, you can get yet another pretty cool looking plot out of it for a large number of steps.  Plotting a heatmap of a few walks, rather than plotting them as lines/paths, ends up looking kind of like a galaxy or big old cluster of stars if you do a grayscale colormap.  Then you can think about "weighting" it so that steps in some directions are more likely given some condition, e.g., a step downwards becomes more likely than a step upwards if the current point's Y value is higher than some pre-defined value.

 

If that still makes no sense, then don't worry about it.  It's admittedly just as much a math problem/application as it is a coding one, but that's the sort of stuff I love doing with programming.  (I've done something similar in Python, like with the Koch snowflake, and would just be interested to see how a C++ program compares).  But, there's a reasonable chance it'll spiral out of hand, so take it as more of a light suggestion than a serious request. :P

I kinda like that idea!

GIGABYTE Z97MX-G516GB DDR3 | I5 4690k @ 4.4ghz | 1TB SSHD, 500GB HDD, 128GB SSD | GTX 1070 8GB | Corsair Graphite 230 | EVGA 650W | Hyper 212 EVO

 

Cinebench R15: 636(all cores), 127FPS

 

Link to post
Share on other sites

Not the code , rather how to do things. Like...what is the snake? It's basically a list/vector of "elements". Ok then , what should each element hold? Its position and a texture/color/shape. Anyway, this is if you do it object oriented.

I'll think about it.

GIGABYTE Z97MX-G516GB DDR3 | I5 4690k @ 4.4ghz | 1TB SSHD, 500GB HDD, 128GB SSD | GTX 1070 8GB | Corsair Graphite 230 | EVGA 650W | Hyper 212 EVO

 

Cinebench R15: 636(all cores), 127FPS

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×