Skip to content

Commit

Permalink
show agent info
Browse files Browse the repository at this point in the history
we added description and status to be passed on the backend side, then we update the ui for sidebar to display agent info.
  • Loading branch information
chiefeu committed Mar 12, 2024
1 parent 4104003 commit 3512254
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(self, agent_data={}):

self.matrix = agent_data.get('matrix')
if self.matrix:
self.matrix.add_to_logs({"agent_id":self.mid,"step_type":"agent_init","x":self.x,"y":self.y,"name":self.name,"goal":self.goal,"kind":self.kind})
self.matrix.add_to_logs({"agent_id":self.mid,"step_type":"agent_init","x":self.x,"y":self.y,"name":self.name,"goal":self.goal,"kind":self.kind,"description":self.description,"status":self.status})

def update_goals(self):
# this assumes 8+ importance is always worth changing /reevaluating goals
Expand Down
6 changes: 5 additions & 1 deletion web/src/classes/Agent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@ export class Agent {
isTalking: boolean;
isThinking: boolean;
status: string
description: string;
goal: string;

constructor(position: GridPosition, agentName: string, agentId: string, status: string) {
constructor(position: GridPosition, agentName: string, agentId: string, status: string, description: string, goal: string) {
this.position = position;
this.agentName = agentName;
this.agentId = agentId;
this.isTalking = false;
this.isThinking = false;
this.status = status;
this.description = description;
this.goal = goal;
this.steps = [];
}

Expand Down
39 changes: 31 additions & 8 deletions web/src/components/Sidebar.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
top: 0;
z-index: 3;
max-height: 100vh;
width: 300px;
width: 350px;
overflow: scroll;
}

Expand All @@ -20,7 +20,7 @@
}

.gameControls:hover {
background-color: rgba(255, 255, 255, 1);
background-color: rgba(255, 255, 255, 1);
}


Expand All @@ -30,8 +30,7 @@
margin: 5px;
}

.agentModule {
display: flex;
.agentInfoContainer {
border: 3px dashed #00bcd4;
background-color: sandybrown;
margin-top: 15px;
Expand All @@ -42,14 +41,38 @@
overflow: hidden;
}

.agentModule {
display: flex;
align-items: center;
position: relative;
}

.agentName {
font-size: x-large;
padding-left: 10px;
padding-left: 8px;
}

.thoughtSelector {
margin-left: auto;
display: flex;
align-items: center;
padding-left: 10px;
margin-left: auto;
display: flex;
align-items: center;
justify-content: center;
}

.closeButton {
margin-left: auto;
display: flex;
justify-content: flex-end;
color: black;
font-size: medium;
font-weight: bold;
border: 2px solid black;
border-radius: 8px;
padding: 4px 8px;
text-align: center;
}

.agentInfo {
text-align: justify;
}
32 changes: 20 additions & 12 deletions web/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,27 @@ const Sidebar: React.FC<SidebarProps> = (
// JSX for the Sidebar component goes here
<div className={styles.sidebar}>
{renderControls()}
{agentPlacement && <div className={styles.agentModule}>
<AgentSprite agentName={agentPlacement.agentName} isTalking={false} isThinking={false} status={agentPlacement.status} />
<div className={styles.agentName}>{agentPlacement.agentName}</div>
<div className={styles.thoughtSelector}>
<label>
<input type="checkbox" checked={showThoughts} onChange={() => setShowThoughts(!showThoughts)} />
Show Thoughts
</label>
{agentPlacement && <div className={styles.agentInfoContainer}>
<div className={styles.agentModule}>
<AgentSprite agentName={agentPlacement.agentName} isTalking={false} isThinking={false} status={agentPlacement.status} />
<div className={styles.agentName}>{agentPlacement.agentName}</div>
<div className={styles.thoughtSelector}>
<label>
<input type="checkbox" checked={showThoughts} onChange={() => setShowThoughts(!showThoughts)} />
Show Thoughts
</label>
</div>
<button onClick={() => setFollowAgent(undefined)} className={styles.closeButton}>
Close
</button>
</div>
<button onClick={() => setFollowAgent(undefined)}>
Close
</button>
</div>}
<hr />
<div>
<p className={styles.agentInfo}><strong>Description:</strong> {agentPlacement.description}</p>
<p className={styles.agentInfo}><strong>Goal:</strong> {agentPlacement.goal}</p>
</div>
</div>
}
<>
{renderTimeline()}
</>
Expand Down
16 changes: 10 additions & 6 deletions web/src/steps/NewAgentStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,36 @@ export interface NewAgentJSON extends StepJSON {
name: string;
agent_id: string;
status: string;
description: string;
goal: string;
}

export class NewAgentStep extends Step {
agentId: string;
agentName: string;
position: GridPosition;
agentStatus: string;
agentDescription: string;
agentGoal: string;

constructor(stepId: number, substepId: number, agentId: string, agentName: string, position: GridPosition, agentStatus: string) {
constructor(stepId: number, substepId: number, agentId: string, agentName: string, position: GridPosition, agentStatus: string, agentDescription: string, agentGoal: string) {
super(stepId, substepId);
this.agentId = agentId;
this.agentName = agentName;
this.position = position;
this.agentStatus = agentStatus;
this.agentDescription = agentDescription;
this.agentGoal = agentGoal;
}

applyStep(level: Level) {
const placement = new Agent(this.position, this.agentName, this.agentId, this.agentStatus);
const placement = new Agent(this.position, this.agentName, this.agentId, this.agentStatus, this.agentDescription, this.agentGoal);

level.agents.push(placement);
}

static fromJSON(json: NewAgentJSON): NewAgentStep {
const position: GridPosition = { x: json.y, y: json.x };
return new NewAgentStep(json.step, json.substep, json.agent_id, json.name, position, json.status);
return new NewAgentStep(json.step, json.substep, json.agent_id, json.name, position, json.status, json.description, json.goal);
}
}


}

0 comments on commit 3512254

Please sign in to comment.