Status: Release/Final
Language: C++
Platform: Linux
Downloads: 128
Raptor is a program that I had to write for my Object-Oriented Programming class. It was difficult because we had to write it on a Linux server over telnet. It was supposedly a group project, but (and I'm not trying to have too great an ego here) I knew my skills and ambition would exceed that of most of my classmates. Besides, the majority of them were too busy playing World of Warcraft to write a week's worth of code. As the due date grew near and the slacker groups began to scramble to get some code done, I heard that they found my nearly finished program and were floored by my use of colors and grids (courtesy of the ncurses lib) and the fact that it actually worked. At the due date, my program was the only one completed.
The program is meant to simulate five prey and five raptors moving around a 20x20 grid. The raptors are obviously trying to eat the prey, but if they don't feed before 20 turns are up, then they will starve. The prey can see raptors in a 10x10 square around them; raptors can see infinitely horizontally, vertically, and diagonally (like a queen in chess). They all get to move in groups by one square per turn. All the prey on a square are eaten if a raptor lands on that square.
The AI is very simple. Still, for the simplicity of the rules, they do rather well. Thus, the prey ...
Raptor is a program that I had to write for my Object-Oriented Programming class. It was difficult because we had to write it on a Linux server over telnet. It was supposedly a group project, but (and I'm not trying to have too great an ego here) I knew my skills and ambition would exceed that of most of my classmates. Besides, the majority of them were too busy playing World of Warcraft to write a week's worth of code. As the due date grew near and the slacker groups began to scramble to get some code done, I heard that they found my nearly finished program and were floored by my use of colors and grids (courtesy of the ncurses lib) and the fact that it actually worked. At the due date, my program was the only one completed.
The program is meant to simulate five prey and five raptors moving around a 20x20 grid. The raptors are obviously trying to eat the prey, but if they don't feed before 20 turns are up, then they will starve. The prey can see raptors in a 10x10 square around them; raptors can see infinitely horizontally, vertically, and diagonally (like a queen in chess). They all get to move in groups by one square per turn. All the prey on a square are eaten if a raptor lands on that square.
The AI is very simple. Still, for the simplicity of the rules, they do rather well. Thus, the prey will almost always get eaten in the corners. I only had time to make the prey move from multiple raptors, but they can still get sandwiched between two raptors or a raptor and a wall (I was still working on the math to avoid that). Raptors will move to the closest prey that they see and will continue in the direction they last saw a prey if it moves out of sight (unless they see another prey).
Since this program is just a skills demo and not a lot of people have a Linux machine just lying around, I provided a demo video done in DivX VBR. But the source and compiled program are also available. It needs all the standard C libraries as well as ncurses. The program has two debug command line arguments. Use /d to display prey coordinates on the info line. Use /d and /r to do the same thing but for raptors.
Raptor Program/Source | 65 Downloads |
|
Download |
|
|