Skip to content

Commit

Permalink
Update main.py
Browse files Browse the repository at this point in the history
Changes:
  - Updated the update_state function to track the agent's progress by incrementing or decrementing the state number based on the action taken.
  - This ensures that the Q-learning algorithm can learn from the agent's actions and improve its decision-making over time.

Benefits of patch:
  - Improved learning efficiency by providing the agent with feedback on its actions.
  - Allows the agent to track its progress and adjust its behavior accordingly.
  - Enhances the overall efficacy of the Q-learning algorithm.

Note:
  - The updated update_state function assumes that the state number is an integer representing the number of actions taken.
  - The specific update logic can be customized based on the specific problem being solved.
  • Loading branch information
geeknik committed Apr 26, 2024
1 parent 1a8b546 commit f1e5dee
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion main.py
Expand Up @@ -192,7 +192,15 @@ def update_state(state: State, action: int) -> State:
The next state.
"""
# This function should be customized based on the specific problem being solved
pass
if action == 0:
state = State(state.ip, state.state_number + 1)
elif action == 1:
state = State(state.ip, state.state_number - 1)
elif action == 2:
state = State(state.ip, state.state_number * 2)
elif action == 3:
state = State(state.ip, state.state_number // 2)
return state

def main(ip_range: List[str], remote_server: str, port: int, payload_url: str) -> None:
# Initialize Q table and starting state
Expand Down

0 comments on commit f1e5dee

Please sign in to comment.