Introduction Bots have been in the news for doing negative things such asspreading fake news. Your t

Introduction Bots have been in the news for doing negative things such asspreading fake news. Your task in this assignment is to write a bot that makes theworld a better place. Your bot will pilot a drone which ferries fruit to UNSW studentsso they stop eating junk food, have a healthy diet. Your bot must successfully buy, transport and sell fruit in asimulated world. You will write a C program to implement this bot. Virtual World The virtual world in which your bot will operate has locationsspread around a ring. It is possible to move in only two directions in the virtualworld: east and west. You can not move north or south. The word is circular so if you keep moving east or west youeventually return to where you started. The details of the virtual world are randomly generated for eachsimulation. An example follows. Locations are listed going east. As the world is circular if yougo east from Kora Lab you go to CSE. Similarly if you go west fromCSE you go to Kora Lab. There is a diagram here that may help you to better understandhow the world fits together. To obtain a copy you can edit ondraw.io, copy the contents of this txt file into your browser’saddress bar. Note most locations sell or buy a particular fruit – for exampleClovelly Watermelons has 85 kg of watermelons for sale at$14/kg. What A Fruit Bot Should Do Your bot has a fixed number of turns in the Fruit Botworld. Its only goal is to have as much cash as possible after thelast turn of the simulation. Your program is run once per turn and given a description of theworld on stdin and is asked to choose a single action for your botby printing a single line of output. There are three types of actions: Move, Buy and Sell. A bot makes money by buying fruit from one location and sellingto another location at a higher price. For example, it might buy Bananas from Bondi Banana Growers at$32/kg each and sell them to Physics Theatre at $111/kg. A bot must move to a location before it can buy or sell fromthat location. A bot’s only goal is to maximize the cash it has at the end ofthe simulation. A bot makes cash by buying fruit at one location,and then moving to a location where it can sell the fruit. There is a maximum weight of fruit that a bot can carry. Thislimit does not change during the simulation. Each location buys or sells at most one type of fruit (exceptionbelow). No location both buys and sells fruit. Some locations donot buy or sell any fruit. Move A bot making a Move action specifies the number of locationsthey wish to move. If the number is positive the bot moves East. Ifthe number is negative the bot moves West. It is not possible tomove North or South. The Fruit Bot world is circular – you can move from the lastlocation to the first location and vice-versa. So if a bot keepsmoving East or West it will eventually return to where itstarted. For example, in the world above a bot at Physics Theatre whichmakes a Move 3 action would go to Quadrangle. If instead a bot atPhysics Theatremade a Move -5 action it would go to Sitar Lab. There is a limit on the number of locations a bot can move inone turn. This limit does not change during the simulation. Each location a bot moves will use up 1 kJ of electricity fromits battery. A bot with battery level 0 can not move – it can stillbuy or sell at its current location, but unless it can buyElectricity at this location, it will not be able to move againduring the simulation. A good bot will likely need to charge its battery by buyingElectricity A bot attempting to make a move that would use up more than itsavailable battery or exceed the move limit is not penalised. It ismoved the maximum possible distance. Buy A bot making a Buy action must specify how many kg of fruit theywish to buy. A bot may receive less kg than it requests. This willoccur if: the quantity exceeds the kg of fruit the seller has the bot has insufficient cash the kg would exceed the bot’s weight limit the bot already has a different type of fruit on board – a botcan only carry one sort of fruit other bots simultaneously try to buy the fruit from the sellerand the requests can’t be fairly satisfied (see Multi-bot Worldsdescription) A bot’s cash is reduced by the total price of the fruit (cost/kg* kg) it receives in a Buy action. A bot will usually then use one or more Move actions to go to alocation which buys this fruit. A bot may however choose to buymore fruit of the same type. Sell A bot making a Sell indicates how many kg of fruit they wish tosell. A bot making a Sell action must be on a location which buysthis type of fruit. The amount that is actually sold may be limitedby the amount the buyer wishes to buy. This and the price the buyerwill pay is indicated in the location’s description. A bot’s cash will be increased by the total price of the fruit(cost/kg * kg) it sells in a Sell action. Bots are not penalised for attempting to buy or sell more fruitthan is possible. The transaction will be carried out as much as ispossible. For example, if a bot attempts to buy 10000 kg of fruitfrom a location which only has 25 kg, they will be sold 25 kg(other restrictions permitting). The initial state of the world is randomly determined at thebeginning of each simulation. The details of the world includingprices do not change during the simulation. The only exception isthat the amount of fruit buyers and sellers are willing to tradereduces as bots buy and sell fruit. You can not assume a location of a particular name will be inthe world. For example, you can not assume a location named”Randwick Apple Orchard” will be present in the world. If a location of a particular name is present, you can notassume it it is a buyer or a seller, or that it buys or sells aparticular fruit. For example, if “Randwick Apple Orchard” is present you can notassume it is a seller and you can assume it sells or buysfruit. You can not assume a location of a particular fruit will be inthe world. For example, you can not assume “Apples” will be presentin the world. Fruit Bot worlds will always contain one or more locations whichwill buy any fruit. These locations indicate they buy”Anything”. Fruit Bot worlds will always contain one or more locations whichsell “Electricity”. Buying electricity charges a bot’s battery. Itdoes not affect a bot’s weight limit. A bot can buy electricitywhen carrying fruit. Electricity cannot be sold by a bot. Botsalways start with a full battery. Multi-bot Worlds Your bot will be tested in Fruit Bot worlds where it is the onlybot present. It will also be tested in Fruit Bot worlds where other bots arepresent. All bots start at the same location, with the full batteries ofthe same size & cash and have the same number of turns. Allbots have the same limits on how far they can move and the maximumfruit weight they can carry. When multiple bots are present in a world each turn all bots aresimultaneously asked for their action. The actions then occursimultaneously. Multiple bots may be present on one location. If multiple botson the one location make buy or sell requests which cannot all besatisfied the trade is divided fairly between the bots. Fruit willbe left unsold if it is not possible to divide trade fairly. If, for example, there is 7 kg of fruit for sale at a location,and 3 bots simultaneously request to buy, respectively 7kg, 18kgand 2kg, each bot would be sold 2 kg and 1 kg would be leftunsold. If instead the 3 bots simultaneously requested to buy,respectively 18kg, 7kg and 1kg, the bots would sold 3 kg, 3 kg and1kg respectively. Getting Started The week 11 lab exercises will take you through gettingstarted. First download fruit_bot.c which contains the starting code forthe assignment. You will also need fruit_bot.h which fruit_bot.c includes. Readbut do not change fruit_bot.h The code to read the input describing the world for thisassignment is difficult. fruit_bot.c calls a function named fruit_bot_input. You willalso need fruit_bot_input.c which defines fruit_bot_input. It is arequirement you use fruit_bot_input for input. You don’t need tounderstand the code in fruit_bot_input.c. Your program must not usescanf, fgets or getchar, it must just call fruit_bot_input fruit_bot_input returns a pointer to a struct. A fulldescription of the Fruit Bot world can be obtained by followingpointers starting with this struct. A significant component of this assignment is understanding therepresentation of the Fruit Bot world. Start by readingfruit_bot.h The command 1511 fruit_bot_referee fruit_bot.c willautomatically test your program on a random world. For example: cp -n /web/cs1511/18s1/activities/fruit_bot/fruit_bot.c .cp /web/cs1511/18s1/activities/fruit_bot/fruit_bot.h .cp /web/cs1511/18s1/activities/fruit_bot/fruit_bot_input.c .dcc fruit_bot.c fruit_bot_input.c -o fruit_bot1511 fruit_bot_referee fruit_bot.c|moreseeding with 14555711dcc -o fruit_bot fruit_bot.c -I/home/cs1511/public_html/18s1/private/activities/fruit_bot /home/cs1511/public_html/18s1/private/activities/fruit_bot/fruit_bot_input.cdcc –valgrind -o fruit_bot-valgrind fruit_bot.c -I/home/cs1511/public_html/18s1/private/activities/fruit_bot /home/cs1511/public_html/18s1/private/activities/fruit_bot/fruit_bot_input.c*** Fruit Bot Parameters ***battery_capacity=105maximum_fruit_kg=32maximum_move=6*** Turn 1 of 33 *** ***Campus Charging: will sell 100 kJ of Electricity for $4/kJScience Theatre: will buy 2 kg of Apples for $91/kgCLB 7: will buy 2 kg of Apples for $104/kgMathews A: will buy 1 kg of Apples for $79/kgQuadrangle: other”Botty McBotbot” is at “Campus Charging” with $118, battery level: 105: action = Move 1 An interactive player is available allowing you to control afruit bot directly: dcc fruit_bot.c fruit_bot_input.c -o fruit_bot1511 fruit_bot_referee –interactive_player… The default world used by the fruit bot referee has only a fewlocations and is designed for debugging. A larger world is available via the -w option. 1511 fruit_bot_referee -w medium fruit_bot.c|moreVersion: 0.2seeding with 8208139dcc -o fruit_bot fruit_bot.c -I/home/cs1511/public_html/18s1/private/activities/fruit_bot /home/cs1511/public_html/18s1/private/activities/fruit_bot/fruit_bot_input.cdcc –valgrind -o fruit_bot-valgrind fruit_bot.c -I/home/cs1511/public_html/18s1/private/activities/fruit_bot /home/cs1511/public_html/18s1/private/activities/fruit_bot/fruit_bot_input.c*** Fruit Bot Parameters ***battery_capacity=39maximum_fruit_kg=21maximum_move=3*** Turn 1 of 128 *** ***John Lions Garden: otherBondi Banana Growers: will sell 25 kg of Bananas for $16/kgKensington Kiwifruit: will sell 23 kg of Kiwifruit for $18/kgCampus Citrus Center: will sell 15 kg of Oranges for $34/kgMathews C: will buy 22 kg of Kiwifruit for $40/kgRosebery Orange Grove: will sell 18 kg of Oranges for $27/kgViola Lab: will buy 34 kg of Durian for $121/kgWentworth Watermelons: will sell 13 kg of Watermelons for $8/kg…. Other worlds will be added to the referee and you can createyour own world in a file (see lab exercises for examples): 1511 fruit_bot_referee -f my_world.txt fruit_bot.c|more These tutor-made solution videos for Traversing the Fruit BotWorld and Go West Young Bot from week 11’s lab might be helpful forunderstanding this assignment. Fruit Bot Tournaments Tournaments will be run on all bots submitted withgive, starting Sun May 20 with the results displayed onthe class web page. This will allow you to see how your bot performs in a world withmany other bots present. Submitted bots will be first tested in a single-bot-world. Theywill only be be added to the tournament if they reach aqualifying-level of performance in a single-bot world. Assumptions/Restrictions/Clarifications You should follow discussion about the assignment in the classforums. Questions about the assignment should be posted there soall students can see the answer. You must use fruit_bot.h and fruit_bot_input.c. You can not change fruit_bot.h or fruit_bot_input.c. You can not submit fruit_bot.h or fruit_bot_input.c. You may submit only one file. It must be named fruit_bot.c You submitted code must be C only. You may not submit code inother languages. You may not use system or other Cfunctions to run external programs. You may call functions from the standard C libraries (e.g. thefunctions from stdio.h, stdlib.h, string.h) and the maths library(math.h). You may not use functions from other C libraries (libraries thatrequire the -l flag for dcc). In other words as long as dcccompiles your program without the -l flag you are fine. Your program must take at most 10 seconds to print a move on aCSE computer when compiled with dcc –valgrind. There is no way for your bot to pass information from one turnto the next. Your bot is not permitted to create files. Sellers do not grow more fruit during the simulation. The kg offruit they have for sale is reduced when bots buy fruit from them.The kg of fruit they have for sale does not otherwise change. This is also true for buyers. The kg of fruit a buyer is willingto buy reduces when bots sell fruit to them. The kg of fruit theyare willing to buy does not otherwise change during thesimulation. fruit_bot.h will not be changed when your bot is compiled formarking. . . .