The goal for this
The ants behave according to the following model:
- Move. Every time step, randomly try to move up, down, left, or right. If the neigh boring cell in the selected direction is occupied or would move the ant off the grid, then the ant stays in the current cell.
- Breed. If an ant survives for three time steps, then at the end of the time step (that is, after moving) the ant will breed. This is simulated by creating a new ant in an adjacent (up, down, left, or right) cell that is empty. If there is no empty cell available, then no breeding occurs. Once an offspring is produced, an ant cannot produce an offspring until three more time steps have elapsed.
The doodlebugs behave according to the following model:
- Move. Every time step, if there is an adjacent ant (up, down, left, or right), then the doodlebug will move to that cell and eat the ant. Otherwise, the doodlebug moves according to the same rules as the ant. Note that a doodlebug cannot eat other doodlebugs.
- Breed. If a doodlebug survives for eight time steps, then at the end of the time step it will spawn off a new doodlebug in the same manner as the ant.
- Starve. If a doodlebug has not eaten an ant within the last three time steps, then at the end of the third time step it will starve and die. The doodlebug should then be removed from the grid of cells.
During one turn, all the doodlebugs should move before the ants do. Write a program to implement this simulation and draw the world using ASCII characters of “o“ for an ant and “X“ for a doodlebug. Create a class named Organism that encapsulates basic data common to both ants and doodlebugs. This class should have a virtual function named move that is defined in the derived classes of Ant and Doodlebug. You may need additional data structures to keep track of which critters have moved. Initialize the world with 5 doodlebugs and 100 ants. After each time step, prompt the user to press Enter to move to the next time step. You should see a cyclical pattern between the population of predators and prey, although random perturbations may lead to the elimination of one or both species.
Want to see the full answer?
Check out a sample textbook solutionChapter 15 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
Concepts Of Programming Languages
Modern Database Management
Introduction to Programming Using Visual Basic (10th Edition)
Starting Out with Java: Early Objects (6th Edition)
Starting Out with Java: From Control Structures through Objects (6th Edition)
- In programming, we use the mask concept to indicate information that can be shown to the user and information that must be “masked”, that is, hidden. In an implementation of a hangman game, we use a mask to indicate which secret word positions the player has already guessed right (whose the contents must therefore be shown to the player), and which positions must remain hidden. Each time that the player hits a letter of the hidden word, the mask is updated so that it has little dashes in the places of letters that the player has not hit yet and show it, in their proper place, the letters that he already hit it. For example, if the word is "cards", the current mask is: - a - - s and the player guesses the letter "d", the mask should be updated to: - a - ds.Write a function called update_mask that takes as input a string containing the word secret (in the example above, this word would be “cards”), a list whose elements are the characters of the current mask (in the example above…arrow_forwardA Memory Matching Game in java code with a 4x4 grid of Squares that when you click on a square it shows a number. It would have to be 2 of each number 1-8 and if the two squares that are clicked match then the squares stay on the grid. If they do not match after picking 2 squares they flip back overarrow_forwardYou are going to write a simulation for a mini survival game. In this game, one flyand three frogs are placed randomly on a board with the size 7x7.In each iteration, they move randomlywithin the board, and the simulation stops when one of the frogs eats the fly.Fly and frogs are essentially creatures that can move, make noise, and eat. Frogs can move up to 2squares in any direction and flies can move up to 1. Frogs make the "Croak! Croak!" sound, and fliesmake "ZzzZZz!". Since frogs should not eat their kind, a function of "isEatable" should also beimplemented in decision making. A variable or function to check if the fly is alive is also required as aterminate condition for simulation.In each iteration, an 'f' character represents frogs' position on board, and an '*' character is used torepresent the position of fly. Use the topics (Abstract classes, Interface, etc.) to implementthe simulation. (in java) An example output is given below.arrow_forward
- Programming language is C. I would really be appriciate if you could help me with this. Please provide me with your cashapp, so I can tip you for your work. THANK YOU:) In this project, we shall simulate the operations of an ATM machine. Suppose you’re in charge of this simulation and here is a scenario of what is required to do: The customer will be assigned a random or fixed number for his/her balance. First, the customer is prompted to enter his personal identification number pin (for this case study, we test only if this pin is formed by 4 digits! otherwise, a message like “Invalid PIN, try again . . .” will be displayed) and the user is re-prompted to enter the pin. The customer is given three chances to enter his pin. If he/she fails during the three trials you display a message like “Sorry you can’t continue, contact your bank for assistance!” If the pin is correct (formed by 4 digits), then the system will ask the customer for the receipt ( 1 for YES and 2 for NO ) and a menu…arrow_forwardJAVA PROGRAMMING OBJECT-ORIENTED PROGRAMMINGCreate a model of a scene of your choosing by making use of the composite pattern. It may be a scene from a photograph, or it could be from a simulator, or it could be from a movie, or it could be from a videogame, etc.arrow_forwardCreate an intelligent agent in Python that can navigate a maze to find the exit. The maze will be represented as a 2D grid of characters, where: 'X' represents a wall represents an open space 'S' represents the starting position of the agent 'E' represents the exit of the maze The agent can move in four directions: up, down, left, and right. Challenge: Implement two approaches: 1. Depth-First Search (DFS): The agent explores the maze using a depth-first search algorithm, backtracking when it reaches a dead end. The goal is to find the exit as quickly as possible. 2. Q-Learning: 。 The agent learns through trial and error, receiving rewards for getting closer to the exit and penalties for hitting walls. 。 Implement a simple Q-learning algorithm where the agent updates its Q-values based on the rewards it receives. The Q-values represent the estimated future reward for taking a particular action from a specific state.arrow_forward
- IN JAVA please not python In this game, one flyand three frogs are placed randomly on a board with the size 7x7.In each iteration, they move randomlywithin the board, and the simulation stops when one of the frogs eats the fly.Fly and frogs are essentially creatures that can move, make noise, and eat. Frogs can move up to 2squares in any direction, and flies can move up to 1. Frogs make the "Croak! Croak!" sound, and fliesmake "ZzzZZz!". Since frogs should not eat their kind, a function of "isEatable" should also beimplemented in decision making. A variable or function to check if the fly is alive is also required as aterminate condition for simulation.In each iteration, an 'f' character represents frogs' position on board, and an '*' character is used torepresent the position of fly. Java language pleasearrow_forwardPython homeworkassignments implement thre-dimensional random walk simulation and calculate the following: 1. The percentage of time random walks wil return to the orgin 2. The average of the square of the distance from the origin You can start with the one-dimensional random walk sample program I shared in the lecture or start from blank slate, the choice is yours.arrow_forwardKingdom of Trolls is celebrating their Kingdom Day and one of the activities that is taking place is a game where a player rolls a magic ball down the hill on a path with spikes. As the ball rolls down, it strikes a spike and bursts open to release a number of smaller balls (in our simulated game, the number of smaller balls is a randomly generated integer between 2 and 6, inclusive). As the smaller balls further roll down, when one strikes a spike, that ball and all its sibling balls burst and each generates another set of smaller balls (using the same random number already generated for the first roll). The balls keep rolling downhill and striking spikes and bursting into smaller balls until a golden ball is released by one of the bursts. At this time, the game is over and the player is told how many balls were generated during the last burst (including the golden ball). The game is played by two players at a time and the player who had the lowest number of balls generated on the…arrow_forward
- You are given an instance of a problem where you have an n x n grid of squares. Each square can be unpainted or can have a hole, so you cannot go on the square with a hole. The objective is to paint all the squares that do not have a hole. You start in the square (0,0) which is unpainted. The actions you can do are: (1) paint the square you are on if it is not painted; (2) move, either vertically or horizontally, to an adjacent square inside the grid that is not painted and does not have a hole. a. Describe a state-space representation for the problem, specifying the state representation, the initial state, the goal condition, and the actions. b. Is the state space finite? Is it a tree or a graph? c. Propose a heuristic for the problem. Is your heuristics admissible or not? Explain briefly your answerarrow_forwardthe program announces the first set of dancepartners and who the next people are in line. If there is not a complete couple,the next person in line is announced. If no one is left in line, this fact isdisplayed.First, let’s look at the data we use for the simulation:F Jennifer IngramM Frank OpitzM Terrill BeckermanM Mike DahlyF Beata LovelaceM Raymond WilliamsF Shirley YawM Don GundolfF Bernica TackettM David DurrM Mike McMillanF Nikki FeldmanWe use a structure to represent each dancer. Two simple String class methods(Chars and Substring) are used to build a dancer. Write program in c#.arrow_forwardYour task is to develop a Tic-Tac-Toe (also called as “Noughts and Crosses”) game in Java using Swing. In this assignment, you are asked to implement a single-player version of the Tic-Tac-Toe game with easy-to-use graphical user interface (GUI). One player will be the user and the second player will be artificial intelligence (AI), namely, the computer. The entire procedure of the implementation has been split into three tasks with detailed description and explanation provided. By completing the three tasks, you will develop your own Tic-Tac-Toe game. Task 1: GUI ImplementationPlease implement a GUI satisfying the following requirements.• A menu bar with two buttons “Reset” and “Quit”. User can click the “Reset” button to restore the software to the initial status. User can software the game by clicking the “Quit” button;• The top pane is an information board to display username and present some basic guidance to the user about this game. The information board will also print out the…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education