Squad Homework

In this assignment, you will implement squad formations, dialogue (barking), and cover tactics. The player controls one of the avatars and is accompanied by three non-player character companions. The game is special version of a Multiplayer Online Battle Arena (MOBA) in which the player's team must destory an enemy base. Like other MOBAs, the enemy base generates a steady stream of enemy minions and an enemy hero. However, the player's base does not produce minions.

The player's squad includes the player (a hero), two companion heroes, and a new type of agent called a Healer. A Healer is a relatively weak agent that can restore other teammates to full health if touching the other agent.

On the left half of the arena (shown above), the player and companions must maintain a formation. It can be any formation of your chosing. Strategically, you are likely to want to use the formation to quickly dispatch enemy minions as you move across the arena.

The enemy towers are very powerful and have a very long range. On the right half of the arena, the player and companions must use cover tactically to get close to the towers.

The solution should implement teammate communication in the form of "barks". Barks are pre-scripted lines of dialogue that are produced at opportune moments to convey the state of agents to the player. Because the player is a human, the player's comanions cannot communicate with the human by passing arguments through function calls. Instead, the agents should communicate by printing barks to the console. The player also has need to communicate with his or her NPC teammates. The human player can initiate a bark by pressing the 'b' button. The human player cannot indicate what should be communicated via the bark, so special routines must be implemented to figure out the context and bark the appropriate message.


Tactical Cover

Tactical cover is about finding a position in the virtual world where obstacles stand between one and something shooting. If one were to imagine a shooting tower or base as light bulb, then one is in cover when in the shadow of an obstacle.

To find the shadow, it is convenient to operate in polar coordinates, where the unique location of a point can be expressed as an angle and a distance from the origin. If the shooter is the origin, we can find the point on an obstacle with the smallest angle and point on the obstacle with the largest angle (see image below). Any point that has an angle between the minimum and maximum may be in the shadow. If the point is farther away from the origin than the greatest distance among the min or max point, the point is definitely in the shadow.

To find the shadows for a shooter: (1) Set the shooter's location as the origin. (2) Convert an obstacle's points to polar coordinates. (3) Find the points with the minimum and maximum angle. (4) Pick the greatest distance of the two points. (5) Record the parameters of the shadow as the two angles and the distance.

The agent is safe if it is in one of the shadows of every shooter.


What you need to know

Please consult previous homework instructions for background on the Game Engine. In addition to the information about the game engine provided there, the following are new elements you need to know about.

Barker

A Barker is something that can send barks and hear barks sent by other Barkers.

Member functions:

PlayerHero

A type of player-controlled agent that inherits from Hero and Barker. The PlayerHero turns into a GhostAgent when it dies.

Member functions:

Healer

A Healer inherits from MOBAAgent and Barker. When it is touching another agent on the same team, it can heal that other agent up to its maximum hitpoints. The heal functionality can be only used periodically.

Member functions:

MyHealer

A specialization of Healer to be modified for the purposes of this assignments. MyHealer is of type StateMachine and also inherits from BehaviorTree.

Member functions:

MyCompanionHero

A specialization of Hero and Barker and needs to be modified for the purposes of this assignments. MyCompanionHero is of type StateMachine and also inherits from BehaviorTree.

Member functions:

MOBAWorld2

A type of MOBAWorld, which recognizes when the player wants to bark by pressing the 'b' button.

BigTowerBullet

A sub-class of TowerBullet that has greater damage, speed, and range.


Instructions

The following steps are required to complete the assignment.

Step 1: Copy your myBuildPathNetowrk function from homework 1.5. Copy your astarnavigator.py from homework 4. Copy mynavigatorhelpers.py functions from homework 3 or homework 4. Copy your btnode.py from Homework 6.

Note that the agents will use a special type of Navigator called AStarNavigator2, which will use the astar(), myUpdate() and myCheckpoints() from your astarnavigator.py and mynaivgationhelpers.py.

Step 2: Edit MyHealer agents2.py to implement formations and tactical cover.

MyHealer inherits from StateMachine and BehaviorTree. Implement either a state machine or a behavior tree that makes the agents move in formation. When the player barks to indicate they should break formation, non-player teammates should break formation and use tactical cover to assault the enemy base.

If using a state machine, make sure the constructor sets the states list and sets the startState variable to the name of the state class that should be entered first (for example Idle). If using a behavior tree, implement code in healerTreeSpec() or myHealerBuildTree() so that one of them returns a non-None value. If healerTreeSpec() or myHealerBuildTree() returns a non-None value, MyHealer will run the behavior tree. Otherwise, it will attempt to change state to the startState.

Step 3: Edit MyCompanionHero in agents2.py to implement formations and tactical cover.

MyCompanionHero inherits from StateMachine and BehaviorTree. Implement either a state machine or a behavior tree that makes the agents move in formation. When the player barks to indicate they should break formation, non-player teammates should break formation and use tactical cover to assault the enemy base.

If using a state machine, make sure the constructor sets the states list and sets the startState variable to the name of the state class that should be entered first (for example Idle). If using a behavior tree, implement code in companionTreeSpec() or myCompanionBuildTree() so that one of them returns a non-None value. If companionTreeSpec() or myCompanionBuildTree() returns a non-None value, MyCompanionHero will run the behavior tree. Otherwise, it will attempt to change state to the startState.

Each MyCompanionHero agent receives an unique id. You can use the unique id number to run different behaviors or switch to different states.

Step 4: Edit PlayerController in agents2.py to implement barking.

The PlayerController is the type of agent controlled by the player. The only way for the player to communicate to his or her non-player teammates is to bark using the 'b' button. Modify the bark() function to contextually do the following:

Test your implementations using test.py:


Grading

TBW


Submission

To submit your solution, upload all files you modified.

You should not modify any other files in the game engine.

DO NOT upload the entire game engine.