Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
progseq-puissance4
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
dario.genga
progseq-puissance4
Commits
45a24c4d
Commit
45a24c4d
authored
3 years ago
by
dario.genga
Browse files
Options
Downloads
Patches
Plain Diff
Add random play
parent
4f312d72
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
main.c
+5
-16
5 additions, 16 deletions
main.c
puissance.c
+7
-2
7 additions, 2 deletions
puissance.c
with
12 additions
and
18 deletions
main.c
+
5
−
16
View file @
45a24c4d
...
...
@@ -5,31 +5,20 @@
#include
<stdio.h>
#include
<stdlib.h>
#include
<time.h>
#include
"puissance.h"
int
main
()
{
srand
(
time
(
NULL
));
puissance
game
;
game_init
(
&
game
,
RAND_AI
,
DEFAULT_ROW
,
DEFAULT_COL
);
print_game
(
game
);
random_play
(
&
game
);
print_game
(
game
);
m
an
ual
_play
(
&
game
,
0
);
r
an
dom
_play
(
&
game
);
print_game
(
game
);
manual_play
(
&
game
,
4
);
print_game
(
game
);
manual_play
(
&
game
,
0
);
print_game
(
game
);
manual_play
(
&
game
,
-
1
);
print_game
(
game
);
manual_play
(
&
game
,
9
);
print_game
(
game
);
manual_play
(
&
game
,
0
);
manual_play
(
&
game
,
0
);
manual_play
(
&
game
,
0
);
manual_play
(
&
game
,
0
);
print_game
(
game
);
manual_play
(
&
game
,
0
);
manual_play
(
&
game
,
1
);
random_play
(
&
game
);
print_game
(
game
);
game_destroy
(
&
game
);
...
...
This diff is collapsed.
Click to expand it.
puissance.c
+
7
−
2
View file @
45a24c4d
...
...
@@ -153,9 +153,14 @@ bool manual_play(puissance *p, int selected_col_index) {
}
bool
random_play
(
puissance
*
p
)
{
bool
valid_action
=
true
;
int
max
=
p
->
col
-
1
;
int
min
=
0
;
int
random_index
=
-
1
;
do
{
random_index
=
rand
()
%
(
max
-
min
+
1
)
+
min
;
}
while
(
manual_play
(
p
,
random_index
)
==
false
);
return
valid_action
;
return
true
;
}
bool
smart_play
(
puissance
*
p
)
{
...
...
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