Presentation is loading. Please wait.

Presentation is loading. Please wait.

Battle For Throne by Pattarapong Rojanasthien Present to Dr. Kepuska Software/Hardware Integration ECE 2552.

Similar presentations


Presentation on theme: "Battle For Throne by Pattarapong Rojanasthien Present to Dr. Kepuska Software/Hardware Integration ECE 2552."— Presentation transcript:

1 Battle For Throne by Pattarapong Rojanasthien Present to Dr. Kepuska Software/Hardware Integration ECE 2552

2 Battle for Throne Text-based strategy game There are two faction: Player and Computer 100 years to obtain the throne (100 turns to defeat or be defeated)

3 Resource Gold –Upgrade Castle and Temple Population –Convert to troops or vice versa –Collect tax (based on amount of population) Farm –Upgradeable –Suppose to affect troop’s morale (ran out of time to implement)

4 Resource cont’d Divine favor –Effect the chances of disaster occur Troops –Use for war purpose –Die less than normal population if disaster occur

5 Computer AI Currently there is only one For each ten years, its troop size and castle level will increase Only attack player when the player has less than one-tenth of its troop size No suffering from disaster nor troop train

6 War formation Standard Wedge Circle Beat Standard beat Circle Circle beat Wedge Wedge beat Standard Winner gain 25% attack bonus Same formation: no bonus

7 War formation cont’d Example output

8 How game ends Game ends at 100 years War –Retreat –Defeat enemy –Defeated by enemy

9 What I applied from lecture Classes –5 Difference classes Inheritance –All inherited to class Command Composition –Class Enemy uses composition from class Stasts

10 Classes Stats Disaster War Enemy Command

11 Class Hierarchy Disaster Command Status Enemy War Inherited to

12 Class Disaster Top based class Calculate the possibility that disasters will occur Consists of –Earthquake: Reduce the level of castle and temple –Disease: Reduce amount of troops and population –Insect: Reduce the size of farm land

13 Class Disaster cont’d Example Earthquake –Function randomEarthquake Random the number that will be use for function fireEarthquake –Function fireEarthquake Receive number from randomEarthqauke, then decide whether the event will occur

14 Class Stats Store all the status of the game (eg. Gold, Population, Castle Size). Contains get and set functions for the status

15 Class Stats cont’d Member functions –Set and get function Receive and send data between functions from base and derived class

16 Class War Receive all values from class Command via set functions. Send back the results to class Command and end the game. Contain all war command

17 Class war cont’d Example –Set and get function –War commands

18 Class Enemy Derived from class Stats Store data for the enemy (computer) Provide progression for computer

19 Class Command The bottom of inheritance. Contain the command prompt for user to decide what to do. Send data to class War when player want to attack or get attacked by the computer

20 Class command cont’d –Member functions Check function –Check if event will occur Command function –Receive the command from player and invoke another function

21 Class command cont’d Example: –checkDisaster() Invoke all functions in class Disaster that determine whether the disaster will occur. –checkEarthquake Receive value from fireEarthquake in boolean. Damage castle and temple level

22 Class command cont’d –commandTroops() Subcommand Manage troop –Draft –Release –Train

23 Driver file Main.cpp Check the condition and events –Taxation from the population –Disaster –Enemy’s progress. Perform the loop to run function enterCommand();

24 Driver file cont’d

25 Problems Unable to get data from the derived class back to the base class –Rearrange the inheritances –Use set and get functions

26 Problems cont’d Return to main menu without start a new turn Infinite loop when player enters invalid command (e.g. Alphabet, numbers not command list) –Set the command choice into string. The program will return to loop if the input is not valid.

27 Problem cont’d Bug –Go thru the code and fix it Example: suppose the computer will check the player has less than one-tenth of its army to decide to attack. The war start while the variables haven’t sent to class War

28 Problem cont’d –Fix it by running to the close and found out that the bracket for if function is not included. Here are the culprits

29 Further Improvements Dynamic Computer AI –Develop itself rather than change for every 10 years –Make their own decision to wage war Tweak the factor in game –% of disaster event occur –% proportion of investment –War: deeper strategy Graphics!

30 Further Improvements cont’d Make the game able to Save/Load Increase the numbers of faction (more computers) Introduce alliance system. Implement effects from food and farm size (ran out of time)

31 That’s it! This develop the program under visual c++ 6 Thanks Dr. Kepuska for good lecture And Daewon for helping me out in the lab


Download ppt "Battle For Throne by Pattarapong Rojanasthien Present to Dr. Kepuska Software/Hardware Integration ECE 2552."

Similar presentations


Ads by Google