Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
PyGAAMAS
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maxime Morge
PyGAAMAS
Commits
f8b59471
Commit
f8b59471
authored
2 weeks ago
by
Maxime Morge
Browse files
Options
Downloads
Patches
Plain Diff
PyGAAMAS: Strategies generated by models fo MP
parent
89f2754b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/mp/mp.py
+28
-11
28 additions, 11 deletions
src/mp/mp.py
with
28 additions
and
11 deletions
src/mp/mp.py
+
28
−
11
View file @
f8b59471
...
@@ -203,15 +203,8 @@ class MP:
...
@@ -203,15 +203,8 @@ class MP:
"""
Play the next move using a heuristic.
"""
"""
Play the next move using a heuristic.
"""
prediction
=
""
prediction
=
""
print
(
self
.
model
)
print
(
self
.
model
)
if
self
.
model
==
"
gpt-4.5-preview-2025-02-27
"
:
if
self
.
model
==
"
gpt-4.5-preview-2025-02-27
"
:
"""
Play the next move using a heuristic.
- Simple strategy: Alternate between
"
Head
"
and
"
Tail
"
.
- Prediction: Assume opponent is also alternating.
"""
moves
=
[
"
Head
"
,
"
Tail
"
]
moves
=
[
"
Head
"
,
"
Tail
"
]
# If no rounds played, start with "Head"
# If no rounds played, start with "Head"
if
not
self
.
history
:
if
not
self
.
history
:
move
=
"
Head
"
move
=
"
Head
"
...
@@ -221,20 +214,16 @@ class MP:
...
@@ -221,20 +214,16 @@ class MP:
+
(
f
"
Predicting opponent starts with
'
Tail
'
(alternating).
"
if
self
.
prediction
else
""
)
+
(
f
"
Predicting opponent starts with
'
Tail
'
(alternating).
"
if
self
.
prediction
else
""
)
)
)
return
move
,
prediction
,
reasoning
return
move
,
prediction
,
reasoning
# Get last move you played and the opponent's last move
# Get last move you played and the opponent's last move
last_agent_move
=
self
.
history
[
-
1
][
"
Agent Move
"
]
last_agent_move
=
self
.
history
[
-
1
][
"
Agent Move
"
]
last_opponent_move
=
self
.
history
[
-
1
][
"
Opponent Move
"
]
last_opponent_move
=
self
.
history
[
-
1
][
"
Opponent Move
"
]
# Alternate your move from last time
# Alternate your move from last time
move
=
"
Tail
"
if
last_agent_move
==
"
Head
"
else
"
Head
"
move
=
"
Tail
"
if
last_agent_move
==
"
Head
"
else
"
Head
"
# Prediction: Suppose opponent is also alternating
# Prediction: Suppose opponent is also alternating
if
self
.
prediction
:
if
self
.
prediction
:
prediction
=
"
Tail
"
if
last_opponent_move
==
"
Head
"
else
"
Head
"
prediction
=
"
Tail
"
if
last_opponent_move
==
"
Head
"
else
"
Head
"
else
:
else
:
prediction
=
"
None
"
prediction
=
"
None
"
reasoning
=
(
reasoning
=
(
f
"
Last round I played
{
last_agent_move
}
, opponent played
{
last_opponent_move
}
.
"
f
"
Last round I played
{
last_agent_move
}
, opponent played
{
last_opponent_move
}
.
"
f
"
I
'
m alternating my move to
'
{
move
}
'
.
"
f
"
I
'
m alternating my move to
'
{
move
}
'
.
"
...
@@ -244,6 +233,34 @@ class MP:
...
@@ -244,6 +233,34 @@ class MP:
)
)
)
)
return
move
,
prediction
,
reasoning
return
move
,
prediction
,
reasoning
if
self
.
model
==
"
mistral-small
"
:
if
not
self
.
history
:
# If there is no history yet, play randomly.
moves
=
[
"
Head
"
,
"
Tail
"
]
return
random
.
choice
(
moves
),
f
"
First round, choosing
{
random
.
choice
(
moves
)
}
.
"
head_count
=
0
tail_count
=
0
for
move
in
[
r
[
'
Opponent Move
'
]
for
r
in
self
.
history
]:
if
move
==
'
Head
'
:
head_count
+=
1
elif
move
==
'
Tail
'
:
tail_count
+=
1
# If there are more heads, play Tail and vice versa.
if
head_count
>
tail_count
:
next_move
=
"
Tail
"
elif
tail_count
>
head_count
:
next_move
=
"
Head
"
else
:
# Equal counts
moves
=
[
"
Head
"
,
"
Tail
"
]
next_move
=
random
.
choice
(
moves
)
reasoning
=
f
"
Opponent
'
s
'
Head
'
count:
{
head_count
}
,
'
Tail
'
count:
{
tail_count
}
. Chose to play
'
{
next_move
}
'
based on the opponent
'
s move frequency.
"
return
next_move
,
"
None
"
,
reasoning
if
self
.
model
==
"
qwen3
"
:
move
=
random
.
choice
([
"
Head
"
,
"
Tail
"
])
prediction
=
move
# Assume the opponent will match our move
reasoning
=
f
"
Choosing randomly. Assuming the opponent will match my move
{
move
}
.
"
return
move
,
prediction
,
reasoning
return
"
None
"
,
"
None
"
,
"
None
"
else
:
else
:
opponent_move
=
self
.
opponent_strategy_fn
(
self
.
history
)
opponent_move
=
self
.
opponent_strategy_fn
(
self
.
history
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment