SEA-4 Ken Kelley University of Alaska, Anchorage.
-
Upload
lauren-dean -
Category
Documents
-
view
214 -
download
1
Transcript of SEA-4 Ken Kelley University of Alaska, Anchorage.
![Page 1: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/1.jpg)
SEA-4
Ken KelleyUniversity of Alaska, Anchorage
![Page 2: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/2.jpg)
The 4th Chapter
• Everyone remembers the ground breaking epic game, known as “Sea”
• Haven’t heard of it? Came out just before your earliest memories…
• So popular that parts 2 and 3 quickly followed• A successful board game version was also
made available, called Battleship.• Sea 4 aims to recapture the magic found in the
original
![Page 3: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/3.jpg)
The Goal
• Design and Implement an interactive “Battleship” type game.– Language/IDE: C#, Visual Studio– User friendly GUI• Interactive Input• Immersive Output
– Embedded videos– Logical AI Opponent– Features – Saving/Loading, Various Options
• Increase experience with C#, and Visual Studio
![Page 4: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/4.jpg)
The Essentials
• Game Logic– Detect Valid Moves *especially important with ship
placement, by both computer and player*– Fewer moves as game progresses– Win/Loss
• Game Data– Need a way to represent a game state– Load/Save that state
• AI opponent should make smart moves– Look for ships– Continue to sink a ship if found– Eventually opted to have several difficulty settings
![Page 5: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/5.jpg)
The Essentials
• And of course…. A GUI!• The workhorse of the program– Interactive component– Respond to player’s choices– Provide updates to game state, based on player’s
actions– Be prepared to handle anything - especially
incorrect responses.
![Page 6: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/6.jpg)
The GUI
• Menu– Load/save/new game– Options (extra features)
• Text Box and Ship Counter– Inform player of win/loss– Game Messages
• Action Window – Embedded Video/Interactive• 2 Sea Grids (Array of Buttons)– Firing Grid– Ship Placement Grid
![Page 7: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/7.jpg)
Firing Grid
• Used to attack computer’s ships• Indicates hit/miss– Red: hit– White: miss– Blue: potential targets
• Player can select a position, which is highlighted, and then click the “Fire!” Button
*Note* Clicking twice allows users the freedom to change their minds if a mistake is made.
![Page 8: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/8.jpg)
Ship Placement Grid
• Used initially to place ships…• Three Stages (Ship Placement)– User selects position– Possible layouts displayed, user chooses one– User confirms ship placement, may cancel anytime
during the process• Player can view the status of their fleet• targeted by the computer, indicates computers
hits/misses
![Page 9: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/9.jpg)
The Conceptual GUI
![Page 10: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/10.jpg)
The Illusion of Control
• One issue remains– Handling user interactions– Expecting the unexpected
• Users need to feel like they are in control, and in fact, they are driving the application
• We need a way to limit this control, to maintain stability of the program
• How do we accomplish this?
The answer is relatively simple… if you have had the opportunity to enjoy CS351
![Page 11: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/11.jpg)
The Solution• Phase System (Finite State Automata)– Certain parts of the application only respond
when program is in a certain phase– Users interactions determine what phase its in
• 4 phases– Start : Number of Ships, AI difficulty, start ends– Ship: 3 phases of its own, create game state ends– Game: firing grid active, AI alternates, movies– Game Over: gameover() checked after each move
• New Game, Play Again – restore start state
![Page 12: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/12.jpg)
GUI - Start
![Page 13: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/13.jpg)
GUI - Ship
![Page 14: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/14.jpg)
GUI - Game
![Page 15: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/15.jpg)
GUI – Game Over
![Page 16: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/16.jpg)
Data Files
• Two Important Files– .txt– .avi
• Text files will contain game states, so that a game may be saved and loaded at a later time.
• Video files will be used to enhance the user experience. Embedded videos will respond to the user’s actions.
![Page 17: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/17.jpg)
It sounded good at the time…
• This portion of the program had some major redesigns….
• Problems– Game state was not sufficient to store data– Opted to scrap DirectX in favor of a player that
was built into visual studio– Added visual instruction walkthrough, and images
instead of colored blocks for ships (needed jpgs) *increases immersion and is user friendly*
![Page 18: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/18.jpg)
A Game State0 0 0 0 0 X 0 0 0 00 0 0 0 0 0 1 0 0 00 0 0 0 0 0 1 0 0 00 0 0 0 0 0 1 0 0 00 0 0 0 X 0 1 0 0 00 0 0 0 0 0 1 1 1 00 0 X 0 0 0 0 1 1 00 0 0 0 0 0 X 1 1 00 0 0 0 0 0 0 1 0 000 0 0 0 0 0 0 0 0 (player)
H H H H H 0 0 0 0 00 0 0 0 0 0 0 0 1 00 0 0 0 0 0 0 0 1 00 X 0 0 0 X 0 0 0 00 0 0 0 0 0 0 0 0 00 0 0 0 1 0 0 0 0 00 0 0 0 1 0 0 0 0 00 X 0 0 1 0 0 X 0 00 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0(computer)
• Two Arrays– Player– Computer
• Four Variables– 0: Open Water– 1: Ship Placed– H: Hit by opponent– X: Miss by opponent
![Page 19: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/19.jpg)
Game State - Redesign4 3XX XX XX XX XX XX XX HH HH HH
XX XX XX XX MM XX A1 XX XX XXXX P1 P1 XX XX XX A1 XX XX XXXX XX XX XX XX XX A1 XX XX XXXX XX XX XX XX XX A1 XX XX XXXX XX XX MM XX XX A1 XX S1 XXXX XX XX XX XX XX XX XX S1 XXXX XX XX XX XX XX XX XX S1 XXXX XX XX XX XX XX XX XX XX XXHH HH HH B1 XX XX XX XX MM XX
![Page 20: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/20.jpg)
Embedded Video
• Scrapped DirectX• Visual Studio has many hidden features• You can add controls (buttons and panels) to
the application from the toolbox• Apparently, you can also add more tools to the
toolbox• Windows Media Player is a built in tool, that
can be added to the toolbox, extra control.• Windows Media Video (.wmv) replaced .avi
![Page 21: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/21.jpg)
An image says a 1000 words
• Ship phase walkthrough
• Ship grid… now with actual ships!
![Page 22: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/22.jpg)
System Design• Programming Language/IDE– C#– Visual Studio
• Data Structures– 2-dimensional arrays - initial states, game changes– Simple and efficient
• Algorithms– Mostly concerned with AI (Attack, ship placement)– Also used to initialize the game (allow player to
place ships in a controlled manner– Save/Load game state
![Page 23: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/23.jpg)
Algorithm – Computer Placement• private void placeCompShips()• {• int units = 5;
int counter = 1;• Boolean done = false;• Boolean emptySpace = false;• int x = 0;• int y = 0;
• while (counter <= compShipCount)• {• if (counter == 6)• {• units = 5;• }• while (!done)• {• while (!emptySpace)• {• x = random.Next(0, 8);• y = random.Next(0, 8);• if (computerShips[x, y] == "XX")• {• emptySpace = true;• }• }
![Page 24: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/24.jpg)
Algorithm – Computer Placement• int direction = random.Next(0, 5);• int directioncount = 1;
• while (directioncount <= 4)• {• if (direction > 4)• {• direction = 1;• }
• if (direction == 1)• {• if (clearPath(x, y, 1, units))• {• markCompShips(x, y, 1, units, getLabel(counter));• done = true;• }• }• else if (direction == 2)• {• if (clearPath(x, y, 2, units))• {• markCompShips(x, y, 2, units, getLabel(counter));• done = true;• }
![Page 25: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/25.jpg)
Algorithm – Computer Placement• else if (direction == 3)• {• if (clearPath(x, y, 3, units))• {• markCompShips(x, y, 3, units, getLabel(counter));• done = true;• }• }• else if (direction == 4)• {• if (clearPath(x, y, 4, units))• {• markCompShips(x, y, 4, units, getLabel(counter));• done = true;• }• }• direction++;• directioncount++;• }• emptySpace = false;• }• if (counter != 3 && counter != 8)• {• units--;• }• counter++;• done = false;• }
![Page 26: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/26.jpg)
System Architecture
![Page 27: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/27.jpg)
The Estimate• 144 hours in the semester• 8-12 hours a week
Requirements; 10.7
Implementa-tion; 48
Write-Up; 30.7
Design; 19.2 Testing; 23.9
Presentation; 11.5
![Page 28: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/28.jpg)
The ScheduleInitial Planning
Initial RequirementsInitial Design
WriteUp - RequirementsWriteUp - Edit Peers' Proposals
Presentation - ProposalDesign - Redesign
Implement - GUI FormResearch - AVI, DirectX
Research - Obtain AVI filesImplement - Action WindowTest- Play AVI in Application
Implement - Game StateTest - Display Game State
Design - Menu BarImplement Load/Save/Exit
Test- Load, Save, ExitImplement Grid
Implement Fire/Setup GridsTest- Setup AI/Human
Research - Rule variationsDesign - Add rule options
Implement Game LogicImplement Move
Implement Move AI/HumanTest - Move / Firing Grid
Test - Play Entire GameTest - Extensive Testing/Bugs
Design - Final ReviewDesign - Potential Refactoring
Implement - ChangesTest - Changes
Design - Code ReviewWriteUp - Final Report
Presentation - Final Product
1/17 1/27 2/6 2/16 2/26 3/8 3/18 3/28 4/7
Start Date
![Page 29: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/29.jpg)
The Reality
• 8 – 12 hours a week…– Beginning was a little less than 8 hours– End was exceeded 12– Averaged out, but less pressure at start
• Schedule ran into problems almost immediately– Priority of tasks• Video - kind of useless without hit s and misses• game state – need a state to display, need a game• Ship placement = highest priority.
– Design changes (extra features, windows media player)
![Page 30: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/30.jpg)
Conclusion
• Sea 4 (Interactive Battleship)– A user friendly GUI, incorporates a phase system– Many Features• Music• Game variations
– Number of Ships– Difficulty settings
• Visual feedback - ship placement, videos• Load/Save …. And More!
– It was a fun project, that I enjoyed, and I am happy with the outcome.
![Page 31: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/31.jpg)
Conclusion
• Provided programming experience– embedded videos– IO, Data Structures, GUI design, AI– experience with C# and Visual Studio
• Provided software development experience– Design -> proposals -> implementation -> even
distribution, this covered it all– Learned to accept/incorporate peer feedback through
heuristic evaluations– Flexibility, as design can change, and problems arise
![Page 32: SEA-4 Ken Kelley University of Alaska, Anchorage.](https://reader035.fdocuments.in/reader035/viewer/2022062804/56649f1c5503460f94c3271e/html5/thumbnails/32.jpg)
Questions?