Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
12 changed files
with
5,459 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <iostream> | ||
#include "randomvalues.h" | ||
|
||
/** A class for AI characters in a game. **/ | ||
class AI | ||
{ | ||
public: | ||
std::string name; | ||
int level; | ||
static int numAIs; | ||
|
||
AI() | ||
{ | ||
name = RandomValues().name(); | ||
level = 1; | ||
numAIs += 1; | ||
|
||
std::cout << "AI " << name << " created" << std::endl; | ||
} | ||
}; | ||
|
||
int AI::numAIs = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <iostream> | ||
#include "randomvalues.h" | ||
|
||
/** A class for AI characters in a game. **/ | ||
class AI | ||
{ | ||
public: | ||
std::string name; | ||
int level; | ||
static int numAIs; | ||
|
||
AI() | ||
{ | ||
name = RandomValues().name(); | ||
level = 1; | ||
numAIs += 1; | ||
|
||
std::cout << "AI " << name << " created" << std::endl; | ||
} | ||
}; | ||
|
||
int AI::numAIs = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <iostream> | ||
#include "randomvalues.h" | ||
|
||
/** A class for AI characters in a game. **/ | ||
class AI | ||
{ | ||
public: | ||
std::string name; | ||
int level; | ||
static int numAIs; | ||
|
||
AI() | ||
{ | ||
name = RandomValues().name(); | ||
level = 1; | ||
numAIs += 1; | ||
|
||
std::cout << "AI " << name << " created" << std::endl; | ||
} | ||
|
||
void say_hello() const | ||
{ | ||
std::cout << name << ":" | ||
<< " Hello! My name is " << name | ||
<< " I am level " << level << std::endl; | ||
} | ||
}; | ||
|
||
int AI::numAIs = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include <iostream> | ||
#include "randomvalues.h" | ||
|
||
/** A class for AI characters in a game. **/ | ||
class AI | ||
{ | ||
public: | ||
std::string name; | ||
int level; | ||
static int numAIs; | ||
|
||
AI() | ||
{ | ||
name = RandomValues().name(); | ||
level = 1; | ||
numAIs += 1; | ||
|
||
std::cout << "AI " << name << " created" << std::endl; | ||
} | ||
|
||
void say_hello() const | ||
{ | ||
std::cout << name << ":" | ||
<< " Hello! My name is " << name | ||
<< " I am level " << level << std::endl; | ||
} | ||
|
||
void increase_level( int num ) | ||
{ | ||
if( level + num >= 10 ) | ||
{ | ||
level = 10; | ||
std::cout << "Maximum level reached" << std::endl; | ||
} | ||
else | ||
level += num; | ||
} | ||
}; | ||
|
||
int AI::numAIs = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include <iostream> | ||
#include "randomvalues.h" | ||
|
||
/** A class for AI characters in a game. **/ | ||
class AI | ||
{ | ||
public: | ||
std::string name; | ||
int level; | ||
static int numAIs; | ||
|
||
AI() | ||
{ | ||
name = RandomValues().name(); | ||
level = 1; | ||
numAIs += 1; | ||
|
||
std::cout << "AI " << name << " created" << std::endl; | ||
} | ||
|
||
void say_hello() const | ||
{ | ||
std::cout << name << ":" | ||
<< " Hello! My name is " << name | ||
<< " I am level " << level << std::endl; | ||
} | ||
|
||
void increase_level( int num ) | ||
{ | ||
if( level + num >= 10 ) | ||
{ | ||
level = 10; | ||
std::cout << "Maximum level reached" << std::endl; | ||
} | ||
else | ||
level += num; | ||
} | ||
|
||
void battle( AI &other ) | ||
{ | ||
int num1 = RandomValues().damage( level ); | ||
int num2 = RandomValues().damage( other.level ); | ||
|
||
if( num1 > num2 ) | ||
{ | ||
std::cout << name << " is the winner!" << std::endl; | ||
increase_level( 1 ); | ||
} | ||
else if( num1 < num2 ) | ||
{ | ||
std::cout << other.name << " is the winner!" << std::endl; | ||
other.increase_level( 1 ); | ||
} | ||
else | ||
std::cout << "It's a draw!" << std::endl; | ||
} | ||
}; | ||
|
||
int AI::numAIs = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include "ai1.h" | ||
|
||
int main() | ||
{ | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include <iostream> | ||
#include "ai2.h" | ||
|
||
int main() | ||
{ | ||
AI firstAI; | ||
AI secondAI; | ||
|
||
std::cout << firstAI.numAIs << " " << AI::numAIs << std::endl; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include <iostream> | ||
#include "ai3.h" | ||
|
||
int main() | ||
{ | ||
AI firstAI; | ||
AI secondAI; | ||
|
||
std::cout << std::endl; | ||
|
||
firstAI.say_hello(); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <iostream> | ||
#include "ai4.h" | ||
|
||
int main() | ||
{ | ||
AI firstAI; | ||
AI secondAI; | ||
|
||
std::cout << std::endl; | ||
|
||
firstAI.say_hello(); | ||
firstAI.increase_level(2); | ||
firstAI.say_hello(); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include <iostream> | ||
#include "ai5.h" | ||
|
||
int main() | ||
{ | ||
AI firstAI; | ||
AI secondAI; | ||
|
||
std::cout << std::endl; | ||
|
||
for( int i=0; i<8; ++i ) | ||
{ | ||
std::cout << "Fight " << i+1 << std::endl; | ||
firstAI.battle( secondAI ); | ||
} | ||
|
||
std::cout << std::endl; | ||
|
||
firstAI.say_hello(); | ||
secondAI.say_hello(); | ||
|
||
return 0; | ||
} |
Oops, something went wrong.