Tom-and-Jerry Catching Game Platform Prototype Presentation
Introduction
A* Search? Depth-First Search? Breadth-First Search?
What is Tom-and-Jerry? ▷ A Java framework. TJ Framework User’s input Visualization Predefined methods and classes
Overview
The World
The World
Class Diagram Framework User’s package Jerry MyJerry Agent Movable World Cheese Tom MyTom GridGraph Graphic Game GridCell
Game World Graphic User
MyJerry Class import TJPackage.Jerry; User’s public class MyJerry extends Jerry{ Input public MoveDirection move(){ Random rand = new Random(); MoveDirection randDirection; randDirection = MoveDirection.values()[rand.nextInt(5)]; return randDirection; } }
Core Components
Creating The Maze ▷ The world consists of rows x columns cells ○ Ex. 4x4 world will have 16 cells. ○ Each cell is a node in the graph ▷ Initially, all cells are walled up.
Disjoint Set ▷ A set containing subsets of joined elements join 2&3 {1,2,3,4,5,6,7} {1,{2,3},4,5,6,7} join 4&6 {1,{2,3,4,6},5,7} {1,{2,3},{4,6},5,7} join 2&4
The Main Loop while (!gameConditionSatisfied()) for (Agent agent: agentList ){ if (agent instanceof Movable){ MoveDirection direction = ((Movable)agent).move(); updateAgentLocation(agent, direction); } } }
Game Class Game + setJerry(Jerry): void + setTom(Tom): void + setDimension(int,int): void + setDifficulty(Difficulty): void + setCheeseNumber(int): void + randomNewMaze(): void + play(): void
User Interface import TJPackage.Game; public static void main(String[] args){ Game .setJerry( new MyJerry()); Game .setTom( new MyTom()); Game .setDifficulty( Difficulty.HARD ); Game .setDimension(5, 5); Game .setCheeseNumber(1); Game .play(); }
Demonstration
Recommend
More recommend