Skip to content
The Chat Archive
chatgpt-4o-latest-20250326· OpenAI LMArena Human Preference 140K

Can you write me a simulation in html and javascript in a single file. You don't need to…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with o3-2025-04-16’s answer.
  1. User

    Can you write me a simulation in html and javascript in a single file. You don't need to write any explanation, the code is enough. The simulation should help the user understand project portfolio management better

  2. Assistant

    Sure! Here's a self-contained HTML and JavaScript simulation that demonstrates basic Project Portfolio Management (PPM) concepts. It allows users to manage a portfolio of projects with different costs, benefits, and risks, and simulates resource allocation and portfolio value over time.

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8" />
      <title>Project Portfolio Management Simulation</title>
      <style>
        body {
          font-family: Arial, sans-serif;
          margin: 20px;
        }
        h1 {
          text-align: center;
        }
        #project-form input, #project-form select {
          margin: 5px;
        }
        table {
          width: 100%;
          border-collapse: collapse;
          margin-top: 15px;
        }
        th, td {
          border: 1px solid #ccc;
          padding: 8px;
          text-align: center;
        }
        .controls {
          margin-top: 20px;
          text-align: center;
        }
        .summary {
          margin-top: 20px;
        }
      </style>
    </head>
    <body>
      <h1>Project Portfolio Management Simulation</h1>
    
      <div id="project-form">
        <input type="text" id="name" placeholder="Project Name" />
        <input type="number" id="cost" placeholder="Cost" />
        <input type="number" id="benefit" placeholder="Expected Benefit" />
        <select id="risk">
          <option value="Low">Low Risk</option>
          <option value="Medium">Medium Risk</option>
          <option value="High">High Risk</option>
        </select>
        <button onclick="addProject()">Add Project</button>
      </div>
    
      <table id="project-table">
        <thead>
          <tr>
            <th>Name</th>
            <th>Cost</th>
            <th>Benefit</th>
            <th>Risk</th>
            <th>Status</th>
            <th>Progress</th>
            <th>Action</th>
          </tr>
        </thead>
        <tbody></tbody>
      </table>
    
      <div class="controls">
        <button onclick="simulateStep()">Simulate Step</button>
        <button onclick="resetSimulation()">Reset</button>
      </div>
    
      <div class="summary">
        <h3>Portfolio Summary</h3>
        <p>Total Budget: <span id="total-budget">1000</span></p>
        <p>Remaining Budget: <span id="remaining-budget">1000</span></p>
        <p>Total Benefit Realized: <span id="total-benefit">0</span></p>
      </div>
    
      <script>
        let projects = [];
        let totalBudget = 1000;
        let remainingBudget = 1000;
        let totalBenefit = 0;
    
        function addProject() {
          const name = document.getElementById('name').value;
          const cost = parseFloat(document.getElementById('cost').value);
          const benefit = parseFloat(document.getElementById('benefit').value);
          const risk = document.getElementById('risk').value;
    
          if (!name || isNaN(cost) || isNaN(benefit)) {
            alert("Please fill in all fields correctly.");
            return;
          }
    
          projects.push({
            name,
            cost,
            benefit,
            risk,
            status: 'Planned',
            progress: 0
          });
    
          renderProjects();
        }
    
        function renderProjects() {
          const tbody = document.querySelector('#project-table tbody');
          tbody.innerHTML = '';
          projects.forEach((p, index) => {
            const tr = document.createElement('tr');
            tr.innerHTML = `
              <td>${p.name}</td>
              <td>${p.cost}</td>
              <td>${p.benefit}</td>
              <td>${p.risk}</td>
              <td>${p.status}</td>
              <td>${p.progress}%</td>
              <td>
                ${p.status === 'Planned' && remainingBudget >= p.cost ? `<button onclick="startProject(${index})">Start</button>` : ''}
              </td>
            `;
            tbody.appendChild(tr);
          });
    
          document.getElementById('remaining-budget').textContent = remainingBudget.toFixed(2);
          document.getElementById('total-benefit').textContent = totalBenefit.toFixed(2);
        }
    
        function startProject(index) {
          const project = projects[index];
          if (remainingBudget >= project.cost) {
            remainingBudget -= project.cost;
            project.status = 'In Progress';
            project.progress = 0;
            renderProjects();
          } else {
            alert("Not enough budget to start this project.");
          }
        }
    
        function simulateStep() {
          projects.forEach(p => {
            if (p.status === 'In Progress') {
              let riskFactor = 1;
              if (p.risk === 'Medium') riskFactor = 0.8;
              if (p.risk === 'High') riskFactor = 0.6;
    
              const progressIncrement = Math.random() * 30 * riskFactor;
              p.progress += progressIncrement;
    
              if (p.progress >= 100) {
                p.progress = 100;
                p.status = 'Completed';
                totalBenefit += p.benefit;
              }
            }
          });
          renderProjects();
        }
    
        function resetSimulation() {
          projects = [];
          totalBudget = 1000;
          remainingBudget = 1000;
          totalBenefit = 0;
          renderProjects();
        }
    
        renderProjects();
      </script>
    </body>
    </html>
    

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.