|
omgnoseat
|
 |
« on: June 14, 2012, 04:48:23 PM » |
|
Post up your solution to real life problems in abstract code. Bonus points for writing "real code" with existing classes used as metaphors for the things they represent. Here is my go: public function Solve() { for (i:int = 0; i < conflicts.length; ++i) { var cachedItem = MEMORY.cache[conflicts[i]].ID; if (cachedItem != null) { conflicts[i].resolve(cachedItem); }else { //TODO } } }
A nice cheesy one; Learning from past mistakes. - The conflicts represent the problems - The ID of the conflict represent the type of problem - The cache represents solutions to old problems Problem -> cache is checked for solution -> apply solution that has the same problem ID to old problem Another one: public function Compare() { entities.Sort ( delegate(Entity e1, Entity e2) { return p1.gender.CompareTo(p2.gender); } ); }
Bros before hoes. Yeah it's very late.
|
|
|
|
« Last Edit: June 15, 2012, 06:34:21 AM by omgnoseat »
|
Logged
|
|
|
|
|
zacaj
|
 |
« Reply #1 on: June 14, 2012, 04:53:54 PM » |
|
groundTime-- if touchingGround() groundTime=10
if spacebarPressed() and groundTime>0 yVelocity+=jumpSpeed*groundTime My super elegant jump code. Handles controllable height jumps and leeway on ledges. I hope I'm understanding the topic correctly...
|
|
|
|
|
Logged
|
My twitter: @zacaj_Well let's just take a look at this "getting started" page and see-- Download and install cmake
Noooooooo
|
|
|
|
eigenbom
|
 |
« Reply #2 on: June 14, 2012, 04:56:23 PM » |
|
while(alive){ read_lame_posts_on_tigsource(); } regret();

|
|
|
|
|
Logged
|
|
|
|
|
Maud'Dib Atreides
|
 |
« Reply #3 on: June 14, 2012, 05:39:24 PM » |
|
using System.ADHD;
public bool motivated = true; //Sweet, we're off to a good start
public void Main() {
while (motivated) { DrawPixelArt(ideas, quality); ProgramGame(ideas, quality); ideas -- ; quality -- ;
}
motivated = Convert.ToBoolean(ADHD.GetRandomNumber(0,1)); //Oh boy
}
|
|
|
|
« Last Edit: June 14, 2012, 05:46:14 PM by # »
|
Logged
|
Guy: Give me all of your money. Chap: You can't talk to me that way, I'M BRITISH! Guy: Well, You can't talk to me that way, I'm brutish. Chap: Somebody help me, I'm about to lose 300 pounds! Guy: Why's that a bad thing? Chap: I'M BRITISH.
|
|
|
|
zacaj
|
 |
« Reply #4 on: June 14, 2012, 05:41:53 PM » |
|
while (motivated or !motivated) work()
|
|
|
|
|
Logged
|
My twitter: @zacaj_Well let's just take a look at this "getting started" page and see-- Download and install cmake
Noooooooo
|
|
|
|
Morroque
|
 |
« Reply #5 on: June 14, 2012, 06:20:23 PM » |
|
|
|
|
|
|
Logged
|
|
|
|
|
omgnoseat
|
 |
« Reply #6 on: June 15, 2012, 06:34:11 AM » |
|
while(alive){ read_lame_posts_on_tigsource(); } regret();
 How is one able to regret when he is not alive? You clearly lack the skills for this complicated form of poetry  using System.ADHD;
public bool motivated = true; //Sweet, we're off to a good start
public void Main() {
while (motivated) { DrawPixelArt(ideas, quality); ProgramGame(ideas, quality); ideas -- ; quality -- ;
}
motivated = Convert.ToBoolean(ADHD.GetRandomNumber(0,1)); //Oh boy
}
I don't have ADHD, but I'm sure we all have moments like this haha. groundTime-- if touchingGround() groundTime=10
if spacebarPressed() and groundTime>0 yVelocity+=jumpSpeed*groundTime My super elegant jump code. Handles controllable height jumps and leeway on ledges. I hope I'm understanding the topic correctly... Sorry, you did not. But that piece of code is pretty handy nonetheless haha. This is brilliant.
|
|
|
|
|
Logged
|
|
|
|
|
Claw
|
 |
« Reply #7 on: June 15, 2012, 06:45:48 AM » |
|
using System.ADHD;
public bool motivated = true; //Sweet, we're off to a good start
public void Main() {
while (motivated) { DrawPixelArt(ideas, quality); ProgramGame(ideas, quality); ideas -- ; quality -- ;
}
motivated = Convert.ToBoolean(ADHD.GetRandomNumber(0,1)); //Oh boy
}
Shouldn't the motivated = randomnumber line be inside the while loop? Else you will always be motivated but your ideas and quality would run to minus infinity I may be taking this too seriously.
|
|
|
|
|
Logged
|
|
|
|
|
Morroque
|
 |
« Reply #8 on: June 15, 2012, 08:11:44 AM » |
|
Thank ye, kind sir. It was actually denied publication for the anthnology "Thinking Machines: Programmer Poets and Poems about Computers" on the editorial grounds of "damnit, I really want it in, but it would take up too many pages." Another two things of mine did get in. Here's one of 'em:  I kind of feel like this one was a bit half-assed, but for whatever reason the editor liked it.
|
|
|
|
|
Logged
|
|
|
|
|
Maud'Dib Atreides
|
 |
« Reply #9 on: June 15, 2012, 08:42:54 AM » |
|
using System.ADHD;
public bool motivated = true; //Sweet, we're off to a good start
public void Main() {
while (motivated) { DrawPixelArt(ideas, quality); ProgramGame(ideas, quality); ideas -- ; quality -- ;
}
motivated = Convert.ToBoolean(ADHD.GetRandomNumber(0,1)); //Oh boy
}
Shouldn't the motivated = randomnumber line be inside the while loop? Else you will always be motivated but your ideas and quality would run to minus infinity I may be taking this too seriously.No no you have a point. I was debating with myself about it before I posted while (motivated or !motivated) work()
LOL
|
|
|
|
|
Logged
|
Guy: Give me all of your money. Chap: You can't talk to me that way, I'M BRITISH! Guy: Well, You can't talk to me that way, I'm brutish. Chap: Somebody help me, I'm about to lose 300 pounds! Guy: Why's that a bad thing? Chap: I'M BRITISH.
|
|
|
|
Quarry
|
 |
« Reply #10 on: June 15, 2012, 09:42:52 AM » |
|
if (game.hasDesignFaults()) abandonProject(game);
|
|
|
|
|
Logged
|
|
|
|
|
JMickle
|
 |
« Reply #11 on: June 15, 2012, 12:38:12 PM » |
|
if (game.unfinished) exit;
|
|
|
|
|
Logged
|
|
|
|
|
kamac
|
 |
« Reply #12 on: June 15, 2012, 12:49:01 PM » |
|
if(ideas.count() < too_few) { int action = rand()%4; if(action < 2) Programmer.Have(NAP); else Programmer.Play(GAME); } @EDIT And bigger one. for(int n=0; n<problems.size(); n++) { int solved = problems[n].tryToSolve(Programmer.tired_level); if(solved == 1) { continue; } else { while(solved == 0) { Programmer.tired_level++; solved = problems[n].tryToSolve(Programmer.tired_level); if(solved == 0) { Programmer.Rage(); Programmer.Cry(); if(Programmer.tired_level >= Programmer.critic_tired_level) { Programmer.Have(NAP); Programmer.tired_level = 0; } } else { Programmer.WriteAPost(tigsource,happy_programmers_room,Programmer.ProblemSolvedString); } } } }
|
|
|
|
« Last Edit: June 15, 2012, 12:55:00 PM by kamac »
|
Logged
|
|
|
|
|
eigenbom
|
 |
« Reply #13 on: June 15, 2012, 03:14:18 PM » |
|
|
|
|
|
|
Logged
|
|
|
|
|
nikki
|
 |
« Reply #14 on: June 15, 2012, 03:22:43 PM » |
|
while ( not life.isDone() ) live( life) wend
|
|
|
|
|
Logged
|
|
|
|
|