The first descent code I wrote in my life
-
Roger Wright wrote:
entering them with 8 toggle switches
Ah, the good old days. I did that on a PDP-11/05 at school. The machine had an 80 word bootstrap that was fairly easy to wipe by accident, so you had to fat-finger it in via the front panel switches. I only had to do it once or twice, and it took me a few minutes. Reportedly there was a guy who could do it in less than 60 seconds. If you think about it, though, that implied if you became practiced at it, your code was pretty bad to create the problem in the first place.
Software Zen:
delete this;
Hehehe... My bootstrap loader, once I got the whole package punched to paper tape, was only 16 bytes, so it wasn't too laborious to enter. The real challenge was the first time. Power wasn't all that reliable, and it seemed that every time I got close to loading the entire system, the power blinked. Then it would fail while I was trying to punch the image to tape. All in all, it took about 6 days to finally get the first version entered into RAM and successfully punched to tape. After that it was smooth sailing, since I could do maintenance and extensions to the system using my assembler. That was a great feeling! :-D
Will Rogers never met me.
-
Hehehe... My bootstrap loader, once I got the whole package punched to paper tape, was only 16 bytes, so it wasn't too laborious to enter. The real challenge was the first time. Power wasn't all that reliable, and it seemed that every time I got close to loading the entire system, the power blinked. Then it would fail while I was trying to punch the image to tape. All in all, it took about 6 days to finally get the first version entered into RAM and successfully punched to tape. After that it was smooth sailing, since I could do maintenance and extensions to the system using my assembler. That was a great feeling! :-D
Will Rogers never met me.
My step-dad had a COSMAC ELF[^] single-board computer with 2K RAM on board. We fat-fingered in a 1.5K Tiny Basic interpreter (which took forever). He rigged up a battery backup using an old car battery, which kept the thing alive for months at a time.
Software Zen:
delete this;
-
You know you can do this with intersecting vectors right? : )
Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost "All users always want Excel" --Ennis Lynch
yes but that is the same than killing an ant with a bazooka
-
yes but that is the same than killing an ant with a bazooka
Splatting an ant can be great fun.
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier
-
Splatting an ant can be great fun.
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier
What about the ole' magnifying glass approach? The only downside is that you typically had to look away when it just started to get good.
-
I was able to boil that down to 3 lines. I'd show you the code, but then I'd have to charge you for it. :-D
The correct comeback should be "I can get it down to 3 lines but there's not enough room in the margin to write it".
cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP
-
My step-dad had a COSMAC ELF[^] single-board computer with 2K RAM on board. We fat-fingered in a 1.5K Tiny Basic interpreter (which took forever). He rigged up a battery backup using an old car battery, which kept the thing alive for months at a time.
Software Zen:
delete this;
Gary Wheeler wrote:
rigged up a battery backup using an old car battery
Great thought! I considered something like that, but the 8080 needed +5, +12, and -12 Vdc, and it just didn't seem practical at the time. In retrospect, it would have been a heck of a lot cheaper than wasting my time for so many days. :doh:
Will Rogers never met me.
-
Mine took 7.5 million years to execute and simply said "42". :-\
Cap duly doffed!
Sort of a cross between Lawrence of Arabia and Dilbert.[^]
-Or-
A Dead ringer for Kate Winslett[^] -
The correct comeback should be "I can get it down to 3 lines but there's not enough room in the margin to write it".
cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP
Please give yourself 5points for that ;)
MVVM# - See how I did MVVM my way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')
-
The correct comeback should be "I can get it down to 3 lines but there's not enough room in the margin to write it".
cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP
hahaahhah, perfect I wish I could vote you up. That remember me when I was in high school back in my home country, in a very selected high school I pissed a friend of mine because I could write an algorithm finding the pithagoric numbers in less lines than him and he was so frustrated that he began making the hole program in one line, but the line was verrrryyy long,
-
Gary Wheeler wrote:
rigged up a battery backup using an old car battery
Great thought! I considered something like that, but the 8080 needed +5, +12, and -12 Vdc, and it just didn't seem practical at the time. In retrospect, it would have been a heck of a lot cheaper than wasting my time for so many days. :doh:
Will Rogers never met me.
My step-dad's a E.E. and a genuine Renaissance man in terms of being handy at these sorts of things.
Software Zen:
delete this;
-
My step-dad's a E.E. and a genuine Renaissance man in terms of being handy at these sorts of things.
Software Zen:
delete this;
Yeah, we E.E.s are handy that way. :-D
Will Rogers never met me.
-
Mine took 7.5 million years to execute and simply said "42". :-\
After waiting that long, I bet you can't even remember the question correctly... ;P
Will Rogers never met me.
-
After waiting that long, I bet you can't even remember the question correctly... ;P
Will Rogers never met me.
How many whores must a man...? No. How many toads...? Hmmm... I shoulda put it in a comment. :sigh:
-
How many whores must a man...? No. How many toads...? Hmmm... I shoulda put it in a comment. :sigh:
:laugh: :laugh: :laugh:
Will Rogers never met me.
-
This is the first descent code I wrote when I began to make programs, it was in C++ Is about an algorithm to arrangle ships in a classic battleship game, first funcion is to check if a ship can be placed at x;y second is for placing the ship and 3th was for placing all the ships. I was so amazed that the code worked that I felt a joy I only felt few times since then. How about you
//------Check if in square X;Y a ship can be placed------------------
/* x,y: Board coordinates
Size: Ship size
Pos: posicion (1 horizontal vertical)
board: board number
*/
bool TGame::Free(int x,int y,int size,int pos,int board )
{
int ship[7];
int side1[7];
int side2[7];
bool answer=true;
if(aBoard[board]->GetInfo(x,y)!=0)
{
return answer=false;
}
if (pos==1)
{
for(int i=0;i<size+2;i++)
{ship[i]=aBoard[board]->GetInfo(x-1+i,y);
side1[i]=aBoard[board]->GetInfo(x-1+i,y-1);
side2[i]=aBoard[board]->GetInfo(x-1+i,y+1);
}
}else
{ for(int i=0;i<size+2;i++)
{ship[i]=aBoard[board]->GetInfo(x,y-1+i);
side1[i]=aBoard[board]->GetInfo(x-1,y-1+i);
side2[i]=aBoard[board]->GetInfo(x+1,y-1+i);
}
}
if (x==0 && pos==1)
{ship[0]=0;
side1[0]=0;
side2[0]=0;}
for (int i=0;i<size+2;i++)
{if (ship[i]!= 0)answer=false;
if (side1[i]!= 0)answer=false;
if (side2[i]!= 0)answer=false;
}
return answer;
}
//------Place a ship in the board-------------------------------------/* Size: Ship size
board: Board
Ship: Place of the ship in the ship array
Type: ship type
*/
void TGame:: RandomShip(int size,int type,int board,int ship)
{
int pos=random(2);
randomize();
int x,y;
bool answer=false; ;
if (pos==1)
{
while (answer==false)
{
x=random(11)-size;
while(x<0)
{x=random(11)-size;
}
y=random(15);
answer=Free(x,y,size,pos,board);
}
for(int i=0;i<size;i++)
{aBoard[board]->SetInfo(x+i,y,type);
}
}
else
{
while (answer==false)
{
x=random(10);
y=random(16)-size;
while(y<0)
{y=random(16)-size;
}
answer=Free(x,y,size,pos,board);
}
for(int i=0;i<size;i++)
{aBoard[board]->SetInfo(x,y+i,type);
}
}
if(board==0)
{
int ax=TransfoGreat game, Descent. My first was a database for text scraps, in COBOL.
I wanna be a eunuchs developer! Pass me a bread knife!
-
This is the first descent code I wrote when I began to make programs, it was in C++ Is about an algorithm to arrangle ships in a classic battleship game, first funcion is to check if a ship can be placed at x;y second is for placing the ship and 3th was for placing all the ships. I was so amazed that the code worked that I felt a joy I only felt few times since then. How about you
//------Check if in square X;Y a ship can be placed------------------
/* x,y: Board coordinates
Size: Ship size
Pos: posicion (1 horizontal vertical)
board: board number
*/
bool TGame::Free(int x,int y,int size,int pos,int board )
{
int ship[7];
int side1[7];
int side2[7];
bool answer=true;
if(aBoard[board]->GetInfo(x,y)!=0)
{
return answer=false;
}
if (pos==1)
{
for(int i=0;i<size+2;i++)
{ship[i]=aBoard[board]->GetInfo(x-1+i,y);
side1[i]=aBoard[board]->GetInfo(x-1+i,y-1);
side2[i]=aBoard[board]->GetInfo(x-1+i,y+1);
}
}else
{ for(int i=0;i<size+2;i++)
{ship[i]=aBoard[board]->GetInfo(x,y-1+i);
side1[i]=aBoard[board]->GetInfo(x-1,y-1+i);
side2[i]=aBoard[board]->GetInfo(x+1,y-1+i);
}
}
if (x==0 && pos==1)
{ship[0]=0;
side1[0]=0;
side2[0]=0;}
for (int i=0;i<size+2;i++)
{if (ship[i]!= 0)answer=false;
if (side1[i]!= 0)answer=false;
if (side2[i]!= 0)answer=false;
}
return answer;
}
//------Place a ship in the board-------------------------------------/* Size: Ship size
board: Board
Ship: Place of the ship in the ship array
Type: ship type
*/
void TGame:: RandomShip(int size,int type,int board,int ship)
{
int pos=random(2);
randomize();
int x,y;
bool answer=false; ;
if (pos==1)
{
while (answer==false)
{
x=random(11)-size;
while(x<0)
{x=random(11)-size;
}
y=random(15);
answer=Free(x,y,size,pos,board);
}
for(int i=0;i<size;i++)
{aBoard[board]->SetInfo(x+i,y,type);
}
}
else
{
while (answer==false)
{
x=random(10);
y=random(16)-size;
while(y<0)
{y=random(16)-size;
}
answer=Free(x,y,size,pos,board);
}
for(int i=0;i<size;i++)
{aBoard[board]->SetInfo(x,y+i,type);
}
}
if(board==0)
{
int ax=TransfoUnfortunately my first decent code is lost forever. It was a game of Reversi/Othello running on a Tandy TRS-80 and which would fit into the default 4kB RAM (yes those are kilobytes). To make it fit I had to do an inordinate amount of variable re-usage and multi-purpose sub-routines, but it worked and could beat an intermediate player. If you gave it a couple of corner squares to start with it would beat anybody. I remember paying £120 to upgrade the RAM to 16 KB so that I could write/run a business simulator - how times have changed... or have they?
-
This is the first descent code I wrote when I began to make programs, it was in C++ Is about an algorithm to arrangle ships in a classic battleship game, first funcion is to check if a ship can be placed at x;y second is for placing the ship and 3th was for placing all the ships. I was so amazed that the code worked that I felt a joy I only felt few times since then. How about you
//------Check if in square X;Y a ship can be placed------------------
/* x,y: Board coordinates
Size: Ship size
Pos: posicion (1 horizontal vertical)
board: board number
*/
bool TGame::Free(int x,int y,int size,int pos,int board )
{
int ship[7];
int side1[7];
int side2[7];
bool answer=true;
if(aBoard[board]->GetInfo(x,y)!=0)
{
return answer=false;
}
if (pos==1)
{
for(int i=0;i<size+2;i++)
{ship[i]=aBoard[board]->GetInfo(x-1+i,y);
side1[i]=aBoard[board]->GetInfo(x-1+i,y-1);
side2[i]=aBoard[board]->GetInfo(x-1+i,y+1);
}
}else
{ for(int i=0;i<size+2;i++)
{ship[i]=aBoard[board]->GetInfo(x,y-1+i);
side1[i]=aBoard[board]->GetInfo(x-1,y-1+i);
side2[i]=aBoard[board]->GetInfo(x+1,y-1+i);
}
}
if (x==0 && pos==1)
{ship[0]=0;
side1[0]=0;
side2[0]=0;}
for (int i=0;i<size+2;i++)
{if (ship[i]!= 0)answer=false;
if (side1[i]!= 0)answer=false;
if (side2[i]!= 0)answer=false;
}
return answer;
}
//------Place a ship in the board-------------------------------------/* Size: Ship size
board: Board
Ship: Place of the ship in the ship array
Type: ship type
*/
void TGame:: RandomShip(int size,int type,int board,int ship)
{
int pos=random(2);
randomize();
int x,y;
bool answer=false; ;
if (pos==1)
{
while (answer==false)
{
x=random(11)-size;
while(x<0)
{x=random(11)-size;
}
y=random(15);
answer=Free(x,y,size,pos,board);
}
for(int i=0;i<size;i++)
{aBoard[board]->SetInfo(x+i,y,type);
}
}
else
{
while (answer==false)
{
x=random(10);
y=random(16)-size;
while(y<0)
{y=random(16)-size;
}
answer=Free(x,y,size,pos,board);
}
for(int i=0;i<size;i++)
{aBoard[board]->SetInfo(x,y+i,type);
}
}
if(board==0)
{
int ax=Transfo -
This is the first descent code I wrote when I began to make programs, it was in C++ Is about an algorithm to arrangle ships in a classic battleship game, first funcion is to check if a ship can be placed at x;y second is for placing the ship and 3th was for placing all the ships. I was so amazed that the code worked that I felt a joy I only felt few times since then. How about you
//------Check if in square X;Y a ship can be placed------------------
/* x,y: Board coordinates
Size: Ship size
Pos: posicion (1 horizontal vertical)
board: board number
*/
bool TGame::Free(int x,int y,int size,int pos,int board )
{
int ship[7];
int side1[7];
int side2[7];
bool answer=true;
if(aBoard[board]->GetInfo(x,y)!=0)
{
return answer=false;
}
if (pos==1)
{
for(int i=0;i<size+2;i++)
{ship[i]=aBoard[board]->GetInfo(x-1+i,y);
side1[i]=aBoard[board]->GetInfo(x-1+i,y-1);
side2[i]=aBoard[board]->GetInfo(x-1+i,y+1);
}
}else
{ for(int i=0;i<size+2;i++)
{ship[i]=aBoard[board]->GetInfo(x,y-1+i);
side1[i]=aBoard[board]->GetInfo(x-1,y-1+i);
side2[i]=aBoard[board]->GetInfo(x+1,y-1+i);
}
}
if (x==0 && pos==1)
{ship[0]=0;
side1[0]=0;
side2[0]=0;}
for (int i=0;i<size+2;i++)
{if (ship[i]!= 0)answer=false;
if (side1[i]!= 0)answer=false;
if (side2[i]!= 0)answer=false;
}
return answer;
}
//------Place a ship in the board-------------------------------------/* Size: Ship size
board: Board
Ship: Place of the ship in the ship array
Type: ship type
*/
void TGame:: RandomShip(int size,int type,int board,int ship)
{
int pos=random(2);
randomize();
int x,y;
bool answer=false; ;
if (pos==1)
{
while (answer==false)
{
x=random(11)-size;
while(x<0)
{x=random(11)-size;
}
y=random(15);
answer=Free(x,y,size,pos,board);
}
for(int i=0;i<size;i++)
{aBoard[board]->SetInfo(x+i,y,type);
}
}
else
{
while (answer==false)
{
x=random(10);
y=random(16)-size;
while(y<0)
{y=random(16)-size;
}
answer=Free(x,y,size,pos,board);
}
for(int i=0;i<size;i++)
{aBoard[board]->SetInfo(x,y+i,type);
}
}
if(board==0)
{
int ax=TransfoMy first "decent" code? Well that would omit all the programs I wrote to auto-generate porn using nothing but ASCII characters, wouldn't it?
But seriously, it's been so long that my first respectable code is lost to the mists of history, so I'll regale you with the earliest relevant story I can remember: Assembly-language programming on a Data General NOVA 1200.
At the time I worked for a division of General Instrument that no longer exists. It made and sold "payments processing" systems that employed some rather delicate proprietary electro-mechanical "workstations." The principal function of a workstation was to read a "turnaround document:" the sort of paper slip you'd detach from your phone bill -- carefully! You know how treacherous perforations can be! -- and mail back to the phone company with your monthly payment.
The workstation used OCR techniques which, for that era, were pretty sophisticated, but which nevertheless had only about a 90% efficacy rate. There were some turnaround documents the workstation just couldn't read, but which had to be processed anyway. So there was a second device in the system to cover that need: a "key entry station" or KES much like an ASR-33 teletype.
Of course, an operator keying in strings of digits from a turnaround document is even more error-prone than an OCR-capable machine. Therefore, part of the processing of KES input involved verifying it, using check digits buried in the account numbers on the document. There was a large, kludgy module built into the system for that purpose: large, because the system was a patchwork put together by many programmers over many years; kludgy, because none of the people who'd worked on it believed in commenting their code, and all of them feared to delete anything that might be important to someone else...even if it had been definitively obsoleted.
I was young and foolish, back then. I volunteered to redo that module, and was given the green light to do so.
It took awhile, as the NOVA 1200 was a very weak CPU: no hardware multiply or divide; only 32K 16-bit words of memory; only four registers; no hardware stack; and only four addressing modes, all of them extremely weak . Also, the module had to account for a range of check-digit and cross-verification techniques, from which each of our customers selected according to his preferences. But when I was finished, the module was smaller by 40% than its predecessor, and every instruction was commented in actual, legible English.
(In
-
This is the first descent code I wrote when I began to make programs, it was in C++ Is about an algorithm to arrangle ships in a classic battleship game, first funcion is to check if a ship can be placed at x;y second is for placing the ship and 3th was for placing all the ships. I was so amazed that the code worked that I felt a joy I only felt few times since then. How about you
//------Check if in square X;Y a ship can be placed------------------
/* x,y: Board coordinates
Size: Ship size
Pos: posicion (1 horizontal vertical)
board: board number
*/
bool TGame::Free(int x,int y,int size,int pos,int board )
{
int ship[7];
int side1[7];
int side2[7];
bool answer=true;
if(aBoard[board]->GetInfo(x,y)!=0)
{
return answer=false;
}
if (pos==1)
{
for(int i=0;i<size+2;i++)
{ship[i]=aBoard[board]->GetInfo(x-1+i,y);
side1[i]=aBoard[board]->GetInfo(x-1+i,y-1);
side2[i]=aBoard[board]->GetInfo(x-1+i,y+1);
}
}else
{ for(int i=0;i<size+2;i++)
{ship[i]=aBoard[board]->GetInfo(x,y-1+i);
side1[i]=aBoard[board]->GetInfo(x-1,y-1+i);
side2[i]=aBoard[board]->GetInfo(x+1,y-1+i);
}
}
if (x==0 && pos==1)
{ship[0]=0;
side1[0]=0;
side2[0]=0;}
for (int i=0;i<size+2;i++)
{if (ship[i]!= 0)answer=false;
if (side1[i]!= 0)answer=false;
if (side2[i]!= 0)answer=false;
}
return answer;
}
//------Place a ship in the board-------------------------------------/* Size: Ship size
board: Board
Ship: Place of the ship in the ship array
Type: ship type
*/
void TGame:: RandomShip(int size,int type,int board,int ship)
{
int pos=random(2);
randomize();
int x,y;
bool answer=false; ;
if (pos==1)
{
while (answer==false)
{
x=random(11)-size;
while(x<0)
{x=random(11)-size;
}
y=random(15);
answer=Free(x,y,size,pos,board);
}
for(int i=0;i<size;i++)
{aBoard[board]->SetInfo(x+i,y,type);
}
}
else
{
while (answer==false)
{
x=random(10);
y=random(16)-size;
while(y<0)
{y=random(16)-size;
}
answer=Free(x,y,size,pos,board);
}
for(int i=0;i<size;i++)
{aBoard[board]->SetInfo(x,y+i,type);
}
}
if(board==0)
{
int ax=TransfoJust out of college, I wanted to use something from the data structures class so wrote a right-inthreaded binary tree structure by hand to handle a large data set. Each unique number went to it's own leaf with a count. In the end, I could traverse the tree, generating a histogram and various statistics, st dev, etc as desired. I think it was in HP Basic predating the PC era at our workplace.