-
Notifications
You must be signed in to change notification settings - Fork 0
/
game_theory(saddle point and value).txt
137 lines (106 loc) · 3.36 KB
/
game_theory(saddle point and value).txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
JAVA CODE GAME THEORY
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package tst;
/**
*
* @author B.Ramanarayanan
*/
import java.util.*;
public class Tst {
/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
int m,n,i,j,value = 0,m1 = 0 ,n1 = 0,min,max;
System.out.println("Enter dimmension m and n");
m=s.nextInt();
n=s.nextInt();
int [][] saddle_pt = new int[m][n];
int[]minmax = new int[m];
int []maxmin = new int[n];
System.out.println("Enter the GAME THEORY matrix:");
for(i = 0; i<m;i++)
{
for(j = 0; j<n;j++)
{
saddle_pt[i][j] = s.nextInt();
}
}
for(i = 0; i<m;i++)
{
min = saddle_pt[i][0];
for(j = 0;j<(n-1);j++)
{
if(min>saddle_pt[i][j+1])
{
min = saddle_pt[i][j+1];
minmax[i]=min;
// m1 = j+1;
}
else
{
minmax[i] = min;
//m1 = j;
}
}
}
for(i = 0; i<n;i++)
{
max = saddle_pt[0][i];
for(j = 0;j<(m-1);j++)
{
if(max<saddle_pt[j+1][i])
{
max = saddle_pt[j+1][i];
maxmin[i]=max;
// n1 = j+1;
}
else
{
maxmin[i] = max;
n1 = j;
}
}
}
for(i=0;i<m;i++)
{
System.out.println("MINMAX VALUE :"+minmax[i]);
}
for(i=0;i<n;i++)
{
System.out.println("MAXMIN VALUE :"+maxmin[i]);
}
for(i = 0; i<m;i++)
{
for(j = 0;j<n;j++)
{
if(minmax[i]==maxmin[j])
{
value = minmax[i]=maxmin[j];
}
}
}
for(i = 0; i<m;i++)
{
for(j = 0;j<n;j++)
{
if(minmax[i]==maxmin[j])
{
if(saddle_pt[i][j]==value)
{
m1 = i;
n1 = j;
}
}
}
}
System.out.println("THE VALUE OF THE GAME :"+value);
System.out.println("SADDLE POINT :"+m1+n1);
}
}