reset password
Author Message
rabbott
Posts: 1649
Posted 11:11 Nov 16, 2018 |

I will be on campus Monday and Tuesday next week for senior design presentation rehearsals. I'd like to talk to you about your projects. If you are interested, please sign up for a 15 minute slot. Fill in the slots backwards from the start of the rehearsal periods. That is, the first slot to be filled in should be Monday at 1:15 or Tuesday at 2:45. Then the slots before those, etc. (If there is demand, additional slots can be added before noon Monday.) I hope to see you next week.

To sign up for a slot put the names of the team members in the appropriate box. Use ctrl-Enter to enter multiple lines in a box.

A comment about Pacman - Capture the Flag. Let's give each team three players, not the usual two. Also, note that the zip file includes a layouts folder. Be sure your strategy works for all layouts, not just the default one. The layouts are text files. You can open them with any text editor.

Last edited by rabbott at 09:43 Nov 17, 2018.
rabbott
Posts: 1649
Posted 16:49 Nov 16, 2018 |

Deleted. See post below.

Last edited by rabbott at 19:28 Nov 16, 2018.
rabbott
Posts: 1649
Posted 19:27 Nov 16, 2018 |

With the following changes I was able to run 3 agents/team on the jumboCapture layout. (You can make it work for other layouts as well.)

Unfortunately, the code is written so that the number of agents on a team is hard-wired. So, if you make these changes it will attempt to run 3 agents/team in all cases. That will work only on modified layouts.

 

In baselineTeam.py change line 34 from

def createTeam(firstIndex, secondIndex, isRed,

to

def createTeam(firstIndex, secondIndex, thirdIndex, isRed,

Change line 50 from 

return [eval(first)(firstIndex), eval(second)(secondIndex)]

to

return [eval(first)(firstIndex), eval(first)(secondIndex), eval(second)(thirdIndex)]

This puts two offensive players and one defensive player on the team being created for the baseline teams.

 

In capture.py, change lines 950 and 951 from

indices = [2*i + indexAddend for i in range(2)]
return createTeamFunc(indices[0], indices[1], isRed, **args)

to

indices = [2*i + indexAddend for i in range(3)]
return createTeamFunc(indices[0], indices[1], indices[2], isRed, **args)

 

In layout.py line 129, change

elif layoutChar in  ['1', '2', '3', '4']:

to

elif layoutChar in  ['1', '2', '3', '4', '5', '6']:

 

In the layouts directory, copy jumboCapture.lay and name the copy jumboCapture6.py

Add 5 and 6 to line 25 so that it looks like this.

%5          o%......%    %......%o          6%

When you run capture.py, include the arg: 

       -l jumboCapture6 

The letter is lower case 'L', for layout.

 

These changes should be rewritten so that the number of agents/team is flexible. But for now, this will give us 3 agents/team running on the jumbo layout.

Last edited by rabbott at 19:30 Nov 16, 2018.
rabbott
Posts: 1649
Posted 21:33 Nov 16, 2018 |

This version is slightly more general.

In baselineTeam.py change line 34 from

def createTeam(firstIndex, secondIndex, isRed,

to

def createTeam(indices, isRed,

Replace line 50, which is: 

return [eval(first)(firstIndex), eval(second)(secondIndex)]

with

agents = [eval('OffensiveReflexAgent' if (index//2)%2 == 0 else 'DefensiveReflexAgent')(index) for index in indices]
return agents

This puts two offensive players and one defensive player on the team being created for the baseline teams.

 

In capture.py replace lines 868-871 with

import layout
l = layout.getLayout(options.layout)
numAgents = len(l.agentPositions)//2
print('\nRed team %s with %s:' % (options.red, redArgs))
redAgents = loadAgents(True, options.red, nokeyboard, redArgs, numAgents)
print('\nBlue team %s with %s:' % (options.blue, blueArgs))
blueAgents = loadAgents(False, options.blue, nokeyboard, blueArgs, numAgents)

Delete line 887.

Replace line 919 with

def loadAgents(isRed, factory, textgraphics, cmdLineArgs, numAgents):

 

Replace range(2) with range(numAgents) in lines 929 and 945

 

Replace lines 947-951 with

indexAddend = 0 if isRed else 1
indices = [2*i + indexAddend for i in range(numAgents)]
return createTeamFunc(indices, isRed, **args)

In layout.py line 129, change

elif layoutChar in  ['1', '2', '3', '4']:

to

elif layoutChar.isdigit():

 

In the layouts directory, copy jumboCapture.lay and name the copy jumboCapture6.py

Add 5 and 6 to line 25 so that it looks like this.

%5          o%......%    %......%o          6%

When you run capture.py, include the arg: 

       -l jumboCapture6 

The letter is lower case 'L', for layout.

 

The code was originally written so that the layout determines the number of agents/team. But the original code didn't use that information. The changes above now use that information to determine the number of agents to generate per team. So if you run capture.py with no arguments or with any of the original layouts, two agents/team will be generated.

Last edited by rabbott at 21:49 Nov 16, 2018.
rabbott
Posts: 1649
Posted 22:39 Nov 16, 2018 |

Another bit of information about the layouts. When a agent is reborn after being eaten it starts at the spot where it was originally placed in the layout. So, it's possible to have agents start right at the edge of the opponent's territory each time they are reborn. It's even possible to put red agents in the blue area and vice versa. In that case the agent will go to the other side (it's own side) and start eating its own food pellets. A good way to make the agents crazy.

If you are playing the baseline agents against each other, it's a good idea not to make the initial placement of the agents completely symmetric. Otherwise, the offensive agents will meet at the border and just stare at each other.

Last edited by rabbott at 22:43 Nov 16, 2018.
rabbott
Posts: 1649
Posted 09:51 Nov 17, 2018 |

If you want to download my code rather than modifying yours, it's available here. This directory includes the modified files as well as an additional directory containing the unmodified original code.

Last edited by rabbott at 19:39 Nov 17, 2018.
rabbott
Posts: 1649
Posted 09:52 Nov 17, 2018 |

The link in the original message to the sign-up sheet didn't allow modifying the sheet. This one does. 

rabbott
Posts: 1649
Posted 11:07 Nov 19, 2018 |

I've adjusted some of the meeting times. Please check your time.

Last edited by rabbott at 11:08 Nov 19, 2018.