jpeterbaker / maxfield Goto Github PK
View Code? Open in Web Editor NEWCode for maximizing the Ingress fields on a given set fo portals
License: GNU General Public License v3.0
Code for maximizing the Ingress fields on a given set fo portals
License: GNU General Public License v3.0
Failed maxfield (if this happens many times, this loop could be infinite. Ill fix this sometime)
Hmm not sure whats causing this
Hello,
What license(s) have you released this package under?
I did not find any reference to a license in the library code or README.
Kind Regards,
Camisa
There already exists an IITC plugin that on its own implements a very limited "max fields" behaviour, so the data is certainly there[1].
Just would need a similar extension that either did manual input of portals via selection, or simply using "The current viewport". The first of those limits what portals you can include by requiring a click-scan behaviour, but can easily be extended beyond a viewport size and won't be limited by portal visibility settings. The second of which is more convenient, but can exclude important portals due to the zoom limits.
This would also be able to tie in nicely with #17 once it is worked out how, in that IITC could help garner what links, fields and link-directions are already present to factor in, and that would also reduce any queries you have to do yourself to google's servers to determine that data
It would also be a good place to assign agents to keys, because it would be a simple case of going "click as agent #1", then clicking Agent1's portals, etc.
1: As to why I'm just not using that plugin, its nowhere near as useful as maxfields is, and doing the heavy lifting in the browser is just bad design imho, because browsers are not very specialised at solving those sorts of problems.
If I understand correctly, the distance between a given pair of portals (which indirectly also determines the amount of required travel time) is calculated based upon the simple line-of-sight route, and does not take into account the real-world walking/driving route.
If it were somehow possible to utilize the Google Maps knowledge of the latter [via the Distance Matrix API?] in order to make the calculations more meaningful, that would be most wonderful!
Also, it would be nice if each step of the Agent's plan, in traveling from one link-origin to the next, could show the calculated travel distance (and time) from the previous step.
See the comment from the official ingress account, so much for my plan
https://plus.google.com/u/0/+GillesWEBER/posts/hfUTD9WqMq3
If a Portal is inside an existing Field, it is no longer possible to establish a Link to that Portal. You should still be able to create Fields over existing Fields, but not Fields nested inside existing ones.
Small png shots are useless when portal/links density is high.
What if output would be KML, which can be visualized in any map software (e.g. Google Earth)?
It's even possible for links to appear step by step, and their sequence could be included in same kml file.
I have python 2.7.9 running on a Mac. I ran pip install as documented, and then ran the sample as documented.
$ python makePlan.py -n 4 EXAMPLE.csv out/ output.pkl
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/_methods.py:55: RuntimeWarning: Mean of empty slice.
warnings.warn("Mean of empty slice.", RuntimeWarning)
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/_methods.py:65: RuntimeWarning: invalid value encountered in true_divide
ret, rcount, out=ret, casting='unsafe', subok=False)
Traceback (most recent call last):
File "makePlan.py", line 261, in
sys.exit(main())
File "makePlan.py", line 161, in main
xy = geometry.gnomonicProj(locs,xyz)
File "/Users/runix/prog/ingress/maxfield/lib/geometry.py", line 173, in gnomonicProj
a = np.pi/2-pts[:,0]
IndexError: too many indices
Does this code need a particular version of Python or some other change to the environment?
I only get a bunch of points on the same place on the map. It seems there is a problem with the coordinates. All portals except two are on the top left corner ?!?!
My input:
Materl Maria Hollabrunn (nördlich),48570723,16084928 Kreuz,48570339,16080256 Hollabrunn - Heiligenstatue,48568594,16076083 Weinkeller der Landw. Fachschule,48568231,16072385 Historical House with Wine,48568025,16072355 Kreuz Jesus Hollabrunn (nördlich),48567711,16080396 Hollabrunn - Wasserrad,48567643,16080976 Museum Alte Hofmühle,48566791,16083500 Speicher 2,48567042,16084442 Hollabrunn - Brunnen am Lothringerplatz,48566393,16079945 Haus,48565154,16079602 Hollabrunn Trainstation,48562838,16072682 Maximilian Jordan,48562758,16078164 Pfarrer Josef Strauss,48563000,16078810 Koliskoplatzsäule,48563475,48563475 Altes Gericht,48563241,16080782 Denkmal,48562659,16078874 Hollabrunn Hauptplatz Stadtbru,48562340,16078818 Rathaus,48561926,16079114 VS Turnsaal,48562162,16080759 Standesamt Hollabrunn,48561578,16078940 Brunnen im Haus Hollabrunn,48561360,16079024 Pfarrkirche St. Ulrich,48561439,16079876 EBRG/ARG Hollabrunn,48561277,16081757 Materl (östlich),48561865,16094441 Kriegerdenkmal Magersdorf,48561280,16098256 Johannes Nepomuc,48561531,16102338 Nepomuk Statue Magersdorf,48561312,16103039 Kapelle Magersdorf,48560807,16105272 Kapelle Magersdorf (nördlich),48561586,16106069 Hollabrunn Kreisverkehr Brunnen,48561185,16073883 Badhaus,48561007,16074579 Denkmal Hollabrunn,48560697,16071792 HTL Hollabrunn,48560343,16070354 Frisch&Fein,48559705,16069863 Alter Schlachthof,48560103,16073791 Old Slaughterhouse Hollabrunn,48559900,16073780 Heiligenbildstock,48559635,16080192 Kapelle,48558610,16067654 Sporthalle Hollabrunn,48557648,16073914 Zechmeister,16073914,16079061 Historisches Gebäude Hollabrunn,48554932,16079491 Russischer Soldatenfriedhof,48554112,16084890 Heiliger Hubertus,48555217,16088024 Materl,48552514,16077598 Kreuz Jesus Hollabrunn,48549769,16078932 Materl Maria Hollabrunn,48549665,16079179
Is it possible to output a diagram with the final look of the fields/links?
I'm in an area where there are a couple/few links that I cannot take down (it's my side). Is there any way to define these pre-existing links and have the program work around this limitation? The other issue is that I'm not sure if these are inbound or outbound links.
Related to this, to be able to define existing links to outside of the fielding area. Again, the unknown is if the links are inbound or outbound, but would affect the perfect fielding.
Attempting to create a simple plan in neighborhood where I live results in links that cross.
test.csv:
Woodlawn Park,41638819,-9366202 Tai Village,41634709,-93651795 Debra Heights Wesleyan Church,41634182,-93664581 Living Waters Friends Church,41629703,-93662797 Darrel L. Thompson Memorial,41629005,-93653673 Trinity Temple,41632202,-93671829
links_for_agent_1_of_1.txt:
Complete link schedule issued to agent 1 of 1
Links marked with * can be made EARLY
Total time estimate: 111611 minutes
----------- AGENT DATA -----------
Distance traveled: 13392833 m
Links made: 10
Fields completed: 8
Total experience: 13130 AP
Link Agent Map# Link Origin
Link Destination
0* ____1 5 Darrel L. Thompson Memorial
2 Tai Village
1* ____1 2 Tai Village
3 Trinity Temple
2 ____1 5 Darrel L. Thompson Memorial
3 Trinity Temple
3* ____1 3 Trinity Temple
4 Living Waters Friends Church
4* ____1 3 Trinity Temple
0 Woodlawn Park
5* ____1 3 Trinity Temple
1 Debra Heights Wesleyan Church
6 ____1 1 Debra Heights Wesleyan Church
2 Tai Village
7 ____1 5 Darrel L. Thompson Memorial
0 Woodlawn Park
8 ____1 0 Woodlawn Park
2 Tai Village
9 ____1 0 Woodlawn Park
1 Debra Heights Wesleyan Church
10 ____1 4 Living Waters Friends Church
5 Darrel L. Thompson Memorial
`
What happens if I leave the # of keys blank for everything, or should I append a large number to each portal if I don't mind farming many of them?
Maxfield.py Lines 136 on seems to be what I'm looking for, if it's left blank assume that there are none?
I used Canopy and tried to execute. Please let me know if you require more info.
Glenns-MacBook-Pro:maxfield-master lucky$ python makePlan.py 4 EXAMPLE.csv out/ output.pkl
Traceback (most recent call last):
File "makePlan.py", line 43, in
import networkx as nx
ImportError: No module named networkx
Glenns-MacBook-Pro:maxfield-master lucky$
Glenns-MacBook-Pro:maxfield-master lucky$ ls
Glenns-MacBook-Pro:maxfield-master lucky$ python makePlan.py 4 EXAMPLE.csv out/ output.pkl
Traceback (most recent call last):
File "makePlan.py", line 43, in
import networkx as nx
ImportError: No module named networkx
Glenns-MacBook-Pro:maxfield-master lucky$ ls
EXAMPLE.csv README.txt lib makePlan.py
Glenns-MacBook-Pro:maxfield-master lucky$ ls -ltr
total 40
-rwxr-xr-x@ 1 lucky staff 5942 Feb 1 10:19 makePlan.py
drwxr-xr-x@ 11 lucky staff 374 Feb 1 10:19 lib
-rwxr-xr-x@ 1 lucky staff 5034 Feb 1 10:19 README.txt
-rwxr-xr-x@ 1 lucky staff 1792 Feb 1 10:19 EXAMPLE.csv
input.csv:
A, 4615, -3916, 0 B, 4134, -4183, 0 C, 3888, -4038, 0
python ../makePlan.py 1 input.csv output1
IMPROVEMENT:
total: 0
max: 0
weighted: 0
KEY PERFECTION
Choosing plan requiring 0 additional keys, max of 0 from single portal
Traceback (most recent call last):
File "../makePlan.py", line 170, in
for t in a.triangulation:
AttributeError: 'DiGraph' object has no attribute 'triangulation'
Greetings,
I'm trying to get this running on a CentOS 6 VM and I'm about 90% there. However, I'm running into an issue in the PlanPrinter.py when trying to setup the agent link files.
I've included a bunch of OS/package information and the run attempt below.
Please let me know if you need any more information.
specifics:
Linux python 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
python-pycurl-7.19.0-8.el6.x86_64
python-iniparse-0.3.1-2.1.el6.noarch
python-libs-2.6.6-52.el6.x86_64
python-nose-0.10.4-3.1.el6.noarch
python-dateutil-1.4.1-6.el6.noarch
python-matplotlib-0.99.1.2-1.el6.x86_64
python-urlgrabber-3.9.1-9.el6.noarch
rpm-python-4.8.0-37.el6.x86_64
newt-python-0.52.11-3.el6.x86_64
python-2.6.6-52.el6.x86_64
python-setuptools-0.6.10-3.el6.noarch
numpy and networkx are both installed
Here is the output of the tried run:
[pel@python maxfield-master]$ python makePlan.py 2 vinal.csv out/ vinal.pkl
IMPROVEMENT:
total: 47
max: 4
weighted: 55
All keys used. Improvement impossible
Choosing plan requiring 47 additional keys, max of 4 from single portal
Planning agent movements:
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_gtk.py:621: DeprecationWarning: Use the new widget gtk.Tooltip
self.tooltips = gtk.Tooltips()
Traceback (most recent call last):
File "makePlan.py", line 206, in
PP.agentLinks()
File "/home/pel/maxlinks/maxfield-master/lib/PlanPrinter.py", line 328, in agentLinks
self.names[q]
ValueError: zero length field name in format
[pel@python maxfield-master]$
[pel@python maxfield-master]$ cd out
[pel@python out]$ ls -l
total 192
-rw-rw-r--. 1 pel pel 1005 Mar 20 16:43 keyPrep.txt
-rw-rw-r--. 1 pel pel 760 Mar 20 16:43 keys_for_agent_1_of_2.txt
-rw-rw-r--. 1 pel pel 760 Mar 20 16:43 keys_for_agent_2_of_2.txt
-rw-rw-r--. 1 pel pel 114826 Mar 20 16:43 linkMap.png
-rw-rw-r--. 1 pel pel 269 Mar 20 16:43 links_for_agent_1_of_2.txt
-rw-rw-r--. 1 pel pel 706 Mar 20 16:43 ownershipPrep.txt
-rw-rw-r--. 1 pel pel 22808 Mar 20 16:43 portalMap.png
-rw-rw-r--. 1 pel pel 29341 Mar 20 16:43 vinal.pkl
[pel@python out]$
[pel@python out]$ cat keyPrep.txt
Keys Needed | Lacked |
3 | 3 | A Perpetual Flower for Kate
2 | 2 | Allan and Herbert Clark Asiatic Sea
3 | 3 | Anne Mackay Memorial Library
2 | 2 | Bruce N. Freeman Lake
4 | 4 | Chelmsford
5 | 5 | Chelmsford Billerica Gift to Chelmsford
3 | 3 | Chelmsford Highland Park
1 | 1 | Chelmsford Southwell Park
0 | 0 | Hadley Park
2 | 2 | North Chelms Congregational
3 | 3 | North Chelmsford Hardware Est 1946
3 | 3 | North Chelmsford Old Town Hall
0 | 0 | North Chelmsford The Mills
1 | 1 | Riverside Cemetery
2 | 2 | Saint John the Evangelist
2 | 2 | US Post Office Kennedy Drive
2 | 2 | Vietnam Memorial
3 | 3 | Williamsburg Condo Post Office
1 | 1 | Williamsburg at Chelmsford
2 | 2 | statue in Vinal Square
[pel@python out]$ cat keys_for_agent_1_of_2.txt
Keys for Agent 1 of 2
Map# Keys Name
14 2 A Perpetual Flower for Kate
19 Allan and Herbert Clark Asiatic Sea
12 2 Anne Mackay Memorial Library
10 Bruce N. Freeman Lake
9 4 Chelmsford
6 4 Chelmsford Billerica Gift to Chelmsford
16 2 Chelmsford Highland Park
2 1 Chelmsford Southwell Park
13 Hadley Park
8 North Chelms Congregational
3 1 North Chelmsford Hardware Est 1946
11 2 North Chelmsford Old Town Hall
15 North Chelmsford The Mills
17 Riverside Cemetery
18 1 Saint John the Evangelist
4 1 US Post Office Kennedy Drive
7 2 Vietnam Memorial
1 1 Williamsburg Condo Post Office
0 Williamsburg at Chelmsford
5 1 statue in Vinal Square
[pel@python out]$ cat keys_for_agent_2_of_2.txt
Keys for Agent 2 of 2
Map# Keys Name
14 1 A Perpetual Flower for Kate
19 2 Allan and Herbert Clark Asiatic Sea
12 1 Anne Mackay Memorial Library
10 2 Bruce N. Freeman Lake
9 Chelmsford
6 1 Chelmsford Billerica Gift to Chelmsford
16 1 Chelmsford Highland Park
2 Chelmsford Southwell Park
13 Hadley Park
8 2 North Chelms Congregational
3 2 North Chelmsford Hardware Est 1946
11 1 North Chelmsford Old Town Hall
15 North Chelmsford The Mills
17 1 Riverside Cemetery
18 1 Saint John the Evangelist
4 1 US Post Office Kennedy Drive
7 Vietnam Memorial
1 2 Williamsburg Condo Post Office
0 1 Williamsburg at Chelmsford
5 1 statue in Vinal Square
[pel@python out]$ cat links_for_agent_1_of_2.txt
Complete link schedule issued to agent 1 of 2
Total time estimate: 24 minutes
Agent distance: 45 m
Agent experience: 29699 AP
Links marked with * can be made EARLY
Link Agent Map# Link Origin
[pel@python out]$ cat ownershipPrep.txt
These portals' first links are incoming
They should be at full resonators before linking
Anne Mackay Memorial Library
Bruce N. Freeman Lake
Chelmsford
Chelmsford Billerica Gift to Chelmsford
Chelmsford Highland Park
Chelmsford Southwell Park
North Chelms Congregational
North Chelmsford Hardware Est 1946
North Chelmsford Old Town Hall
Riverside Cemetery
Saint John the Evangelist
US Post Office Kennedy Drive
Vietnam Memorial
Williamsburg Condo Post Office
Williamsburg at Chelmsford
statue in Vinal Square
These portals' first links are outgoing
Their resonators can be applied when first agent arrives
A Perpetual Flower for Kate
Allan and Herbert Clark Asiatic Sea
[pel@python out]$
my CSV looks like this:
[pel@python maxfield-master]$ cat vinal.csv
Allan and Herbert Clark Asiatic Sea,426346,-713979
Bruce N. Freeman Lake,426380,-713914
Williamsburg Condo Post Office,426460,-713899
Williamsburg at Chelmsford,426466,-713893
Chelmsford Southwell Park,426414,-713801
US Post Office Kennedy Drive,426390,-713804
North Chelmsford Hardware Est 1946,426397,-713840
Anne Mackay Memorial Library,426372,-713838
statue in Vinal Square,426387,-713824
Chelmsford Billerica Gift to Chelmsford,426386,-713819
North Chelms Congregational,426382,-713823
Chelmsford,426382,-713818
Vietnam Memorial,426385,-713816
North Chelmsford Old Town Hall,426375,-713815
North Chelmsford The Mills,426360,-713798
Chelmsford Highland Park,426360,-713798
Saint John the Evangelist,426357,-713732
Riverside Cemetery,426358,-713718
A Perpetual Flower for Kate,426363,-713713
Hadley Park,426363,-713713
[pel@python maxfield-master]$
See https://gist.github.com/roncli/91abc2ae7049cf2e70f54f626045eacd for the input and link output.
Specifically, I want to focus on these links:
41 ____1 15 Twin Pines Park Lion Sculpture
19 The Book Nook
42 ____1 17 Twin Pines Park Dedication Sto
19 The Book Nook
43 ____1 14 Carved Tree Sculpture
19 The Book Nook
41 creates the link, and the ensuing field encloses Twin Pines Park Dedication Stone and Carved Tree Sculpture. However, the program now wants me to throw links 42 and 43 to The Book Nook from INSIDE the field, whereas throwing it from the Book Nook is the only way to make the fields, because The Book Nook is on the edge of any fields, whereas the other two are inside fields.
So, links 42 and 43 need to be thrown from The Book Nook, not from the other portals. I'm not sure why the program did not catch this.
Otherwise, the plan worked great.
In the agent data section, the number of links to be made by the agent is 1 less than the actual number of keys assigned to the agent. From the code, I believe (in agentLinks() function) you did not account for the first link. Please take a look, thanks!
I know that the script doesn't scale all that well, but when it does complete the linking is pretty inefficient, requiring multiple agents at the same portal at the same time, where it would obviously be faster to have just one agent doing the linking.
I've resorted to editing the links_for_agent_*_of_7.txt files manually
output.pkl
http://pastebin.com/jpm5d240
I show two parameter used for test more solutions. EXTRA_SAMPLES && TRIES_PER_TRI
Can we add an option to test all options?
Would be nice to select the starting portal as an optional value.
got this
C:\Python27>python makePlan.py 1 KYam-HaiPark.csv out5
IMPROVEMENT:
total: 0
max: 0
weighted: 0
KEY PERFECTION
Choosing plan requiring 0 additional keys, max of 0 from single portal
Traceback (most recent call last):
File "makePlan.py", line 175, in
for t in a.triangulation:
AttributeError: 'DiGraph' object has no attribute 'triangulation'
10x for help
Why the order you put the portals in the CSV file affects the links you should create? I think that order should not affect it. Am I wrong?
Anyway, thank you very much for your program. Very useful! ;)
Hi,
great work with the code there! I had my 1st experience with py but managed to run it (thanks for the detailed how to).
Here is a question: would it be possible to optimize CF/Links configuration for the given keys parameter? Often some portals won't drop as many keys as we like, while others do it everytime. Eventually I end up waiting burnout cylces to collect 1-2 missing keys and having a load of others.
So, if I could omit the maxed out CF configuration for the sake of making the best out of the keys I have that would be awesome.
Regards!
I intend to add the option to make the maps' links and portals blue. I think the Resistance may prefer this.
Great software. For some reason though I am unable to properly designate a number of agent other than leaving it at the default and getting plans for 1? Anyone else having problems with this - python makePlan.py 4 EXAMPLE.csv out/ output.pkl - does not appear to work.
I'm no python king. But is it possible to add the functionality to show how many fields will be created with the output of the report? I used your script now a couple of times and when handing out the plans to the agents i got the questions a couple of times how many fields there will be created.
So now you see in links_for_agent_x_of_x.txt
Agent distance: 10371 m
Agent experience: 149111 AP
Example to add:
Agent fields: 36 fields
p.s. Many thanks for your work on this script
I cannot find the script, am I the only one? Running the example gives me the "No such file or directory" error. I'm lost..
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.