![]() ![]() I thought I would provide the results of the script below so you could see the output that you will receive if you run it: OutputFleets = outputFleets "Fleet " str(i) ": " str(currentFleet) " " str(currentFleet) " " str(currentFleet) " " str(currentFleet) " " str(currentFleet) " " str(currentFleet) " Total: " str(total) "\n" If a b and a c and a d and a e and a f and b c and b d and b e and b f and c d and c e and c f and d e and d f:ĬurrentTotal = listNumb listNumb listNumb listNumb listNumb listNumb Random.shuffle(listNumb) # Makes the order of the list random #listNumb.sort() # Sorts the list by smallest integer first #listNumb.sort(reverse=True) # Sorts the list by largest integer first ListNumb = broadswordDestroyer exodusCruiser rancorBattleship genesisCruiser Below is the code that I am using it is also located here on google docs. Though output is received from the code I have to manually enter in the output to the browser or the app that I am using. I am also using it as part of my strategy to determine the best combinations of fleets to use in the game. I am only using the code as a great mathematical challenge and solving it using python. This code is run independent of anything that Kixeye uses for the game, interaction with another player, created apps or gameplay. I am in no way using this code to tamper with another player, the game, app or gameplay. I would be more than happy to learn of a different way to code this or a better way mathematically to do it. Then finally I added a condition so it would take the maximum combined total of the 7 fleets and then only output future combinations that are larger than the previous one output. So I introduced an if statement so if the fleet mass amounted to over 10,000 it would not execute the for loops after that threshold was hit.Īfter the above challenges I found that sometimes a fleet would try and include a duplicate ship that did not exist because the for loop would complete without reaching maximum mass of 10,000 or above and pass the last value of the for loop into the fleet.Īlso one or more of the 7 fleets would not be generated in the for loops so not to output these fleets but only the ones that are complete. I could not figure out how to break out of the 6 for loops without breaking out of the 7th which is used to generate all 7 fleets. Then if the the fleets mass amounted to over 10,000 then break out of the for loops. However each for loop had to be looking at a unique ship in the list so an if statement was created to work around this issue of the variables counting the loop could not be accessing the same item in the list of ships. ![]() ![]() In creating 1 fleet, I would send the calculations through 6 for loops, one loop for each ship in the fleet. I found that instead of sorting the list by smallest to largest or largest to smallest I received the best results if I randomized the list using random.shuffle. So I have a total of 51 ships accounted for in the above lists. The challenges and what I learned from this problem: Now back to the math of trying to figure this out, here are the ships placed into python lists based on their mass:ĮxodusCruiser = ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |